【发布时间】:2015-03-11 12:05:36
【问题描述】:
expect(page).to have_content 语法根据capybara docs 是合法的,但它似乎不起作用
我已经添加了spec文件和下面的错误
require 'spec_helper.rb'
feature "Looking up recipes", js: true do
before do
Recipe.create!(name: 'Baked Potato w/ Cheese')
Recipe.create!(name: 'Garlic Mashed Potatoes')
Recipe.create!(name: 'Potatoes Au Gratin')
Recipe.create!(name: 'Baked Brussel Sprouts')
end
scenario "finding recipes" do
visit '/'
fill_in "keywords", with: "baked"
click_on "Search"
expect(page).to have_content("Baked Potato")
expect(page).to have_content("Baked Brussel Sprouts")
end
end
运行规范时出错:
sai@saip:~/rails_apps/receta$ rspec spec/features/search_spec.rb
F
Failures:
1) Looking up recipes finding recipes
Failure/Error: expect(page).to have_content("Baked Potato")
only the `receive` matcher is supported with `expect(...).to`, but you have provided: #<Capybara::RSpecMatchers::HaveText:0x000000057c0470>
# ./spec/features/search_spec.rb:15:in `block (2 levels) in <top (required)>'
Finished in 9.95 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/features/search_spec.rb:10 # Looking up recipes finding recipes
Randomized with seed 31312
这些是各种 rspec gem 的版本
- rspec (2.99.0)
- rspec-collection_matchers (1.1.2)
- rspec-core (2.99.2)
- rspec-expectations (2.99.2)
- rspec 模拟 (2.99.3)
- rspec-rails (2.99.0)
水豚的版本是水豚(2.4.4)
【问题讨论】:
标签: ruby-on-rails rspec