开发者

Cucumber step failing for Devise, connection refused?

I'm trying to get some Cucumber tests working with Devise, and I have the following step definition:

Given /^(?:I am|I have|I) signed up (?:as|with) "(.*)\/(.*)"$/ do |email, password|
  Factory(:user, :email => email, :password => password, :password_confirmation => password)
end

And this for my User factory:

Factory.define :user do |u|
  u.sequence(:email) { |n| "testing@example#{n}.com" }
  u.password "test_pass"
  u.password_confirmation "test_pass"
  u.sequence(:display_name) { |n| "user#{n}" }
  u.people { |i| [i.association(:person), i.association(:person)] }
end

And I have these Devise modules loaded (in app/models/user.rb):

# Include Devise modules
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable, :confirmable, :lockable, :timeoutable

I run a Cucumber scenario with the above step, and it fails with:

Given I am signed in as "a_new_user@example.com/test_password" # features/step_definitions/devise_steps.rb:7
  Connection refused - connect(2) (Errno::ECONNREFUSED)
  /Users/macbook/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/smtp.rb:551:in `initialize'
  /Users/macbook/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/smtp.rb:551:in `open'
  /Users/macbook/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/smtp.rb:551:in `block in do_start'
  /Users/macbook/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/timeout.rb:57:in `timeout'
  /Users/macbook/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/timeout.rb:87:in `timeout'
  /Users/macbook/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/smtp.rb:551:in `do_start'
  /Users/macbook/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/smtp.rb:525:in `start'
  ./features/step_definitions/devise_steps.rb:4:in `/^(?:I am|I have|I) signed up (?:as|with) 开发者_JAVA百科"(.*)\/(.*)"$/'
  features/users/friends.feature:7:in `Given I am signed in as "a_new_user@example.com/test_password"'

... which I assume is related to the sending of the confirmation email when a new user is created, which I have configured in config/environments/cucumber.rb:

App::Application.configure do

  # sets our mailer to localhost for the mailer (Devise)
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }

end

How do I get around this/fix this/avoid this? Let me know if you need anymore info to help me solve this issue...


Do you have this in your environments/test.rb file:

config.action_mailer.delivery_method = :test

This tells rails "not to deliver emails to the real world".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜