您好,我对 Rspec + Capybara 有疑问。我想测试我的 ajax 评论是否可以发布。我的错误是因为没有创建帖子。
Failure/Error: page.should have_content('Could')
当我输出@post 我看到
#<Post id: 1, title: "Deploying through ssh", body: "This is post about ssh", slug: deploying-through-ssh, published: nil, published_at: nil, created_at: "2013-02-05 17:37:39", updated_at: "2013-02-05 17:37:39", user_id: nil, meta_desc: nil>
describe "Sending Comments" do
before(:each) do
@post = FactoryGirl.create(:post)
end
it "should allow user to post new comment", :js => true do
visit post_path(@post)
page.should have_content('Could')
fill_in 'comment[name]', :with => "name"
fill_in 'comment_email', :with => "email@mail.com"
fill_in 'comment_content', :with => "content"
end
end