Итак, похоже, что я использовал 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'
?
Я просто не помню, чтобы когда-нибудь сталкивался с этой проблемой. У кого-нибудь есть предложение или причина? или я упускаю что-то очевидное? Уже поздно
page
работает нормально. Это только строкаcurrent_path
. Это странно, если я не упускаю что-то очевидное. - person fontno   schedule 16.05.2013