Capybara matchers #2

Closed
ream88 opened this Issue Jul 30, 2012 · 6 comments

Comments

Projects
None yet
2 participants
Owner

blowmage commented Jul 30, 2012

I don't think forcing matchers on everyone is a great idea, so if they are added it will likely be an option you will have to enable. That said, here are a couple projects you may be interested in:

The official project to add matchers to Minitest:
https://github.com/zenspider/minitest-matchers

This project adds Capybara's Rspec matchers to Minitest, as well as adds a metadata feature:
https://github.com/wojtekmach/minitest-capybara

I'm on the fence on how much to add or support by default. If you want Capybara matchers in your tests I think the most direct path is to add minitest-capybara to your Gemfile:

group :development, :test do
  gem "minitest-rails"
  gem "minitest-rails-capybara"
  gem "minitest-capybara"
end

And then add the following to your test/minitest_helper.rb file:

class MiniTest::Rails::ActionDispatch::IntegrationTest
  include Capybara::RSpecMatchers
end

ream88 commented Jul 31, 2012

Though I don't like to include 3 gems which seem to do the same, it is a working and solution and I will stick with that. Will close this issue, thx @blowmage!

@ream88 ream88 closed this Jul 31, 2012

@blowmage blowmage reopened this Jul 31, 2012

Owner

blowmage commented Aug 2, 2012

So the more I think about this, the more I think that we should register the matchers if minitest-matchers has been loaded. That mean that all you should have to do is add minitest-matchers to the Gemfile.

group :development, :test do
  gem "minitest-rails"
end

group :test do
  gem "minitest-matchers" # I want Capybara's matchers registered
  gem "minitest-rails-capybara"
end

You could make it explicit by specifically requiring it in your test/minitest_helper.rb file as well.

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

require "minitest/autorun"
require "minitest/rails"

# Uncomment if you want Capybara in accceptance/integration tests
require "minitest/matchers" # Requires gem "minitest-matchers" in Gemfile
require "minitest/rails/capybara"

# Uncomment if you want awesome colorful output
require "minitest/pride"

Thoughts?

@blowmage blowmage closed this in bb50742 Aug 2, 2012

ream88 commented Aug 2, 2012

Wow thank you! minitest-matchers anyways was already in here, so this is a very welcome change!

Owner

blowmage commented Aug 2, 2012

Well now in 0.1 everyone gets minitest-matchers regardless. Thanks for taking the time to open the issue.

ream88 commented Aug 2, 2012

Getting rid of gems in Gemfile always feels so good ;) Thank you very much again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment