blowmage / minitest-rails-capybara

Capybara integration for MiniTest::Rails
http://blowmage.com/minitest-rails-capybara
MIT License
131 stars 40 forks source link

error running 'rake test' #3

Closed jamezilla closed 12 years ago

jamezilla commented 12 years ago

I'm able to run tests using Guard, but using the test rake task fails:

/Users/james/.rvm/gems/ruby-1.9.2-p290@checkout/gems/minitest-rails-capybara-0.0.2/lib/minitest-rails-capybara.rb:1:in `<top (required)>': uninitialized constant Minitest (NameError)
    from /Users/james/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `require'
    from /Users/james/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/james/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `each'
    from /Users/james/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/james/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `each'
    from /Users/james/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `require'
    from /Users/james/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.1.5/lib/bundler.rb:119:in `require'
    from /Users/james/src/checkout/config/application.rb:7:in `<top (required)>'
    from /Users/james/src/checkout/config/environment.rb:2:in `require'
    from /Users/james/src/checkout/config/environment.rb:2:in `<top (required)>'
    from /Users/james/src/checkout/test/minitest_helper.rb:2:in `require'
    from /Users/james/src/checkout/test/minitest_helper.rb:2:in `<top (required)>'
    from /Users/james/src/checkout/test/unit/business_hour_test.rb:1:in `require'
    from /Users/james/src/checkout/test/unit/business_hour_test.rb:1:in `<top (required)>'
    from /Users/james/.rvm/gems/ruby-1.9.2-p290@checkout/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in `require'
    from /Users/james/.rvm/gems/ruby-1.9.2-p290@checkout/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
    from /Users/james/.rvm/gems/ruby-1.9.2-p290@checkout/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `each'
    from /Users/james/.rvm/gems/ruby-1.9.2-p290@checkout/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `block in <main>'
    from /Users/james/.rvm/gems/ruby-1.9.2-p290@checkout/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `select'
    from /Users/james/.rvm/gems/ruby-1.9.2-p290@checkout/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `<main>'

Adding require 'minitest/rails' to minitest-rails-capybara.rb solved the problem for me, but I don't know if that's necessarily the correct patch.

blowmage commented 12 years ago

Yeah, we shouldn't need that require since its already listed as the gem's dependency. But its a good idea to have it anyway, I'll add it.

What does your minitest_helper.rb file look like?

blowmage commented 12 years ago

Try updating your Gemfile with the following to use the repo instead of the gem and tell me if the latest commits help.

group :development, :test do
  gem "minitest-rails"
  gem "minitest-rails-capybara", git: "git@github.com:blowmage/minitest-rails-capybara.git"
end
jamezilla commented 12 years ago

Using the master repo, so far so good.

Here's what my minitest_helper.rb looks like:


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

require "minitest/autorun"
require "minitest/rails"
require "minitest/rails/capybara"
#require "minitest/pride"

DatabaseCleaner.strategy = :truncation

class MiniTest::Spec
  before :each do
    DatabaseCleaner.clean       # Truncate the database
    Capybara.reset_sessions!    # Forget the (simulated) browser state
    Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver
  end
end

class MiniTest::Rails::ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
  fixtures :all

  # Add more helper methods to be used by all tests here...
end
blowmage commented 12 years ago

Awesome. Just released a new gem. Thanks!