书中的 RubyMIne 水豚示例不起作用 - 语法错误
RubyMIne capybara example from book does not work - syntax error
当运行书中的一个例子"Application testing with Capybara"时,我得到了错误
step_definitions/steps.rb:5: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '('
... :with => search_term click_on 'search-btn'
... ^
我的steps.rb看起来像这样:
Given(/^I am on the YouTube home page$/) do
visit 'http://www.youtube.com'
end
When(/^I search for "(.*?)"$/) do
|search_term| fill_in 'search_query', :with => search_term click_on 'search-btn'
end
Then(/^videos of large rodents are returned$/) do
page.should have_content 'Largest Rodent'
结束
现在我有新问题
根据:
更好的规格.org/#expect
我将 "then line" 更改为...
然后(/^返回大型啮齿动物的视频$/) do
期望(页面).to have_content 'Largest rodents'
我得到了:
Spec::Expectations::ExpectationNotMetError:预计会在“稍后提醒我查看来自 YouTube 的隐私提醒,一家 Google 公司 PL UploadSign 在搜索首页中找到文本 "Largest rodents"
./features/step_definitions/steps.rb:10:in `/^返回大型啮齿动物的视频$/'
./features/youtube_search.feature:5:in `然后返回大型啮齿动物的视频'
fill_in
和 click_on
是两种截然不同的方法。您的代码应如下所示:
When(/^I search for "(.*?)"$/) do |search_term|
fill_in 'search_query', :with => search_term
click_on 'search-btn'
end
谢谢它的帮助,但是..出现了另一个问题:(
./features/step_definitions/steps.rb:10:in /^videos of large rodents are returned$/'
./features/youtube_search.feature:5:in
然后返回大型啮齿动物的视频'
弃用:使用 rspec-expectations 的旧 :should
语法中的 should
而不显式启用
我更改了行:
然后(/^返回大型啮齿动物的视频$/) do
page.should have_content 'Largest rodents'
结束
page.sould page.expect 但没有帮助
我也更改了文本 "Largest rodents" foe another:( 但没有帮助:(
当运行书中的一个例子"Application testing with Capybara"时,我得到了错误
step_definitions/steps.rb:5: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '('
... :with => search_term click_on 'search-btn'
... ^
我的steps.rb看起来像这样:
Given(/^I am on the YouTube home page$/) do
visit 'http://www.youtube.com'
end
When(/^I search for "(.*?)"$/) do
|search_term| fill_in 'search_query', :with => search_term click_on 'search-btn'
end
Then(/^videos of large rodents are returned$/) do
page.should have_content 'Largest Rodent'
结束
现在我有新问题
根据: 更好的规格.org/#expect
我将 "then line" 更改为... 然后(/^返回大型啮齿动物的视频$/) do 期望(页面).to have_content 'Largest rodents'
我得到了: Spec::Expectations::ExpectationNotMetError:预计会在“稍后提醒我查看来自 YouTube 的隐私提醒,一家 Google 公司 PL UploadSign 在搜索首页中找到文本 "Largest rodents" ./features/step_definitions/steps.rb:10:in `/^返回大型啮齿动物的视频$/'
./features/youtube_search.feature:5:in `然后返回大型啮齿动物的视频'
fill_in
和 click_on
是两种截然不同的方法。您的代码应如下所示:
When(/^I search for "(.*?)"$/) do |search_term|
fill_in 'search_query', :with => search_term
click_on 'search-btn'
end
谢谢它的帮助,但是..出现了另一个问题:(
./features/step_definitions/steps.rb:10:in /^videos of large rodents are returned$/'
./features/youtube_search.feature:5:in
然后返回大型啮齿动物的视频'
弃用:使用 rspec-expectations 的旧 :should
语法中的 should
而不显式启用
我更改了行: 然后(/^返回大型啮齿动物的视频$/) do page.should have_content 'Largest rodents' 结束
page.sould page.expect 但没有帮助
我也更改了文本 "Largest rodents" foe another:( 但没有帮助:(