1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00
Commit graph

8 commits

Author SHA1 Message Date
Elliot Winkler
12543ede2e Use same assertion class as Rails, if loaded
Given this scenario:

* Using Rails 4.1
* Gemfile has `gem 'shoulda-matchers', require: false`
* spec_helper has `require 'shoulda/matchers'` following
  `require 'rspec/rails'`
* Using Spring to run tests

matchers that delegate to assertions in Rails (e.g. `render_template`
and `route`) will fail in the wrong way if used. They fail because in
order to use these assertions, we expect that the assertions will
raise a specific exception, an exception that corresponds to whichever
test framework that Rails is using. For Rails versions that used
Test::Unit, this is Test::Unit::AssertionFailedError. For current Rails
versions, which now use Minitest, this exception is Minitest::Assertion.

The problem is that instead of asking Rails which exception class it's
using, we are trying to detect this exception class ourselves (for
cases in which Rails is not being used). This leads to the wrong class
being detected: when using a Rails version that uses Minitest, we choose
Test::Unit::AssertionFailedError as the class. This happens using the
exact scenario above because even though shoulda-matchers is loaded
after rspec-rails, rspec-rails itself defines
Test::Unit::AssertionFailedError.

Also add Cucumber tests that confirms this exact scenario works.
2014-06-27 14:06:47 -06:00
Elliot Winkler
c22d7c89e0 Extract examples in README to inline documentation 2014-06-20 16:41:27 -06:00
Mauro George
714cf87d78 Add support to rails 4.1.0 2014-04-08 17:41:31 -03:00
Oleg Sukhodolsky
68ae50045e #88: Do not force minitest loading when test-unit is available (restoring original fix) 2013-01-03 13:58:22 -05:00
Gabe Berke-Williams
af8f9a7bff Use current thoughtbot style in specs 2012-12-26 22:45:54 -05:00
Mike Burns
27b8b781a5 Fix the build on Ruby 1.8 using Test::Unit 2012-07-10 14:27:02 +02:00
J. Pablo Fernández
c75c833491 Do not force loading minitest when test-unit is available. Closes #88.
Credit goes to Matt Conway (@wr0ngway https://github.com/wr0ngway)
2012-06-15 11:39:17 +01:00
Timothy Yen
404d1f4ee8 Added shoulda/matchers/assertion_error that assigns based on the current Ruby version. 2011-02-17 13:37:30 -05:00