I have problems with Capybara with Rails. Just checking that this is probably an interesting test thing. Well, there are some equivalent tests in the attached code. The first one is done using the toa-context + Test :: Unit command, which comes with Rails. The second test runs with capybara and shoulda-context too.
require 'integration_test_helper' class UsersTest < ActionDispatch::IntegrationTest fixtures :all context "signup" do context "failure" do setup do @attr = { :name => "", :email => "", :password => "", :password_confirmation => "" } end should "not make a new user" do assert_no_difference 'User.count' do post_via_redirect "users", :user =>@attr
While the first one is working fine, capybara gives this error message:
================================================================================ Error: test: signup failure should not make a new user (capybara). (UsersTest): ArgumentError: @request must be an ActionDispatch::Request test/integration/users_test.rb:30:in `block (4 levels) in <class:UsersTest>' test/integration/users_test.rb:23:in `block (3 levels) in <class:UsersTest>' ================================================================================
the required * integration_test_helper.rb * file is the accumulator of all the allowed solutions that I found on Google, and this does not work for me.
require 'test_helper' require 'capybara/rails' require 'database_cleaner'
Does anyone have a solution? Should I try another integration frmawork like webrat?
My setup:
marcel@pua :~/Desenvolupament/Rails3Examples/ror_tutorial$ rake about About your application environment Ruby version 1.9.2 (x86_64-linux) RubyGems version 1.8.15 Rack version 1.3 Rails version 3.1.3 JavaScript Runtime therubyracer (V8) Active Record version 3.1.3 Action Pack version 3.1.3 Active Resource version 3.1.3 Action Mailer version 3.1.3 Active Support version 3.1.3 Middleware ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x00000002b9bac0>, Rack::Runtime, Rack::MethodOverride, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::RemoteIp, Rack::Sendfile, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, ActionDispatch::Head, Rack::ConditionalGet, Rack::ETag, ActionDispatch::BestStandardsSupport Application root /mnt/dropbox/Dropbox/DESENVOLUPAMENT/Rails3Examples/ror_tutorial Environment development Database adapter sqlite3 Database schema version 20120127011330
Besides
shoulda-context (1.0.0) capybara (1.1.2)
thanks