samedi 22 mars 2014

Asserting current_path with Capybara and Test::Unit


Vote count:

0




I'm switching from Rspec back to Test::Unit and I want to assert the current path after clicking on a link:


The following fails:



test "browse to about page" do
visit '/'
within(".top-bar") do
click_link 'About'
end
assert current_path == '/about'
end


The failure message is:



Failure:
...
Failed assertion, no message give.


It still fails if I change the assertion to:



assert current_path == about_path


I've got the following in test_helper.rb:



ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

class ActiveSupport::TestCase

fixtures :all

class ActionDispatch::IntegrationTest
require 'capybara/rails'
include Capybara::DSL
end
end


Is the placing of require 'capybara/rails' right? Should it be where it is? Or do I need to put it elsewhere?



asked 33 secs ago

marflar

11.8k





Aucun commentaire:

Enregistrer un commentaire