I’m creating a multilanguage CMS with Rails, Rspec (for test) and capybara.
the problem appear when i wrote this test
it "redirect and create a new post" do
visit posts_path
create_new_post = I18n.t('posts.index.create_new_post')
click_link create_new_post
current_path.should == new_post_path
end
problem is in last line and i got this
expected: “/posts/new”
got: “/en/posts/new” (using ==)
i want to use something like “new_post_path”, not “/en/posts/new”
the main problem depicted when i use something like this
it "redirect to show link" do
visit posts_path
page.should have_content 'show'
click_link 'show'
current_path.should == post_path(@post)
end
any help is appreciate.
Check this StackOverflow question for some ideas on this subject. My preferred way is this answer on the same question. But, using your current code, to get your expectations right you would perhaps do something like this (assuming you want to test all of your locales):