lundi 21 novembre 2016

Cucumber Test - Can anyone solve my 'edit' Scenario?

I'm new to cucumber testing and I am confused as to why this will not work. As you can see I am trying to test that the updated details of a location are shown after edit but I recieve the below error. Can anyone help me spot what is wrong?

error =

Then I should see the updated location details # features/step_definitions/location_steps.rb:71
  expected to find text "#<Location:0x007fac52ca98f0>" in "/Location/289" (RSpec::Expectations::ExpectationNotMetError)
  ./features/step_definitions/location_steps.rb:73:in `/^I\ should\ see\ the\ updated\ location\ details$/'
  features/location.feature:24:in `Then I should see the updated location details'

feature.rb =

Scenario: editing a location
 Given There is a location
 And I am on the location details page
 When I click on edit
 Then I should see edit location form
 When I edit location details
 And I click submit changes
 Then I should see the updated location details

steps.rb =

Given "There is a location" do
  @location = create(:location)
end

And "I am on the locations page" do
  visit locations_path
end

When "I click on edit" do
  click_link "edit"
end

Then "I should see edit location form" do
  visit edit_location_path(@location)
end

When "I edit location details" do
   @edited_location = build(:location)
end

 And "I click submit changes" do
   click_on "Submit Changes"
 end

 Then "I should see the updated location details" do
   visit location_path(@location)
   expect(location_path(@location)).to have_content(@edited_location)
 end

Aucun commentaire:

Enregistrer un commentaire