所以看起来我已经用过current_path
很多次了request specs
。然而,Capybara 现在需要规格features directory
才能使用Capybara DSL (page & visit)
# creating_posts_spec.rb
require "spec_helper"
feature "creating posts" do
scenario "creating posts with valid info is successful" do
visit new_post_path
fill_in 'Title', with: "This is a title test"
fill_in 'Content', with: "This is a content test"
click_button 'Create Post'
page.should have_content 'Post was successfully created.'
page.current_path.should == post_path(post)
end
end
它是一个简单的帖子控制器,并且在帖子在浏览器中渲染得很好后,页面就会显示出来。
posts GET /posts(.:format) posts#index
POST /posts(.:format) posts#create
new_post GET /posts/new(.:format) posts#new
edit_post GET /posts/:id/edit(.:format) posts#edit
post GET /posts/:id(.:format) posts#show
PUT /posts/:id(.:format) posts#update
DELETE /posts/:id(.:format) posts#destroy
root / posts#index
为什么我收到错误:undefined local variable or method 'post'
?
我只是不记得曾经遇到过这种麻烦。有人有建议或理由吗?还是我错过了一些明显的东西?晚了