Skip to content

Commit

Permalink
Mix into corresponding RSpec example groups
Browse files Browse the repository at this point in the history
Why:

* Currently, our matchers are mixed into every example group under
  RSpec.
* This creates a problem because some gems, such as
  active_model_serializers-matchers, provide matchers that are named
  the same as the ones that we provide.

To satisfy the above:

* Only mix matchers that correspond to a particular Rails module into
  the appropriate example group for that module. In detail:
    * Mix ActiveModel and ActiveRecord matchers into model example
      groups.
    * Mix ActionController matchers into controller example groups.
  • Loading branch information
mcmire committed Sep 25, 2015
1 parent 3c2fe12 commit af98a23
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 11 deletions.
Expand Up @@ -10,7 +10,7 @@ class ActionController
include Integrations::Rails

def integrate_with(test_framework)
test_framework.include(matchers_module)
test_framework.include(matchers_module, type: :controller)

include_into(::ActionController::TestCase, matchers_module) do
def subject
Expand Down
Expand Up @@ -10,7 +10,7 @@ class ActiveModel
include Integrations::Rails

def integrate_with(test_framework)
test_framework.include(matchers_module)
test_framework.include(matchers_module, type: :model)
include_into(ActiveSupport::TestCase, matchers_module)
end

Expand Down
Expand Up @@ -10,7 +10,7 @@ class ActiveRecord
include Integrations::Rails

def integrate_with(test_framework)
test_framework.include(matchers_module)
test_framework.include(matchers_module, type: :model)
include_into(ActiveSupport::TestCase, matchers_module)
end

Expand Down
Expand Up @@ -9,7 +9,7 @@ class ActiveSupportTestCase
def validate!
end

def include(*modules)
def include(*modules, **options)
test_case_class.include(*modules)
end

Expand Down
Expand Up @@ -9,7 +9,7 @@ class Minitest4
def validate!
end

def include(*modules)
def include(*modules, **options)
test_case_class.class_eval do
include(*modules)
extend(*modules)
Expand Down
Expand Up @@ -10,7 +10,7 @@ class Minitest5
def validate!
end

def include(*modules)
def include(*modules, **options)
test_case_class.class_eval do
include(*modules)
extend(*modules)
Expand Down
Expand Up @@ -23,7 +23,7 @@ def validate!
EOT
end

def include(*modules)
def include(*modules, **options)
end

def n_unit?
Expand Down
4 changes: 2 additions & 2 deletions lib/shoulda/matchers/integrations/test_frameworks/rspec.rb
Expand Up @@ -9,9 +9,9 @@ class Rspec
def validate!
end

def include(*modules)
def include(*modules, **options)
::RSpec.configure do |config|
config.include(*modules)
config.include(*modules, **options)
end
end

Expand Down
Expand Up @@ -9,7 +9,7 @@ class TestUnit
def validate!
end

def include(*modules)
def include(*modules, **options)
test_case_class.class_eval do
include(*modules)
extend(*modules)
Expand Down
@@ -1,6 +1,6 @@
require 'unit_spec_helper'

describe Shoulda::Matchers::ActiveModel do
describe Shoulda::Matchers::ActiveModel, type: :model do
describe '#allow_values' do
it 'is aliased to #allow_value' do
expect(method(:allow_values)).to eq(method(:allow_value))
Expand Down

0 comments on commit af98a23

Please sign in to comment.