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:[email protected]
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
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)
On: Wed, 12 Nov 2008 17:35:40 +0100, “aslak hellesoy” [email protected] 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
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:[email protected]
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
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.
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:[email protected]
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@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:[email protected]
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.