【发布时间】:2016-11-21 14:13:20
【问题描述】:
我是黄瓜测试的新手,我很困惑为什么这不起作用。如您所见,我正在尝试测试位置的更新详细信息是否在编辑后显示,但我收到以下错误。谁能帮我找出问题所在?
错误 =
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的一些属性。
标签: ruby-on-rails testing cucumber edit