Cucumber default_url_options [: host] each time "www.example.com", even if specified in environmenttemnts / test.rb

I have specified default_url_options in my /test.rb environments with

config.action_mailer.default_url_options = { :host => "www.xyu.at" }

This is quite normal in my cucumber history, where I test user registration, the link to activate the user is generated correctly

invitation_activation_url(1)
=> "www.xyu.at/signup/1231hj23jh23"

But when I try to follow the link provided in the email with the following code in the / steps / user _steps.rb functions (using the email address-rspec from http://github.com/bmabey/email-spec/tree/master ) :

When /^I follow the invitation link$/ do
  When 'I follow "'+invitation_activation_url(1) + '" in the email'
end

Here the URL is created using the default host:

invitation_activation_url(1)
=> "www.example.com/signup/1231hj23jh23"

Can someone help me? I do not understand what I am doing wrong ....

Thanks!

EDIT:

It looks like a method

current_url

but I donโ€™t know where it came from ..?

EDIT:

, /support/env.rb

ENV["RAILS_ENV"] ||= "test"

EDIT:

- , edbond,

invitation_activation_url(1, :host => "www.xyz.at")
  => "www.xyz.at/signup/1231hj23jh23"

( / test.rb - )

+5
5

: URL.

invitation_activation_url(1, :host => "www.xyz.at")
  => "www.xyz.at/signup/1231hj23jh23"

EDIT:

  mail = YourMailer.deliveries.last
  email_html = Nokogiri::HTML mail.body.to_s
  approve_link = email_html.at_css("a")["href"]
+1

, .. , , , .

When /^I follow the invitation link$/ do
  When 'I follow "'+invitation_activation_path(1) + '" in the email'
end

_url URL-; _path URI. web_steps.rb URI current_url, .

http://api.rubyonrails.org/classes/ActionDispatch/Routing.html

, : as, name_of_route_url URL- name_of_route_path URI.

web_steps.rb

Then /^(?:|I )should be on (.+)$/ do |page_name|                                                                                                                                     |  #     end                                                                                                                                                                           
  current_path = URI.parse(current_url).path                                                                                                                                         |  #                                                                                                                                                                                   
  if current_path.respond_to? :should                                                                                                                                                |  #     collection do                                                                                                                                                                 
    current_path.should == path_to(page_name)                                                                                                                                        |  #       get 'sold'                                                                                                                                                                  
  else                                                                                                                                                                               |  #     end                                                                                                                                                                           
    assert_equal path_to(page_name), current_path                                                                                                                                    |  #   end                                                                                                                                                                             
  end                                                                                                                                                                                |
end 
+1

, config/environment/test.rb. , Cucumber "test"?

Cucumber , , , , "".

/support/env.rb :

ENV["RAILS_ENV"] ||= "cucumber"

, , config/environment/cucumber.rb.

0

Cucumber, , . , default_url_options , url...

, - , URL. self.class. , -. , , 'ClassName' .

, config/environment/test.rb , , :

class ClassName
  cattr_accessor :default_url_options
  # or mattr_ if it a module
end

, actionmailer

ClassName.default_url_options = { :host => "www.xyu.at" }

, URL- ( ActionController:: UrlWriter).

0

( info ) ,

Given /^the domain "(.+?)"$/ do |domain|
  host! domain
end

Given the domain "www.foo.com"

.

, , , . , .

Cucumber env.rb:

# There is a bug in internal_redirect? when used with explicit (non-example.com) domains.
# This is a simple workaround but may break if we start specing external redirects.
# https://webrat.lighthouseapp.com/projects/10503/tickets/140-current_url-should-be-fully-qualified
class Webrat::Session
  alias internal_redirect? redirect?
end

, , , , .

0

All Articles