i am very new to rails, and even newer to BDD. I have attempted to stick to DRY methodology but somethings not right here..
FEATURE
Scenario: Add a new vehicle with valid data
Given I exist as a user
And I am logged in
And I am on the Create New Vehicle page
When I fill out the form with the following attributes:
| vehicle_make | DODGE |
| vehicle_model | RAM 1500 |
| vehicle_year | 2005 |
| vehicle_engine | 5.7L |
| vehicle_color | Black |
And I click the Create Vehicle button
Then I should see Vehicle was successfully created.
STEP DEFINITION
## this is in common_steps.rb
When /^I fill out the form with the following attributes:$/ do |table|
puts table.rows_hash
criteria = table.rows_hash.each do |field, value|
fill_in field.to_sym, :with => value
end
end
When /^I click the (.*?) button$/ do |button|
click_button button
end
TEST RESULTS
## seems that its not filling the form out as im getting
## "cannot be blank" validation errors
Scenario: Add a new vehicle with valid data # features/vehicles/vehicle_new.feature:12
Given I exist as a user # features/step_definitions/user_steps.rb:42
And I am logged in # features/step_definitions/common_steps.rb:18
And I am on the Create New Vehicle page # features/step_definitions/common_steps.rb:22
When I fill out the form with the following attributes: # features/step_definitions/common_steps.rb:33
{"vehicle_make"=>"DODGE", "vehicle_model"=>"RAM 1500", "vehicle_year"=>"2005", "vehicle_engine"=>"5.7L", "vehicle_color"=>"Black"}
| vehicle_make | DODGE |
| vehicle_model | RAM 1500 |
| vehicle_year | 2005 |
| vehicle_engine | 5.7L |
| vehicle_color | Black |
And I click the Create Vehicle button # features/step_definitions/common_steps.rb:39
Then I should see Vehicle was successfully created. # features/step_definitions/common_steps.rb:47
expected there to be content "Vehicle was successfully created." in "GasLoggr | Create New Vehicle\n \n \n Gasloggr\n \n \n \n \n \n Welcome Back Test User\n \n Home\n About\n\n \n \n \n \n Vehicles\n Fillups\n Edit Profile\n Logout\n \n\n \n \n \n \n Create New Vehicle\n \n \n \n \n NAVIGATION\n Vehicles\n Fillups\n Edit Profile\n \n \n \n \n \n\t\n\t\t\n\t\t\t\n \n 4 errors prohibited this vehicle from being saved:\n\n Color can't be blank\n Engine can't be blank\n Model can't be blank\n Year can't be blank\n \n \n Make\n \n \n \n \n Model\n \n \n \n \n \n Year\n \n \n \n \n \n Engine\n \n \n \n \n \n Color\n \n \n \n \n \n Image\n \n \n \n \n Description\n \n \n \n \n Cancel\n \n \n\t\t\n\t\t\n\t\t\tLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\n\t\t\ttempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\n\t\t\tquis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\n\t\t\tconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\n\t\t\tcillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\n\t\t\tproident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n\t\t\n\t\n\n \n " (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/common_steps.rb:48:in `/^I should see (.*?)$/'
features/vehicles/vehicle_new.feature:23:in `Then I should see Vehicle was successfully created.'
From everything i can tell, the step definition isnt filling out the form, but the form values do exist properly according to this line from the results.. {"vehicle_make"=>"DODGE", "vehicle_model"=>"RAM 1500", "vehicle_year"=>"2005", "vehicle_engine"=>"5.7L", "vehicle_color"=>"Black"}