#359 new
kmandrup

Raisl 3 cucumber integration problem - certain web steps

Reported by kmandrup | February 22nd, 2010 @ 05:43 PM

We almost have a cucumber-rails for Rails 3 working:

http://gist.github.com/311597

Scenario: Register new person # features/manage_people.feature:6

Given I am on the new person page # features/step_definitions/web_steps.rb:13
When I fill in "Name" with "name 1" # features/step_definitions/web_steps.rb:33
And I press "Create" # features/step_definitions/web_steps.rb:21
Then I should see "name 1" # features/step_definitions/web_steps.rb:141
expected the following element's content to include "name 1": You are being redirected. is not true. (Test::Unit::AssertionFailedError) ./features/step_definitions/web_steps.rb:146:in /^(?:|I )should see "([^\"]*)"$/' features/manage_people.feature:10:inThen I should see "name 1"'

web_steps.rb

Then /^(?:|I )should see \/([^\/])\/ within "([^"])"$/ do |regexp, selector|
within(selector) do |content|

regexp = Regexp.new(regexp)
if defined?(Spec::Rails::Matchers)
  content.should contain(regexp)
else
  assert_match(regexp, content)
end

end end

Is Spec::Rails::Matchers called something different in Rails 3? or how do we include it?
The assert doesn't seem to work either... ?

If we run the app manually in a browser, it works as expected and "name 1" is displayed after creating a new person by pressing the submit button.

Thanks for any assistance!

Comments and changes to this ticket

  • kmandrup

    kmandrup February 22nd, 2010 @ 06:11 PM

    .feature fix

    Then I should see "name 1" on the index page
    

    paths.rb

    when /the index page/
      people_path
    

    web_steps.rb

    Then /^(?:|I )should see "([^"]*)" on (.+)$/ do |text, page_name|
    visit path_to(page_name) if defined?(Spec::Rails::Matchers)

    response.should contain(text)
    

    else

    assert_contain text
    

    end end

    I think there should be a new web_steps.rb file for Rails 3

  • Louis Rose

    Louis Rose February 24th, 2010 @ 10:26 AM

    I'm not sure if this is the cause of the problem, but in the current version of Rspec 2.0, it seems that Spec modules have been renamed to Rspec.

    Does the following change fix the problem?

    if defined?(Spec::Rails::Matchers)
    

    becomes:

    if defined?(Rspec::Rails::Matchers)
    
  • xinuc

    xinuc August 31st, 2010 @ 04:25 AM

    • Milestone order changed from “0” to “0”

    for me, the problem is webrat not following redirect, and just return "You are being redirected"

    I use webrat 0.7.2.beta.1

  • lminaudier

    lminaudier October 18th, 2010 @ 10:56 AM

    Hi guys,

    Was in that case too with webrat 0.7.2.beta.2
    Webrat doesn't follow controller's redirect_to calls and just return "You are being redirected"

    Google finally points me to Stack Overflow

    The solution of 'justsee' to patch 'lib/webrat/core/session.rb' works well for me.

    #/lib/webrat/core/session.rb
    #starting at line 288
    
    def current_host
    - URI.parse(current_url).host || @custom_headers["Host"] || "www.example.com"
    + URI.parse(current_url).host || @custom_headers["Host"] || default_current_host
    end
    
    + def default_current_host
    +   adapter.class==Webrat::RackAdapter ? "example.org" : "www.example.com"
    + end
    
  • Becasims

    Becasims April 20th, 2012 @ 08:08 AM

    There were a lot of conversations about the college research paper service. However, university students will know lots about the publishing service purchasing authors topics there in authorhouse.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Pages