0
我是新來黃瓜測試,我很困惑,爲什麼這將無法正常工作。正如你所看到的,我試圖在編輯後顯示位置的更新細節,但我收到下面的錯誤。任何人都可以幫助我發現什麼是錯的?黃瓜測試 - 任何人都可以解決我的'編輯'情景?
錯誤=
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
什麼是「@ edited_location」?看起來你正在傳遞一個'Location'對象而不是'String'。我猜你想要傳遞'@ edited_location'的某些屬性。 –