mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
![Elliot Winkler](/assets/img/avatar_default.png)
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.
26 lines
607 B
Ruby
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
|