Suzanne | 26 Feb 22:03 2012
Picon

[Cucumber:10555] paths.rb file

Okay I a very confused.  I have been following a rails book that uses
webrat and since it is no longer valid, I am getting quite frustrated
with the very simple.  Given I am on the home page.  I bought the
cucumber book, but it doesn't specifically discuss routing.  So am I
supposed to be using a paths.rb file?  Is there a good example as to
what my routes should look like?

here is my error

Feature: Signing up
  In order to be attributed for my work
  As a user
  I want to be able to sign up

  Scenario: Signing up                                     # features/
signing_up.feature:6
    Given I am on the homepage                             # features/
step_definitions/Signing_up_steps.rb:1
      undefined method `path_to' for #<Cucumber::Rails::World:
0x2f42200> (NoMethodError)
      ./features/step_definitions/Signing_up_steps.rb:2:in `/^I am on
the (.+)$/'
      features/signing_up.feature:7:in `Given I am on the homepage'
    When I follow "Sign up"                                # features/
step_definitions/Signing_up_steps.rb:5
    And I fill in "Email" with "coutsuza@..." # features/
step_definitions/Signing_up_steps.rb:9
    And I fill in "Password" with "password".              # features/
step_definitions/Signing_up_steps.rb:13
    And I fill in "Password confirmation" with "password"  # features/
(Continue reading)

Jon Kern | 26 Feb 23:22 2012
Picon

Re: [Cucumber:10557] paths.rb file

i may not have the latest syntax for you...

but, it doesn't know what to do with "I am on the homepage"

and it looks like you defined a step for it?

try using a more common phrase that the paths.rb will pick up, like
     When I go to the home page
and then add a path as shown below.

in an older project, i see i have a features/support/paths.rb file with 
stuff like this in it:
module NavigationHelpers
   # Maps a name to a path. Used by the
   #
   #   When /^I go to (.+)$/ do |page_name|
   #
   # step definition in web_steps.rb
   #
   def path_to(page_name)
     case page_name

       when /the home\s?page/
         root_path

       when /login/
         login_path

       when /re-run messages/i
         url_for({:controller => '/message_logs', :action => 
(Continue reading)

Jon Kern | 26 Feb 23:28 2012
Picon

Re: [Cucumber:10558] paths.rb file

In a rails3 app, i see my paths.rb looks like this:

module NavigationHelpers
  # Maps a name to a path. Used by the
  #
  #   When /^I go to (.+)$/ do |page_name|
  #
  # step definition in web_steps.rb
  #
  def path_to(page_name)
    case page_name

    when /^the home\s?page$/
      '/'

      when /^sign in page$/
        '/users/sign_in'
      when /^sign out page$/
        '/users/sign_out'
    # Add more mappings here.
    # Here is an example that pulls values out of the Regexp:
    #
    #   when /^(.*)'s profile page$/i
    #     user_profile_path(User.find_by_login($1))

    else
      begin
        page_name =~ /^the (.*) page$/
        path_components = $1.split(/\s+/)
        self.send(path_components.push('path').join('_').to_sym)
      rescue NoMethodError, ArgumentError
        raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
          "Now, go and add a mapping in #{__FILE__}"
      end
    end
  end
end

World(NavigationHelpers)

And in my env.rb, i see i am still using webrat (i'd share the whole env.rb, but i have it sporkified, and i don't want to confuse you further with that (!):

  require 'webrat'

  Webrat.configure do |config|
    config.mode = :rails
  end

  require 'cucumber/rails'

  require 'webrat/core/matchers'
  require 'cucumber'                   # I needed to add this... We could move this require to Spork if we think it is better there...
  require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
  require 'rspec/rails'                # I needed to add this as well to avoid the #records error...
  require 'cucumber/rails/rspec'

  # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
  # order to ease the transition to Capybara we set the default here. If you'd
  # prefer to use XPath just remove this line and adjust any selectors in your
  # steps to use the XPath syntax.
  Capybara.default_selector           = :css

Some of my gems:
capybara (1.1.2)
cucumber (1.1.4)
cucumber-rails (1.2.1)
gherkin (2.7.3)
webrat (0.7.3)

My blog has some cucumber stuff as well.
jon blog: http://technicaldebt.com twitter: http://twitter.com/JonKernPA
Suzanne said the following on 2/26/12 4:03 PM:
Okay I a very confused. I have been following a rails book that uses webrat and since it is no longer valid, I am getting quite frustrated with the very simple. Given I am on the home page. I bought the cucumber book, but it doesn't specifically discuss routing. So am I supposed to be using a paths.rb file? Is there a good example as to what my routes should look like? here is my error Feature: Signing up In order to be attributed for my work As a user I want to be able to sign up Scenario: Signing up # features/ signing_up.feature:6 Given I am on the homepage # features/ step_definitions/Signing_up_steps.rb:1 undefined method `path_to' for #<Cucumber::Rails::World: 0x2f42200> (NoMethodError) ./features/step_definitions/Signing_up_steps.rb:2:in `/^I am on the (.+)$/' features/signing_up.feature:7:in `Given I am on the homepage' When I follow "Sign up" # features/ step_definitions/Signing_up_steps.rb:5 And I fill in "Email" with "coutsuza-2/1dyl5XNkz7FfK2uYURpw@public.gmane.org" # features/ step_definitions/Signing_up_steps.rb:9 And I fill in "Password" with "password". # features/ step_definitions/Signing_up_steps.rb:13 And I fill in "Password confirmation" with "password" # features/ step_definitions/Signing_up_steps.rb:9 And I press "Sign up" # features/ step_definitions/Signing_up_steps.rb:17 Then I should see "You have signed up successfully." # features/ step_definitions/Signing_up_steps.rb:21 This is what I have in my steps. Given /^I am on the (.+)$/ do |page_name| visit path_to(page_name) end in my routes I have root :to => "home#index" formally I had used "home/index" instead of page_name, but that didn't work There is so much contradictory information I am getting quite frustrated. I had thought the cucumber book would set it straight, but alas it has not. HELP

--
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.

Suzanne | 26 Feb 23:50 2012
Picon

[Cucumber:10559] Re: paths.rb file

okay so I thought webrat was out.......that is the beginning of my
confusion....

so if not webrat what?  and also are you saying that a path.rb file is
required.  it is not discussed in the cucumber book?

On Feb 26, 5:28 pm, Jon Kern <jonker...@...> wrote:
> In a rails3 app, i see my paths.rb looks like this:module NavigationHelpers
>   # Maps a name to a path. Used by the
>   #
>   #   When /^I go to (.+)$/ do |page_name|
>   #
>   # step definition in web_steps.rb
>   #
>   def path_to(page_name)
>     case page_name
>     when /^the home\s?page$/
>       '/'
>       when /^sign in page$/
>         '/users/sign_in'
>       when /^sign out page$/
>         '/users/sign_out'
>     # Add more mappings here.
>     # Here is an example that pulls values out of the Regexp:
>     #
>     #   when /^(.*)'s profile page$/i
>     #     user_profile_path(User.find_by_login($1))
>     else
>       begin
>         page_name =~ /^the (.*) page$/
>         path_components = $1.split(/\s+/)
>         self.send(path_components.push('path').join('_').to_sym)
>       rescue NoMethodError, ArgumentError
>         raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
>           "Now, go and add a mapping in #{__FILE__}"
>       end
>     end
>   end
> end
> World(NavigationHelpers)
> And in my env.rb, i see i am still using webrat (i'd share the whole env.rb, but i have it sporkified, and i
don't want to confuse you further with that (!):  require 'webrat'
>   Webrat.configure do |config|
>     config.mode = :rails
>   end
>   require 'cucumber/rails'
>   require 'webrat/core/matchers'
>   require 'cucumber'                   # I needed to add this... We could move
this require to Spork if we think it is better there...
>   require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
>   require 'rspec/rails'                # I needed to add this as well to avoid the
#records error...
>   require 'cucumber/rails/rspec'
>   # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
>   # order to ease the transition to Capybara we set the default here. If you'd
>   # prefer to use XPath just remove this line and adjust any selectors in your
>   # steps to use the XPath syntax.
>   Capybara.default_selector           = :css
> Some of my gems:
> capybara (1.1.2)
> cucumber (1.1.4)
> cucumber-rails (1.2.1)
> gherkin (2.7.3)
> webrat (0.7.3)
> My blog has somecucumberstuff as well.jon blog:http://technicaldebt.comtwitter:http://twitter.com/JonKernPA
> Suzanne said the following on 2/26/12 4:03 PM:Okay I a very confused. I have been following a rails book
that uses webrat and since it is no longer valid, I am getting quite frustrated with the very simple. Given I
am on the home page. I bought the cucumber book, but it doesn't specifically discuss routing. So am I
supposed to be using a paths.rb file? Is there a good example as to what my routes should look like? here is my
error Feature: Signing up In order to be attributed for my work As a user I want to be able to sign up Scenario:
Signing up # features/ signing_up.feature:6 Given I am on the homepage # features/
step_definitions/Signing_up_steps.rb:1 undefined method `path_to' for
#<Cucumber::Rails::World: 0x2f42200> (NoMethodError)
./features/step_definitions/Signing_up_steps.rb:2:in `/^I am on the (.+)$/'
features/signing_up.feature:7:in `Given I am on the homepage' When I follow "Sign up" # features/
step_definitions/Signing_up_steps.rb:5 And I fill in "Email"
with"coutsuza@..."# features/
step_definitions/Signing_up_steps.rb:9 And I fill in "Password" with "password". # features/
step_definitions/Signing_up_steps.rb:13 And I fill in "Password confirmation" with "password" #
features/ step_definitions/Signing_up_steps.rb:9 And I press "Sign up" # features/
step_definitions/Signing_up_steps.rb:17 Then I should see "You have signed up successfully." #
features/ step_definitions/Signing_up_steps.rb:21 This is what I have in my steps. Given /^I am on the
(.+)$/ do |page_name| visit path_to(page_name) end in my routes I have root :to => "home#index" formally
I had used "home/index" instead of page_name, but that didn't work There is so much contradictory
information I am getting quite frustrated. I had thought the cucumber book would set it straight, but alas
it has not. HELP

--

-- 
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cukes@...
To unsubscribe from this group, send email to cukes+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.

Aslak Hellesøy | 27 Feb 00:47 2012
Picon

Re: [Cucumber:10560] Re: paths.rb file

On Feb 26, 2012, at 22:50, Suzanne <coutsuza@...> wrote:

> okay so I thought webrat was out.......that is the beginning of my
> confusion....
>
> so if not webrat what?

Capybara. The book has a full chapter on it. Have you read that chapter?

>  and also are you saying that a path.rb file is
> required.

Boilerplate code like paths.rb is no longer recommended:
http://aslakhellesoy.com/post/11055981222/the-training-wheels-came-off

Aslak

>  it is not discussed in the cucumber book?
>
> On Feb 26, 5:28 pm, Jon Kern <jonker...@...> wrote:
>> In a rails3 app, i see my paths.rb looks like this:module NavigationHelpers
>>   # Maps a name to a path. Used by the
>>   #
>>   #   When /^I go to (.+)$/ do |page_name|
>>   #
>>   # step definition in web_steps.rb
>>   #
>>   def path_to(page_name)
>>     case page_name
>>     when /^the home\s?page$/
>>       '/'
>>       when /^sign in page$/
>>         '/users/sign_in'
>>       when /^sign out page$/
>>         '/users/sign_out'
>>     # Add more mappings here.
>>     # Here is an example that pulls values out of the Regexp:
>>     #
>>     #   when /^(.*)'s profile page$/i
>>     #     user_profile_path(User.find_by_login($1))
>>     else
>>       begin
>>         page_name =~ /^the (.*) page$/
>>         path_components = $1.split(/\s+/)
>>         self.send(path_components.push('path').join('_').to_sym)
>>       rescue NoMethodError, ArgumentError
>>         raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
>>           "Now, go and add a mapping in #{__FILE__}"
>>       end
>>     end
>>   end
>> end
>> World(NavigationHelpers)
>> And in my env.rb, i see i am still using webrat (i'd share the whole env.rb, but i have it sporkified, and i
don't want to confuse you further with that (!):  require 'webrat'
>>   Webrat.configure do |config|
>>     config.mode = :rails
>>   end
>>   require 'cucumber/rails'
>>   require 'webrat/core/matchers'
>>   require 'cucumber'                   # I needed to add this... We could move this require to Spork if we think it is better there...
>>   require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
>>   require 'rspec/rails'                # I needed to add this as well to avoid the #records error...
>>   require 'cucumber/rails/rspec'
>>   # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
>>   # order to ease the transition to Capybara we set the default here. If you'd
>>   # prefer to use XPath just remove this line and adjust any selectors in your
>>   # steps to use the XPath syntax.
>>   Capybara.default_selector           = :css
>> Some of my gems:
>> capybara (1.1.2)
>> cucumber (1.1.4)
>> cucumber-rails (1.2.1)
>> gherkin (2.7.3)
>> webrat (0.7.3)
>> My blog has somecucumberstuff as well.jon blog:http://technicaldebt.comtwitter:http://twitter.com/JonKernPA
>> Suzanne said the following on 2/26/12 4:03 PM:Okay I a very confused. I have been following a rails book
that uses webrat and since it is no longer valid, I am getting quite frustrated with the very simple. Given I
am on the home page. I bought the cucumber book, but it doesn't specifically discuss routing. So am I
supposed to be using a paths.rb file? Is there a good example as to what my routes should look like? here is my
error Feature: Signing up In order to be attributed for my work As a user I want to be able to sign up Scenario:
Signing up # features/ signing_up.feature:6 Given I am on the homepage # features/
step_definitions/Signing_up_steps.rb:1 undefined method `path_to' for
#<Cucumber::Rails::World: 0x2f42200> (NoMethodError)
./features/step_definitions/Signing_up_steps.rb:2:in `/^I am on the (.+)$/'
features/signing_up.feature:7:in `Given I am on the homepage' When I follow "Sign up" # features/
step_definitions/Signing_up_steps.rb:5 And I fill in "Email"
with"coutsuza@..."# features/
step_definitions/Signing_up_steps.rb:9 And I fill in "Password" with "password". # features/
step_definitions/Signing_up_steps.rb:13 And I fill in "Password confirmation" with "password" #
features/ step_definitions/Signing_up_steps.rb:9 And I press "Sign up" # features/
step_definitions/Signing_up_steps.rb:17 Then I should see "You have signed up successfully." #
features/ step_definitions/Signing_up_steps.rb:21 This is what I have in my steps. Given /^I am on the
(.+)$/ do |page_name| visit path_to(page_name) end in my routes I have root :to => "home#index" formally
I had used "home/index" instead of page_name, but that didn't work There is so much contradictory
information I am getting quite frustrated. I had thought the cucumber book would set it straight, but alas
it has not. HELP
>
> --
> You received this message because you are subscribed to the Google Groups "Cukes" group.
> To post to this group, send email to cukes@...
> To unsubscribe from this group, send email to cukes+unsubscribe <at> googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cukes?hl=en.
>

--

-- 
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cukes@...
To unsubscribe from this group, send email to cukes+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.

Suzanne Coutchie | 27 Feb 00:56 2012
Picon

Re: [Cucumber:10563] Re: paths.rb file

I will take a look

On Feb 26, 2012 6:47 PM, "Aslak Hellesøy" <aslak.hellesoy <at> gmail.com> wrote:

On Feb 26, 2012, at 22:50, Suzanne <coutsuza-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> okay so I thought webrat was out.....

Capybara. The book has a full chapter on it. Have you read that chapter?


> and also are you saying that a path.rb file is
> required.

Boilerplate code like paths.rb is no longer recommended:
http://aslakhellesoy.com/post/11055981222/the-training-wheels-came-off

Aslak


> it is not discussed in the cucumber book?
>
> On Feb 26, 5:28 pm, Jon Kern <jonker...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>...

--
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to cukes+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.
Jon Kern | 27 Feb 00:49 2012
Picon

Re: [Cucumber:10561] Re: paths.rb file

well, capybara (i guess an even larger rodent and better sounding than 
"Wharfrat") is a popular choice...

and if you want an easier time of writing cukes that march around your 
UI (u can write complete smoke tests in no time), I find paths.rb a 
must-have -- at least for starters, you should stick with something 
simple that works.

jon

blog: http://technicaldebt.com
twitter: http://twitter.com/JonKernPA

Suzanne said the following on 2/26/12 5:50 PM:
> okay so I thought webrat was out.......that is the beginning of my
> confusion....
>
> so if not webrat what?  and also are you saying that a path.rb file is
> required.  it is not discussed in the cucumber book?
>
> On Feb 26, 5:28 pm, Jon Kern<jonker...@...>  wrote:
>> In a rails3 app, i see my paths.rb looks like this:module NavigationHelpers
>>    # Maps a name to a path. Used by the
>>    #
>>    #   When /^I go to (.+)$/ do |page_name|
>>    #
>>    # step definition in web_steps.rb
>>    #
>>    def path_to(page_name)
>>      case page_name
>>      when /^the home\s?page$/
>>        '/'
>>        when /^sign in page$/
>>          '/users/sign_in'
>>        when /^sign out page$/
>>          '/users/sign_out'
>>      # Add more mappings here.
>>      # Here is an example that pulls values out of the Regexp:
>>      #
>>      #   when /^(.*)'s profile page$/i
>>      #     user_profile_path(User.find_by_login($1))
>>      else
>>        begin
>>          page_name =~ /^the (.*) page$/
>>          path_components = $1.split(/\s+/)
>>          self.send(path_components.push('path').join('_').to_sym)
>>        rescue NoMethodError, ArgumentError
>>          raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
>>            "Now, go and add a mapping in #{__FILE__}"
>>        end
>>      end
>>    end
>> end
>> World(NavigationHelpers)
>> And in my env.rb, i see i am still using webrat (i'd share the whole env.rb, but i have it sporkified, and i
don't want to confuse you further with that (!):  require 'webrat'
>>    Webrat.configure do |config|
>>      config.mode = :rails
>>    end
>>    require 'cucumber/rails'
>>    require 'webrat/core/matchers'
>>    require 'cucumber'                   # I needed to add this... We could move this require to Spork if we think it is better there...
>>    require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
>>    require 'rspec/rails'                # I needed to add this as well to avoid the #records error...
>>    require 'cucumber/rails/rspec'
>>    # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
>>    # order to ease the transition to Capybara we set the default here. If you'd
>>    # prefer to use XPath just remove this line and adjust any selectors in your
>>    # steps to use the XPath syntax.
>>    Capybara.default_selector           = :css
>> Some of my gems:
>> capybara (1.1.2)
>> cucumber (1.1.4)
>> cucumber-rails (1.2.1)
>> gherkin (2.7.3)
>> webrat (0.7.3)
>> My blog has somecucumberstuff as well.jon blog:http://technicaldebt.comtwitter:http://twitter.com/JonKernPA
>> Suzanne said the following on 2/26/12 4:03 PM:Okay I a very confused. I have been following a rails book
that uses webrat and since it is no longer valid, I am getting quite frustrated with the very simple. Given I
am on the home page. I bought the cucumber book, but it doesn't specifically discuss routing. So am I
supposed to be using a paths.rb file? Is there a good example as to what my routes should look like? here is my
error Feature: Signing up In order to be attributed for my work As a user I want to be able to sign up Scenario:
Signing up # features/ signing_up.feature:6 Given I am on the homepage # features/
step_definitions/Signing_up_steps.rb:1 undefined method `path_to' for
#<Cucumber::Rails::World: 0x2f42200>  (NoMethodError)
./features/step_definitions/Signing_up_steps.rb:2:in `/^I am on the (.+)$/'
features/signing_up.feature:7:in `Given I am on the homepage' When I follow "Sign up" # features/
step_definitions/Signing_up_steps.rb:5 And I fill in "Email"
with"coutsuza@..."# features/
step_definitions/Signing_up_steps.rb:9 And I fill in "Password" with "password". # features/
step_definitions/Signing_up_steps.rb:13 And I fill in "Password confirmation" with "password" #
features/ step_definitions/Signing_up_steps.rb:9 And I press "Sign up" # features/
step_definitions/Signing_up_steps.rb:17 Then I should see "You have signed up successfully." #
features/ step_definitions/Signing_up_steps.rb:21 This is what I have in my steps. Given /^I am on the
(.+)$/ do |page_name| visit path_to(page_name) end in my routes I have root :to =>  "home#index" formally
I had used "home/index" instead of page_name, but that didn't work There is so much contradictory
information I am getting quite frustrated. I had thought the cucumber book would set it straight, but alas
it has not. HELP

--

-- 
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cukes@...
To unsubscribe from this group, send email to cukes+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.

Jon Kern | 27 Feb 00:52 2012
Picon

Re: [Cucumber:10562] Re: paths.rb file

this might help:
http://net.tutsplus.com/tutorials/ruby/ruby-for-newbies-testing-web-apps-with-capybara-and-cucumber/

jon

blog: http://technicaldebt.com
twitter: http://twitter.com/JonKernPA

Suzanne said the following on 2/26/12 5:50 PM:
> okay so I thought webrat was out.......that is the beginning of my
> confusion....
>
> so if not webrat what?  and also are you saying that a path.rb file is
> required.  it is not discussed in the cucumber book?
>
> On Feb 26, 5:28 pm, Jon Kern<jonker...@...>  wrote:
>> In a rails3 app, i see my paths.rb looks like this:module NavigationHelpers
>>    # Maps a name to a path. Used by the
>>    #
>>    #   When /^I go to (.+)$/ do |page_name|
>>    #
>>    # step definition in web_steps.rb
>>    #
>>    def path_to(page_name)
>>      case page_name
>>      when /^the home\s?page$/
>>        '/'
>>        when /^sign in page$/
>>          '/users/sign_in'
>>        when /^sign out page$/
>>          '/users/sign_out'
>>      # Add more mappings here.
>>      # Here is an example that pulls values out of the Regexp:
>>      #
>>      #   when /^(.*)'s profile page$/i
>>      #     user_profile_path(User.find_by_login($1))
>>      else
>>        begin
>>          page_name =~ /^the (.*) page$/
>>          path_components = $1.split(/\s+/)
>>          self.send(path_components.push('path').join('_').to_sym)
>>        rescue NoMethodError, ArgumentError
>>          raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
>>            "Now, go and add a mapping in #{__FILE__}"
>>        end
>>      end
>>    end
>> end
>> World(NavigationHelpers)
>> And in my env.rb, i see i am still using webrat (i'd share the whole env.rb, but i have it sporkified, and i
don't want to confuse you further with that (!):  require 'webrat'
>>    Webrat.configure do |config|
>>      config.mode = :rails
>>    end
>>    require 'cucumber/rails'
>>    require 'webrat/core/matchers'
>>    require 'cucumber'                   # I needed to add this... We could move this require to Spork if we think it is better there...
>>    require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
>>    require 'rspec/rails'                # I needed to add this as well to avoid the #records error...
>>    require 'cucumber/rails/rspec'
>>    # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
>>    # order to ease the transition to Capybara we set the default here. If you'd
>>    # prefer to use XPath just remove this line and adjust any selectors in your
>>    # steps to use the XPath syntax.
>>    Capybara.default_selector           = :css
>> Some of my gems:
>> capybara (1.1.2)
>> cucumber (1.1.4)
>> cucumber-rails (1.2.1)
>> gherkin (2.7.3)
>> webrat (0.7.3)
>> My blog has somecucumberstuff as well.jon blog:http://technicaldebt.comtwitter:http://twitter.com/JonKernPA
>> Suzanne said the following on 2/26/12 4:03 PM:Okay I a very confused. I have been following a rails book
that uses webrat and since it is no longer valid, I am getting quite frustrated with the very simple. Given I
am on the home page. I bought the cucumber book, but it doesn't specifically discuss routing. So am I
supposed to be using a paths.rb file? Is there a good example as to what my routes should look like? here is my
error Feature: Signing up In order to be attributed for my work As a user I want to be able to sign up Scenario:
Signing up # features/ signing_up.feature:6 Given I am on the homepage # features/
step_definitions/Signing_up_steps.rb:1 undefined method `path_to' for
#<Cucumber::Rails::World: 0x2f42200>  (NoMethodError)
./features/step_definitions/Signing_up_steps.rb:2:in `/^I am on the (.+)$/'
features/signing_up.feature:7:in `Given I am on the homepage' When I follow "Sign up" # features/
step_definitions/Signing_up_steps.rb:5 And I fill in "Email"
with"coutsuza@..."# features/
step_definitions/Signing_up_steps.rb:9 And I fill in "Password" with "password". # features/
step_definitions/Signing_up_steps.rb:13 And I fill in "Password confirmation" with "password" #
features/ step_definitions/Signing_up_steps.rb:9 And I press "Sign up" # features/
step_definitions/Signing_up_steps.rb:17 Then I should see "You have signed up successfully." #
features/ step_definitions/Signing_up_steps.rb:21 This is what I have in my steps. Given /^I am on the
(.+)$/ do |page_name| visit path_to(page_name) end in my routes I have root :to =>  "home#index" formally
I had used "home/index" instead of page_name, but that didn't work There is so much contradictory
information I am getting quite frustrated. I had thought the cucumber book would set it straight, but alas
it has not. HELP

--

-- 
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cukes@...
To unsubscribe from this group, send email to cukes+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.

Jon Kern | 27 Feb 01:24 2012
Picon

Re: [Cucumber:10564] paths.rb file

Not to further confuse you Suzanne, but the code i pasted below for env.rb does NOT need any of the webrat stuff. The paths.rb is also not needed. My mistake (probably a cut-n-paste error on my part grabbing stuff from an older env.rb file -- haste makes waste). I realized after reading Aslak's excellent training wheels are off post, that my steps are like what he describes. That got me to thinking... so I commented out the webrat and paths stuff and the darn features still passed.
  ...
  #require 'webrat'
  #
  #Webrat.configure do |config|
  #  config.mode = :rails
  #end

  require 'cucumber/rails'

  #require 'webrat/core/matchers'
  ...

Go figure <g>. By way of example:

The Feature:
#  <at> wip
  Scenario: EMS Admin UI smoke test
    Given I login in as an "ems_admin" role
    Then I should see "Sign Out"
    Then I should see "EMS Care Records"
    Then I should not see "Admin"
    Then I should not see "Patients"
    Then I should not see "Practice"

The Steps:
When /^I login in as an "([^"]*)" role$/ do |role|
  visit('/users/sign_in')
  user = Factory.create(:user, :login => "#{role}_user")
  user.add_role role.to_sym
  user.confirmed_at = Time.now
  user.save!

  fill_in("user_login", :with => user[:login])
  fill_in("user_password", :with => "password")
  click_button "Sign In"
end

Keep after it, Suzanne... I find Cucumber to be an awesome tool, wouldn't develop without it (though obviously you can). imho, it is the first "closed loop" way that I have seen to go from business requirement all the way through to the code. (And I love using the tabular feature for even doing non-business stuff, because it is often a great way to express requirements, even if they are at a lower level class API that is typically handled by RSpec.)

if you have more questions, ask away!
jon blog: http://technicaldebt.com twitter: http://twitter.com/JonKernPA
Jon Kern said the following on 2/26/12 5:28 PM:
In a rails3 app, i see my paths.rb looks like this:

module NavigationHelpers
  # Maps a name to a path. Used by the
  #
  #   When /^I go to (.+)$/ do |page_name|
  #
  # step definition in web_steps.rb
  #
  def path_to(page_name)
    case page_name

    when /^the home\s?page$/
      '/'

      when /^sign in page$/
        '/users/sign_in'
      when /^sign out page$/
        '/users/sign_out'
    # Add more mappings here.
    # Here is an example that pulls values out of the Regexp:
    #
    #   when /^(.*)'s profile page$/i
    #     user_profile_path(User.find_by_login($1))

    else
      begin
        page_name =~ /^the (.*) page$/
        path_components = $1.split(/\s+/)
        self.send(path_components.push('path').join('_').to_sym)
      rescue NoMethodError, ArgumentError
        raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
          "Now, go and add a mapping in #{__FILE__}"
      end
    end
  end
end

World(NavigationHelpers)

And in my env.rb, i see i am still using webrat (i'd share the whole env.rb, but i have it sporkified, and i don't want to confuse you further with that (!):

  require 'webrat'

  Webrat.configure do |config|
    config.mode = :rails
  end

  require 'cucumber/rails'

  require 'webrat/core/matchers'
  require 'cucumber'                   # I needed to add this... We could move this require to Spork if we think it is better there...
  require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
  require 'rspec/rails'                # I needed to add this as well to avoid the #records error...
  require 'cucumber/rails/rspec'

  # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
  # order to ease the transition to Capybara we set the default here. If you'd
  # prefer to use XPath just remove this line and adjust any selectors in your
  # steps to use the XPath syntax.
  Capybara.default_selector           = :css

Some of my gems:
capybara (1.1.2)
cucumber (1.1.4)
cucumber-rails (1.2.1)
gherkin (2.7.3)
webrat (0.7.3)

My blog has some cucumber stuff as well.
jon blog: http://technicaldebt.com twitter: http://twitter.com/JonKernPA
Suzanne said the following on 2/26/12 4:03 PM:
Okay I a very confused. I have been following a rails book that uses webrat and since it is no longer valid, I am getting quite frustrated with the very simple. Given I am on the home page. I bought the cucumber book, but it doesn't specifically discuss routing. So am I supposed to be using a paths.rb file? Is there a good example as to what my routes should look like? here is my error Feature: Signing up In order to be attributed for my work As a user I want to be able to sign up Scenario: Signing up # features/ signing_up.feature:6 Given I am on the homepage # features/ step_definitions/Signing_up_steps.rb:1 undefined method `path_to' for #<Cucumber::Rails::World: 0x2f42200> (NoMethodError) ./features/step_definitions/Signing_up_steps.rb:2:in `/^I am on the (.+)$/' features/signing_up.feature:7:in `Given I am on the homepage' When I follow "Sign up" # features/ step_definitions/Signing_up_steps.rb:5 And I fill in "Email" with "coutsuza-2/1dyl5XNkz7FfK2uYURpw@public.gmane.org" # features/ step_definitions/Signing_up_steps.rb:9 And I fill in "Password" with "password". # features/ step_definitions/Signing_up_steps.rb:13 And I fill in "Password confirmation" with "password" # features/ step_definitions/Signing_up_steps.rb:9 And I press "Sign up" # features/ step_definitions/Signing_up_steps.rb:17 Then I should see "You have signed up successfully." # features/ step_definitions/Signing_up_steps.rb:21 This is what I have in my steps. Given /^I am on the (.+)$/ do |page_name| visit path_to(page_name) end in my routes I have root :to => "home#index" formally I had used "home/index" instead of page_name, but that didn't work There is so much contradictory information I am getting quite frustrated. I had thought the cucumber book would set it straight, but alas it has not. HELP

--
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.

Suzanne Coutchie | 27 Feb 16:24 2012
Picon

Re: [Cucumber:10575] paths.rb file

Thanks.  So what does the routes file look like?

On Feb 26, 2012 7:24 PM, "Jon Kern" <jonkernpa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

Not to further confuse you Suzanne, but the code i pasted below for env.rb does NOT need any of the webrat stuff. The paths.rb is also not needed. My mistake (probably a cut-n-paste error on my part grabbing stuff from an older env.rb file -- haste makes waste). I realized after reading Aslak's excellent training wheels are off post, that my steps are like what he describes. That got me to thinking... so I commented out the webrat and paths stuff and the darn features still passed.
  ...
  #require 'webrat'
  #
  #Webrat.configure do |config|
  #  config.mode = :rails
  #end

  require 'cucumber/rails'

  #require 'webrat/core/matchers'
  ...

Go figure <g>. By way of example:

The Feature:
#  <at> wip
  Scenario: EMS Admin UI smoke test
    Given I login in as an "ems_admin" role
    Then I should see "Sign Out"
    Then I should see "EMS Care Records"
    Then I should not see "Admin"
    Then I should not see "Patients"
    Then I should not see "Practice"

The Steps:
When /^I login in as an "([^"]*)" role$/ do |role|
  visit('/users/sign_in')
  user = Factory.create(:user, :login => "#{role}_user")
  user.add_role role.to_sym
  user.confirmed_at = Time.now
  user.save!

  fill_in("user_login", :with => user[:login])
  fill_in("user_password", :with => "password")
  click_button "Sign In"
end

Keep after it, Suzanne... I find Cucumber to be an awesome tool, wouldn't develop without it (though obviously you can). imho, it is the first "closed loop" way that I have seen to go from business requirement all the way through to the code. (And I love using the tabular feature for even doing non-business stuff, because it is often a great way to express requirements, even if they are at a lower level class API that is typically handled by RSpec.)

if you have more questions, ask away!



jon

blog: http://technicaldebt.com
twitter: http://twitter.com/JonKernPA

Jon Kern said the following on 2/26/12 5:28 PM:


>
> In a rails3 app, i see my paths.rb looks like this:
>
> module NavigationHelpers
>   # Maps a n...

--
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post...

--
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to cukes+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.
Andrew Premdas | 27 Feb 10:13 2012
Picon

Re: [Cucumber:10568] paths.rb file

On 26 February 2012 21:03, Suzanne <coutsuza-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Okay I a very confused.  I have been following a rails book that uses
webrat and since it is no longer valid, I am getting quite frustrated
with the very simple.  Given I am on the home page.  I bought the
cucumber book, but it doesn't specifically discuss routing.  So am I
supposed to be using a paths.rb file?  Is there a good example as to
what my routes should look like?

here is my error


Feature: Signing up
 In order to be attributed for my work
 As a user
 I want to be able to sign up

 Scenario: Signing up                                     # features/
signing_up.feature:6
   Given I am on the homepage                             # features/
step_definitions/Signing_up_steps.rb:1
     undefined method `path_to' for #<Cucumber::Rails::World:
0x2f42200> (NoMethodError)
     ./features/step_definitions/Signing_up_steps.rb:2:in `/^I am on
the (.+)$/'
     features/signing_up.feature:7:in `Given I am on the homepage'
   When I follow "Sign up"                                # features/
step_definitions/Signing_up_steps.rb:5
   And I fill in "Email" with "coutsuza-2/1dyl5XNkz7FfK2uYURpw@public.gmane.org" # features/
step_definitions/Signing_up_steps.rb:9
   And I fill in "Password" with "password".              # features/
step_definitions/Signing_up_steps.rb:13
   And I fill in "Password confirmation" with "password"  # features/
step_definitions/Signing_up_steps.rb:9
   And I press "Sign up"                                  # features/
step_definitions/Signing_up_steps.rb:17
   Then I should see "You have signed up successfully."   # features/
step_definitions/Signing_up_steps.rb:21

This is what I have in my steps.


Given /^I am on the (.+)$/ do |page_name|
 visit path_to(page_name)
end

in my routes I have

 root :to => "home#index"

formally I had used "home/index" instead of page_name, but that didn't
work

There is so much contradictory information I am getting quite
frustrated.  I had thought the cucumber book would set it straight,
but alas it has not.

HELP

--
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To unsubscribe from this group, send email to cukes+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.


Suzanne,

For visiting pages in cucumber the simplest approach (IMO) is to visit the route directly using capybara's visit method and the rails route helper. So for your home page  you would write a step

When /^I view the home page$/ do
   visit root_path
end

Note with this step you are

1) not doing anything clever with regular expressions
2) not using any additional files like paths.rb
3) using Capybara directly (this is good as its your main tool for interacting with web pages when using cucumber)
4) using methods from your source code. Again this is good, there is no point in defining what you home page is in both your test code and source code, when you can just use the definition in the source code.

I would strongly recommend following this approach when starting with cucumber, use simple steps, get directly to the ruby as quickly as possible and use Capybara directly - not some intermediary.

If your ruby is OK then having a look at the features in https://github.com/diabolo/r3-mongo-devise might be useful. It does all this login stuff using very simple features. Also the Cucumber Book is highly recommended.

HTH

All best

Andrew


--
------------------------
Andrew Premdas

--
You received this message because you are subscribed to the Google Groups "Cukes" group.
To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to cukes+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cukes?hl=en.

Gmane