4
我正在尝试使用Capybara编写Rspec请求规范。似乎所有东西都正常工作除了水豚看到页面为空白。为什么Capybara无法看到此页面的内容?
好的迹象:
- 该页面加载在浏览器中
- 尾矿日志精细显示,正确的观点是试运行期间呈现
- 任何记录语句我把意见执行
- 如果我使用
assert_select "h1", :text => "hello world"
,测试通过。
不良苗头:
- 如果我使用
page.should have_content('hello world')
,它失败了,说Capybara::ElementNotFound: Unable to find xpath "/html"
- 如果我做
$stdout.puts page.html
,这是除了一个DOCTYPE
我的测试看起来像空这个:
describe "working with foos" do
it "should have a 'new foo' form" do
get '/foos/new'
assert_select 'h1', text: 'hello world' # passes
page.should have_content('hello world') # fails
$stdout.puts page.html # empty except for a doctype
end
end
这里有什么问题?