I have installed all of the various bit and pieces for rspec and cucumber and have used: script/generate feature Frooble name color description To create a dummy feature and related steps. Now, while I have been poking at Ruby, Rails, RSpec and Stories for a long time, I have never really grasped much of what I have been exposed to. Therefore, I crave your indulgence for the next little while as I buckle down to master this stuff. My questions over the next little while will likely be novice level. Taking the frooble skeleton I have reworked it to this: #manage_entities.feature Feature: Manage entities In order to keep track of entities A entity maintainer Should be able to manage entities To Protect Revenue Scenario: Register a new entity Given I am on the new entity page When I fill in "entity_name" with "My New Entity" And I fill in "entity_legal_name" with "My New Enitity is a CORP" And I fill in "entity_legal_form" with "CORP" And I press "Create" Then I should see "My New Entity" And I should see "My New Enitity is a CORP" And I should see "CORP" ... And #steps/entity_steps.rb Given /I am on the new entity page/ do visits "/entities/new" end ... When I run # rake features I see this: Feature: Manage entities # features/manage_entities.feature In order to keep track of entities A entity maintainer Should be able to manage multiple entities To Protect Revenue Scenario: Register a new entity # features/manage_entities.feature:7 Given I am on the new entity page # features/steps/entity_steps.rb:1 undefined method `visits'' for #<ActionController::Integration::Session:0xb7202094> (NoMethodError) Now, "visits" is an action predefined in the step file, and one that I presume is connected somehow to webrat (installed), which means to me that I should not have to define it myself. Therefore my questions are: Is there some manual configuration I am required to do to wire this up correctly or am I missing the boat on this altogether? If there are additional set-up steps that I must perform then where to I discover them? Regards, -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3
On Wed, Nov 12, 2008 at 5:17 PM, James B. Byrne <byrnejb at harte-lyne.ca> wrote:> I have installed all of the various bit and pieces for rspec and cucumber > and have used: > > script/generate feature Frooble name color description > > To create a dummy feature and related steps. Now, while I have been > poking at Ruby, Rails, RSpec and Stories for a long time, I have never > really grasped much of what I have been exposed to. Therefore, I crave > your indulgence for the next little while as I buckle down to master this > stuff. My questions over the next little while will likely be novice > level. > > Taking the frooble skeleton I have reworked it to this: > > #manage_entities.feature > > Feature: Manage entities > In order to keep track of entities > A entity maintainer > Should be able to manage entities > To Protect Revenue > > Scenario: Register a new entity > Given I am on the new entity page > When I fill in "entity_name" with "My New Entity" > And I fill in "entity_legal_name" with "My New Enitity is a CORP" > And I fill in "entity_legal_form" with "CORP" > And I press "Create" > Then I should see "My New Entity" > And I should see "My New Enitity is a CORP" > And I should see "CORP" > ... > > And > > #steps/entity_steps.rb > > Given /I am on the new entity page/ do > visits "/entities/new" > end > ... > > When I run # rake features I see this: > > Feature: Manage entities # features/manage_entities.feature > In order to keep track of entities > A entity maintainer > Should be able to manage multiple entities > To Protect Revenue > Scenario: Register a new entity # > features/manage_entities.feature:7 > Given I am on the new entity page # > features/steps/entity_steps.rb:1 > undefined method `visits'' for > #<ActionController::Integration::Session:0xb7202094> (NoMethodError) > > Now, "visits" is an action predefined in the step file, and one that I > presume is connected somehow to webrat (installed), which means to me that > I should not have to define it myself. Therefore my questions are: Is > there some manual configuration I am required to do to wire this up > correctly or am I missing the boat on this altogether? If there are > additional set-up steps that I must perform then where to I discover them? >Do you have vendor/plugins/webrat ? If you have webrat as a gem you must require ''webrat'' in env.rb Maybe the generated env.rb should have: require ''webrat'' if !defined?(Webrat) HTH, Aslak> Regards, > > -- > *** E-Mail is NOT a SECURE channel *** > James B. Byrne mailto:ByrneJB at Harte-Lyne.ca > Harte & Lyne Limited http://www.harte-lyne.ca > 9 Brockley Drive vox: +1 905 561 1241 > Hamilton, Ontario fax: +1 905 561 0757 > Canada L8E 3C3 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On: Wed, 12 Nov 2008 17:35:40 +0100, "aslak hellesoy" <aslak.hellesoy at gmail.com> wrote> > Do you have vendor/plugins/webrat ? > If you have webrat as a gem you must require ''webrat'' in env.rb > > Maybe the generated env.rb should have: > require ''webrat'' if !defined?(Webrat) >Yes. That worked fine. Now I have another question. Please be patient with me. The features test now shows this: $ rake features (in /home/byrnejb/Software/Development/Projects/proforma.git) Feature: Manage entities # features/manage_entities.feature In order to keep track of entities A entity maintainer Should be able to manage multiple entities To Protect Revenue Scenario: Register a new entity # features/manage_entities.feature:7 Given I am on the new entity page # features/steps/entity_steps.rb:1 wrong number of arguments (3 for 1) (ActionView::TemplateError) On line #10 of app/views/entities/new.html.erb 7: <% form_for(@entity) do |f| %> 8: 9: <%= render :partial => ''entities/entity_header'', 10: :object => @entity -%> 11: 12: <p> 13: <%= f.submit "Create" -%> vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb:13:in `render_partial'' vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb:13:in `render_partial'' I am obviously retro-fitting tests on code that I have already written. In this instance I have extracted code common to the new and the edit views into a partial. What is this test error telling me and how do I get my feature/step to accommodate my existing ( and working ) code? # steps/entity_steps.rb Given /I am on the new entity page/ do visits "/entities/new" end Regards, -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3
On Wed, Nov 12, 2008 at 9:27 AM, James B. Byrne <byrnejb at harte-lyne.ca>wrote:> Feature: Manage entities # features/manage_entities.feature >This is just a side note, but is "manage entities" really a feature? It sounds pretty vague. I''m not experienced with cucumber, so I don''t know if that''s typical usage. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081112/ce6c2402/attachment.html>
On Wed, Nov 12, 2008 at 6:46 PM, Mark Wilden <mark at mwilden.com> wrote:> On Wed, Nov 12, 2008 at 9:27 AM, James B. Byrne <byrnejb at harte-lyne.ca> > wrote: > >> >> Feature: Manage entities # features/manage_entities.feature > > This is just a side note, but is "manage entities" really a feature? ItGood catch. It is not - it''s just what the generator generates. Read the disclaimer here: http://github.com/aslakhellesoy/cucumber/wikis/ruby-on-rails (Start a feature) Suggestions about how to generate starter-features that are at the same time valuable features and tie into Rails'' REST are welcome.> sounds pretty vague. I''m not experienced with cucumber, so I don''t know if > that''s typical usage. > > ///ark > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Wed, November 12, 2008 12:27, James B. Byrne wrote:> > The features test now shows this: > > $ rake features...> Scenario: Register a new entity # > features/manage_entities.feature:7 > Given I am on the new entity page # > features/steps/entity_steps.rb:1 > wrong number of arguments (3 for 1) (ActionView::TemplateError) > On line #10 of app/views/entities/new.html.erb > > 7: <% form_for(@entity) do |f| %> > 8: > 9: <%= render :partial => ''entities/entity_header'', > 10: :object => @entity -%> > 11: > 12: <p> > 13: <%= f.submit "Create" -%> > > vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb:13:in > `render_partial'' > vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb:13:in > `render_partial'' >...> > # steps/entity_steps.rb > Given /I am on the new entity page/ do > visits "/entities/new" > endAny hints on what I am doing wrong here? Should I be asking this question on a webrat list? Is there one? I cannot find it. -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3
For what it is worth the contents of the log/test.log file are: $ tail log/test.log Completed in 67ms (View: 7, DB: 2) | 200 OK [http://www.example.com/entities] SQL (0.7ms) SELECT count(*) AS count_all FROM "entities" REQUESTING PAGE: GET /entities/new with {} and HTTP headers {} Processing EntitiesController#new (for 127.0.0.1 at 2008-11-12 15:11:44) [GET] Session ID: 04a1f0098c54dba8a812645fbb015380 Parameters: {"action"=>"new", "controller"=>"entities"} Rendering template within layouts/application Rendering entities/new While, the same page rendered in Firefox using the development environment shows this: REQUESTING PAGE: GET /entities/new with {} and HTTP headers {} Processing EntitiesController#new (for 127.0.0.1 at 2008-11-12 15:11:44) [GET] Session ID: 04a1f0098c54dba8a812645fbb015380 Parameters: {"action"=>"new", "controller"=>"entities"} Rendering template within layouts/application Rendering entities/new [byrnejb at inet02 proforma.git]$ tail log/development.log Rendering template within layouts/application Rendering entities/new Rendered entities/_entity_header (15.2ms) Completed in 98ms (View: 57, DB: 0) | 200 OK [http://localhost/entities/new] SQL (4.3ms) SELECT name FROM sqlite_master WHERE type = ''table'' AND NOT name = ''sqlite_sequence'' SQL (1.1ms) SELECT version FROM schema_migrations SQL (1.7ms) SELECT version FROM schema_migrations I really could use from help from someone who can explain this behaviour. -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3
Thanks to a suggestion from the Ruby on Rails list I checked my vendor plugins directory and discovered that I had not actually removed the older rspec and rspec-rails plugins, just detached them from git. They both are now gone and my tests are running, if not passing. But at least I am past this problem anyway. -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:ByrneJB at Harte-Lyne.ca Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3
A couple of tips may help here. 1) You can debug features by putting ''debugger'' in the step file. Just make sure there is a line after debugger e.g ... debugger response end If there''s nothing after debugger you will stop in the cucumber code, which is not what you want. 2) You can also put debugger statements in your rails files. Perhaps you could do a <%- debugger %> before you render your partial in the form. (You might have to use <%=) HTH Andrew 2008/11/12 James B. Byrne <byrnejb at harte-lyne.ca>:> > For what it is worth the contents of the log/test.log file are: > > $ tail log/test.log > Completed in 67ms (View: 7, DB: 2) | 200 OK [http://www.example.com/entities] > SQL (0.7ms) SELECT count(*) AS count_all FROM "entities" > REQUESTING PAGE: GET /entities/new with {} and HTTP headers {} > > > Processing EntitiesController#new (for 127.0.0.1 at 2008-11-12 15:11:44) > [GET] > Session ID: 04a1f0098c54dba8a812645fbb015380 > Parameters: {"action"=>"new", "controller"=>"entities"} > Rendering template within layouts/application > Rendering entities/new > > While, the same page rendered in Firefox using the development environment > shows this: > > REQUESTING PAGE: GET /entities/new with {} and HTTP headers {} > > > Processing EntitiesController#new (for 127.0.0.1 at 2008-11-12 15:11:44) > [GET] > Session ID: 04a1f0098c54dba8a812645fbb015380 > Parameters: {"action"=>"new", "controller"=>"entities"} > Rendering template within layouts/application > Rendering entities/new > [byrnejb at inet02 proforma.git]$ tail log/development.log > Rendering template within layouts/application > Rendering entities/new > Rendered entities/_entity_header (15.2ms) > Completed in 98ms (View: 57, DB: 0) | 200 OK [http://localhost/entities/new] > SQL (4.3ms) SELECT name > FROM sqlite_master > WHERE type = ''table'' AND NOT name = ''sqlite_sequence'' > > SQL (1.1ms) SELECT version FROM schema_migrations > SQL (1.7ms) SELECT version FROM schema_migrations > > I really could use from help from someone who can explain this behaviour. > > > > > -- > *** E-Mail is NOT a SECURE channel *** > James B. Byrne mailto:ByrneJB at Harte-Lyne.ca > Harte & Lyne Limited http://www.harte-lyne.ca > 9 Brockley Drive vox: +1 905 561 1241 > Hamilton, Ontario fax: +1 905 561 0757 > Canada L8E 3C3 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Wed, Nov 12, 2008 at 10:03 PM, Andrew Premdas <apremdas at gmail.com> wrote:> > 1) You can debug features by putting ''debugger'' in the step file. Just > make sure there is a line after debugger >And require ruby-debug. ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081112/335d0582/attachment.html>