1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00
thoughtbot--shoulda-matchers/lib/shoulda/matchers/integrations/libraries/active_model.rb
Elliot Winkler af98a23091 Mix into corresponding RSpec example groups
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.
2015-09-25 17:45:27 -06:00

26 lines
607 B
Ruby

module Shoulda
module Matchers
module Integrations
module Libraries
# @private
class ActiveModel
Integrations.register_library(self, :active_model)
include Integrations::Inclusion
include Integrations::Rails
def integrate_with(test_framework)
test_framework.include(matchers_module, type: :model)
include_into(ActiveSupport::TestCase, matchers_module)
end
private
def matchers_module
Shoulda::Matchers::ActiveModel
end
end
end
end
end
end