shoulda-matchers 2.8.0 → 3.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.hound_config/ruby.yml +7 -0
- data/.travis.yml +11 -54
- data/Appraisals +45 -100
- data/CONTRIBUTING.md +51 -7
- data/Gemfile +7 -19
- data/Gemfile.lock +60 -134
- data/Guardfile +5 -0
- data/NEWS.md +203 -0
- data/README.md +95 -50
- data/Rakefile +1 -0
- data/doc_config/yard/templates/default/layout/html/setup.rb +1 -1
- data/gemfiles/4.0.0.gemfile +10 -7
- data/gemfiles/4.0.0.gemfile.lock +103 -79
- data/gemfiles/4.0.1.gemfile +10 -7
- data/gemfiles/4.0.1.gemfile.lock +109 -83
- data/gemfiles/4.1.gemfile +10 -7
- data/gemfiles/4.1.gemfile.lock +109 -85
- data/gemfiles/4.2.gemfile +10 -9
- data/gemfiles/4.2.gemfile.lock +86 -78
- data/lib/shoulda/matchers.rb +13 -18
- data/lib/shoulda/matchers/action_controller.rb +4 -1
- data/lib/shoulda/matchers/action_controller/flash_store.rb +95 -0
- data/lib/shoulda/matchers/action_controller/{strong_parameters_matcher.rb → permit_matcher.rb} +147 -30
- data/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +1 -1
- data/lib/shoulda/matchers/action_controller/render_template_matcher.rb +1 -1
- data/lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb +1 -1
- data/lib/shoulda/matchers/action_controller/rescue_from_matcher.rb +1 -1
- data/lib/shoulda/matchers/action_controller/route_matcher.rb +5 -1
- data/lib/shoulda/matchers/action_controller/route_params.rb +15 -6
- data/lib/shoulda/matchers/action_controller/session_store.rb +34 -0
- data/lib/shoulda/matchers/action_controller/set_flash_matcher.rb +30 -136
- data/lib/shoulda/matchers/action_controller/set_session_matcher.rb +28 -109
- data/lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb +103 -0
- data/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb +1 -12
- data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +79 -10
- data/lib/shoulda/matchers/active_model/numericality_matchers/numeric_type_matcher.rb +10 -0
- data/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +21 -0
- data/lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb +24 -0
- data/lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb +22 -5
- data/lib/shoulda/matchers/active_model/validate_exclusion_of_matcher.rb +29 -10
- data/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +27 -10
- data/lib/shoulda/matchers/active_model/validate_length_of_matcher.rb +27 -12
- data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +56 -20
- data/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +3 -11
- data/lib/shoulda/matchers/active_model/validation_message_finder.rb +65 -0
- data/lib/shoulda/matchers/active_record/association_matcher.rb +40 -6
- data/lib/shoulda/matchers/active_record/association_matchers/join_table_matcher.rb +21 -7
- data/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +11 -40
- data/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +1 -1
- data/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb +2 -6
- data/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +137 -22
- data/lib/shoulda/matchers/configuration.rb +20 -0
- data/lib/shoulda/matchers/doublespeak.rb +11 -1
- data/lib/shoulda/matchers/doublespeak/double.rb +29 -11
- data/lib/shoulda/matchers/doublespeak/double_collection.rb +4 -3
- data/lib/shoulda/matchers/doublespeak/method_call.rb +35 -0
- data/lib/shoulda/matchers/doublespeak/object_double.rb +7 -2
- data/lib/shoulda/matchers/doublespeak/proxy_implementation.rb +4 -3
- data/lib/shoulda/matchers/doublespeak/stub_implementation.rb +3 -3
- data/lib/shoulda/matchers/doublespeak/world.rb +21 -1
- data/lib/shoulda/matchers/integrations.rb +43 -0
- data/lib/shoulda/matchers/integrations/configuration.rb +68 -0
- data/lib/shoulda/matchers/integrations/configuration_error.rb +9 -0
- data/lib/shoulda/matchers/integrations/inclusion.rb +20 -0
- data/lib/shoulda/matchers/integrations/libraries.rb +15 -0
- data/lib/shoulda/matchers/integrations/libraries/action_controller.rb +31 -0
- data/lib/shoulda/matchers/integrations/libraries/active_model.rb +26 -0
- data/lib/shoulda/matchers/integrations/libraries/active_record.rb +26 -0
- data/lib/shoulda/matchers/integrations/libraries/missing_library.rb +19 -0
- data/lib/shoulda/matchers/integrations/libraries/rails.rb +30 -0
- data/lib/shoulda/matchers/integrations/rails.rb +12 -0
- data/lib/shoulda/matchers/integrations/registry.rb +28 -0
- data/lib/shoulda/matchers/integrations/test_frameworks.rb +16 -0
- data/lib/shoulda/matchers/integrations/test_frameworks/active_support_test_case.rb +37 -0
- data/lib/shoulda/matchers/integrations/test_frameworks/minitest_4.rb +36 -0
- data/lib/shoulda/matchers/integrations/test_frameworks/minitest_5.rb +37 -0
- data/lib/shoulda/matchers/integrations/test_frameworks/missing_test_framework.rb +40 -0
- data/lib/shoulda/matchers/integrations/test_frameworks/rspec.rb +29 -0
- data/lib/shoulda/matchers/integrations/test_frameworks/test_unit.rb +36 -0
- data/lib/shoulda/matchers/rails_shim.rb +0 -40
- data/lib/shoulda/matchers/version.rb +1 -1
- data/script/SUPPORTED_VERSIONS +1 -1
- data/script/update_gems_in_all_appraisals +14 -0
- data/shoulda-matchers.gemspec +2 -2
- data/spec/acceptance/active_model_integration_spec.rb +4 -1
- data/spec/acceptance/independent_matchers_spec.rb +6 -6
- data/spec/acceptance/multiple_libraries_integration_spec.rb +52 -0
- data/spec/acceptance/rails_integration_spec.rb +15 -5
- data/spec/acceptance_spec_helper.rb +8 -0
- data/spec/doublespeak_spec_helper.rb +14 -0
- data/spec/support/acceptance/adds_shoulda_matchers_to_project.rb +110 -0
- data/spec/support/acceptance/helpers.rb +2 -0
- data/spec/support/acceptance/helpers/base_helpers.rb +6 -1
- data/spec/support/acceptance/helpers/command_helpers.rb +6 -2
- data/spec/support/acceptance/helpers/minitest_helpers.rb +0 -8
- data/spec/support/acceptance/helpers/n_unit_helpers.rb +25 -0
- data/spec/support/acceptance/helpers/rspec_helpers.rb +2 -0
- data/spec/support/acceptance/helpers/step_helpers.rb +13 -19
- data/spec/support/acceptance/matchers/have_output.rb +1 -1
- data/spec/support/tests/bundle.rb +1 -1
- data/spec/support/tests/command_runner.rb +25 -13
- data/spec/support/tests/current_bundle.rb +47 -0
- data/spec/support/tests/database.rb +28 -0
- data/spec/support/tests/database_adapters/postgresql.rb +25 -0
- data/spec/support/tests/database_adapters/sqlite3.rb +26 -0
- data/spec/support/tests/database_configuration.rb +33 -0
- data/spec/support/tests/database_configuration_registry.rb +28 -0
- data/spec/support/tests/filesystem.rb +25 -2
- data/spec/support/unit/helpers/active_record_versions.rb +12 -0
- data/spec/support/unit/helpers/class_builder.rb +6 -2
- data/spec/support/unit/helpers/column_type_helpers.rb +26 -0
- data/spec/support/unit/helpers/controller_builder.rb +0 -28
- data/spec/support/unit/helpers/database_helpers.rb +18 -0
- data/spec/support/unit/helpers/model_builder.rb +38 -6
- data/spec/support/unit/helpers/rails_versions.rb +2 -2
- data/spec/support/unit/matchers/fail_with_message_including_matcher.rb +9 -8
- data/spec/support/unit/matchers/fail_with_message_matcher.rb +1 -1
- data/spec/support/unit/rails_application.rb +29 -13
- data/spec/support/unit/record_validating_confirmation_builder.rb +1 -2
- data/spec/support/unit/shared_examples/set_session_or_flash.rb +355 -0
- data/spec/unit/shoulda/matchers/action_controller/permit_matcher_spec.rb +433 -0
- data/spec/unit/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb +1 -5
- data/spec/unit/shoulda/matchers/action_controller/route_matcher_spec.rb +37 -0
- data/spec/unit/shoulda/matchers/action_controller/set_flash_matcher_spec.rb +23 -147
- data/spec/unit/shoulda/matchers/action_controller/set_session_matcher_spec.rb +8 -285
- data/spec/unit/shoulda/matchers/action_controller/set_session_or_flash_matcher_spec.rb +562 -0
- data/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb +81 -14
- data/spec/unit/shoulda/matchers/active_model/disallow_value_matcher_spec.rb +16 -8
- data/spec/unit/shoulda/matchers/active_model/numericality_matchers/comparison_matcher_spec.rb +101 -9
- data/spec/unit/shoulda/matchers/active_model/numericality_matchers/even_number_matcher_spec.rb +39 -1
- data/spec/unit/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher_spec.rb +39 -1
- data/spec/unit/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher_spec.rb +39 -0
- data/spec/unit/shoulda/matchers/active_model/validate_exclusion_of_matcher_spec.rb +0 -17
- data/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb +0 -17
- data/spec/unit/shoulda/matchers/active_model/validate_length_of_matcher_spec.rb +0 -17
- data/spec/unit/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb +838 -271
- data/spec/unit/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb +0 -19
- data/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb +93 -0
- data/spec/unit/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb +3 -3
- data/spec/unit/shoulda/matchers/active_record/define_enum_for_matcher_spec.rb +25 -0
- data/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb +905 -0
- data/spec/unit/shoulda/matchers/doublespeak/double_collection_spec.rb +17 -11
- data/spec/unit/shoulda/matchers/doublespeak/double_implementation_registry_spec.rb +1 -1
- data/spec/unit/shoulda/matchers/doublespeak/double_spec.rb +144 -43
- data/spec/unit/shoulda/matchers/doublespeak/object_double_spec.rb +1 -1
- data/spec/unit/shoulda/matchers/doublespeak/proxy_implementation_spec.rb +36 -11
- data/spec/unit/shoulda/matchers/doublespeak/stub_implementation_spec.rb +29 -16
- data/spec/unit/shoulda/matchers/doublespeak/world_spec.rb +8 -5
- data/spec/unit/shoulda/matchers/doublespeak_spec.rb +1 -1
- data/spec/unit_spec_helper.rb +15 -14
- data/spec/warnings_spy.rb +1 -1
- metadata +68 -29
- data/docs.watchr +0 -5
- data/gemfiles/3.0.gemfile +0 -26
- data/gemfiles/3.0.gemfile.lock +0 -173
- data/gemfiles/3.1.gemfile +0 -32
- data/gemfiles/3.1.gemfile.lock +0 -212
- data/gemfiles/3.1_1.9.2.gemfile +0 -32
- data/gemfiles/3.1_1.9.2.gemfile.lock +0 -212
- data/gemfiles/3.2.gemfile +0 -33
- data/gemfiles/3.2.gemfile.lock +0 -212
- data/gemfiles/3.2_1.9.2.gemfile +0 -31
- data/gemfiles/3.2_1.9.2.gemfile.lock +0 -207
- data/lib/shoulda/matchers/assertion_error.rb +0 -27
- data/lib/shoulda/matchers/doublespeak/structs.rb +0 -10
- data/lib/shoulda/matchers/integrations/nunit_test_case_detection.rb +0 -39
- data/lib/shoulda/matchers/integrations/rspec.rb +0 -19
- data/lib/shoulda/matchers/integrations/test_unit.rb +0 -34
- data/spec/unit/shoulda/matchers/action_controller/strong_parameters_matcher_spec.rb +0 -331
- data/spec/unit/shoulda/matchers/active_model/validate_uniqueness_of_matcher_spec.rb +0 -564
@@ -3,7 +3,8 @@ module Shoulda
|
|
3
3
|
module Doublespeak
|
4
4
|
# @private
|
5
5
|
class DoubleCollection
|
6
|
-
def initialize(klass)
|
6
|
+
def initialize(world, klass)
|
7
|
+
@world = world
|
7
8
|
@klass = klass
|
8
9
|
@doubles_by_method_name = {}
|
9
10
|
end
|
@@ -40,12 +41,12 @@ module Shoulda
|
|
40
41
|
|
41
42
|
protected
|
42
43
|
|
43
|
-
attr_reader :klass, :doubles_by_method_name
|
44
|
+
attr_reader :world, :klass, :doubles_by_method_name
|
44
45
|
|
45
46
|
def register_double(method_name, implementation_type)
|
46
47
|
implementation =
|
47
48
|
DoubleImplementationRegistry.find(implementation_type)
|
48
|
-
double = Double.new(klass, method_name, implementation)
|
49
|
+
double = Double.new(world, klass, method_name, implementation)
|
49
50
|
doubles_by_method_name[method_name] = double
|
50
51
|
double
|
51
52
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Shoulda
|
2
|
+
module Matchers
|
3
|
+
module Doublespeak
|
4
|
+
# @private
|
5
|
+
class MethodCall
|
6
|
+
attr_accessor :return_value
|
7
|
+
attr_reader :method_name, :args, :block, :object, :double
|
8
|
+
|
9
|
+
def initialize(args)
|
10
|
+
@method_name = args.fetch(:method_name)
|
11
|
+
@args = args.fetch(:args)
|
12
|
+
@block = args[:block]
|
13
|
+
@double = args[:double]
|
14
|
+
@object = args[:object]
|
15
|
+
@return_value = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def with_return_value(return_value)
|
19
|
+
dup.tap do |call|
|
20
|
+
call.return_value = return_value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def ==(other)
|
25
|
+
other.is_a?(self.class) &&
|
26
|
+
method_name == other.method_name &&
|
27
|
+
args == other.args &&
|
28
|
+
block == other.block &&
|
29
|
+
double == other.double &&
|
30
|
+
object == other.object
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -19,8 +19,13 @@ module Shoulda
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def method_missing(method_name, *args, &block)
|
22
|
-
|
23
|
-
|
22
|
+
call = MethodCall.new(
|
23
|
+
method_name: method_name,
|
24
|
+
args: args,
|
25
|
+
block: block
|
26
|
+
)
|
27
|
+
calls << call
|
28
|
+
(calls_by_method_name[method_name] ||= []) << call
|
24
29
|
nil
|
25
30
|
end
|
26
31
|
|
@@ -17,9 +17,10 @@ module Shoulda
|
|
17
17
|
@stub_implementation = stub_implementation
|
18
18
|
end
|
19
19
|
|
20
|
-
def call(
|
21
|
-
|
22
|
-
|
20
|
+
def call(call)
|
21
|
+
return_value = call.double.call_original_method(call)
|
22
|
+
stub_implementation.call(call.with_return_value(return_value))
|
23
|
+
return_value
|
23
24
|
end
|
24
25
|
|
25
26
|
protected
|
@@ -21,9 +21,9 @@ module Shoulda
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def call(
|
25
|
-
double.record_call(
|
26
|
-
implementation.call(
|
24
|
+
def call(call)
|
25
|
+
call.double.record_call(call)
|
26
|
+
implementation.call(call)
|
27
27
|
end
|
28
28
|
|
29
29
|
protected
|
@@ -4,7 +4,19 @@ module Shoulda
|
|
4
4
|
# @private
|
5
5
|
class World
|
6
6
|
def double_collection_for(klass)
|
7
|
-
double_collections_by_class[klass] ||=
|
7
|
+
double_collections_by_class[klass] ||=
|
8
|
+
DoubleCollection.new(self, klass)
|
9
|
+
end
|
10
|
+
|
11
|
+
def store_original_method_for(klass, method_name)
|
12
|
+
original_methods_for_class(klass)[method_name] ||=
|
13
|
+
klass.instance_method(method_name)
|
14
|
+
end
|
15
|
+
|
16
|
+
def original_method_for(klass, method_name)
|
17
|
+
if original_methods_by_class.key?(klass)
|
18
|
+
original_methods_by_class[klass][method_name]
|
19
|
+
end
|
8
20
|
end
|
9
21
|
|
10
22
|
def with_doubles_activated
|
@@ -31,6 +43,14 @@ module Shoulda
|
|
31
43
|
def double_collections_by_class
|
32
44
|
@_double_collections_by_class ||= {}
|
33
45
|
end
|
46
|
+
|
47
|
+
def original_methods_by_class
|
48
|
+
@_original_methods_by_class ||= {}
|
49
|
+
end
|
50
|
+
|
51
|
+
def original_methods_for_class(klass)
|
52
|
+
original_methods_by_class[klass] ||= {}
|
53
|
+
end
|
34
54
|
end
|
35
55
|
end
|
36
56
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Shoulda
|
2
|
+
module Matchers
|
3
|
+
# @private
|
4
|
+
module Integrations
|
5
|
+
class << self
|
6
|
+
def register_library(klass, name)
|
7
|
+
library_registry.register(klass, name)
|
8
|
+
end
|
9
|
+
|
10
|
+
def find_library!(name)
|
11
|
+
library_registry.find!(name)
|
12
|
+
end
|
13
|
+
|
14
|
+
def register_test_framework(klass, name)
|
15
|
+
test_framework_registry.register(klass, name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def find_test_framework!(name)
|
19
|
+
test_framework_registry.find!(name)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def library_registry
|
25
|
+
@_library_registry ||= Registry.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_framework_registry
|
29
|
+
@_test_framework_registry ||= Registry.new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'shoulda/matchers/integrations/configuration'
|
37
|
+
require 'shoulda/matchers/integrations/configuration_error'
|
38
|
+
require 'shoulda/matchers/integrations/inclusion'
|
39
|
+
require 'shoulda/matchers/integrations/rails'
|
40
|
+
require 'shoulda/matchers/integrations/registry'
|
41
|
+
|
42
|
+
require 'shoulda/matchers/integrations/libraries'
|
43
|
+
require 'shoulda/matchers/integrations/test_frameworks'
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module Shoulda
|
4
|
+
module Matchers
|
5
|
+
module Integrations
|
6
|
+
# @private
|
7
|
+
class Configuration
|
8
|
+
def self.apply(configuration, &block)
|
9
|
+
new(configuration, &block).apply
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(configuration, &block)
|
13
|
+
@test_frameworks = Set.new
|
14
|
+
@libraries = Set.new
|
15
|
+
|
16
|
+
test_framework :missing_test_framework
|
17
|
+
library :missing_library
|
18
|
+
|
19
|
+
block.call(self)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_framework(name)
|
23
|
+
clear_default_test_framework
|
24
|
+
@test_frameworks << Integrations.find_test_framework!(name)
|
25
|
+
end
|
26
|
+
|
27
|
+
def library(name)
|
28
|
+
@libraries << Integrations.find_library!(name)
|
29
|
+
end
|
30
|
+
|
31
|
+
def apply
|
32
|
+
if no_test_frameworks_added? && no_libraries_added?
|
33
|
+
raise ConfigurationError, <<EOT
|
34
|
+
shoulda-matchers is not configured correctly. You need to specify at least one
|
35
|
+
test framework and/or library. For example:
|
36
|
+
|
37
|
+
Shoulda::Matchers.configure do |config|
|
38
|
+
config.integrate do |with|
|
39
|
+
with.test_framework :rspec
|
40
|
+
with.library :rails
|
41
|
+
end
|
42
|
+
end
|
43
|
+
EOT
|
44
|
+
end
|
45
|
+
|
46
|
+
@test_frameworks.each do |test_framework|
|
47
|
+
test_framework.include(Shoulda::Matchers::Independent)
|
48
|
+
@libraries.each { |library| library.integrate_with(test_framework) }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def clear_default_test_framework
|
55
|
+
@test_frameworks.select!(&:present?)
|
56
|
+
end
|
57
|
+
|
58
|
+
def no_test_frameworks_added?
|
59
|
+
@test_frameworks.empty? || !@test_frameworks.any?(&:present?)
|
60
|
+
end
|
61
|
+
|
62
|
+
def no_libraries_added?
|
63
|
+
@libraries.empty?
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Shoulda
|
2
|
+
module Matchers
|
3
|
+
module Integrations
|
4
|
+
# @private
|
5
|
+
module Inclusion
|
6
|
+
def include_into(mod, *other_mods, &block)
|
7
|
+
mods_to_include = other_mods.dup
|
8
|
+
mods_to_extend = other_mods.dup
|
9
|
+
|
10
|
+
if block
|
11
|
+
mods_to_include << Module.new(&block)
|
12
|
+
end
|
13
|
+
|
14
|
+
mod.__send__(:include, *mods_to_include)
|
15
|
+
mod.extend(*mods_to_extend)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'shoulda/matchers/integrations/libraries/action_controller'
|
2
|
+
require 'shoulda/matchers/integrations/libraries/active_model'
|
3
|
+
require 'shoulda/matchers/integrations/libraries/active_record'
|
4
|
+
require 'shoulda/matchers/integrations/libraries/missing_library'
|
5
|
+
require 'shoulda/matchers/integrations/libraries/rails'
|
6
|
+
|
7
|
+
module Shoulda
|
8
|
+
module Matchers
|
9
|
+
module Integrations
|
10
|
+
# @private
|
11
|
+
module Libraries
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Shoulda
|
2
|
+
module Matchers
|
3
|
+
module Integrations
|
4
|
+
module Libraries
|
5
|
+
# @private
|
6
|
+
class ActionController
|
7
|
+
Integrations.register_library(self, :action_controller)
|
8
|
+
|
9
|
+
include Integrations::Inclusion
|
10
|
+
include Integrations::Rails
|
11
|
+
|
12
|
+
def integrate_with(test_framework)
|
13
|
+
test_framework.include(matchers_module)
|
14
|
+
|
15
|
+
include_into(::ActionController::TestCase, matchers_module) do
|
16
|
+
def subject
|
17
|
+
@controller
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def matchers_module
|
25
|
+
Shoulda::Matchers::ActionController
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Shoulda
|
2
|
+
module Matchers
|
3
|
+
module Integrations
|
4
|
+
module Libraries
|
5
|
+
# @private
|
6
|
+
class ActiveModel
|
7
|
+
Integrations.register_library(self, :active_model)
|
8
|
+
|
9
|
+
include Integrations::Inclusion
|
10
|
+
include Integrations::Rails
|
11
|
+
|
12
|
+
def integrate_with(test_framework)
|
13
|
+
test_framework.include(matchers_module)
|
14
|
+
include_into(ActiveSupport::TestCase, matchers_module)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def matchers_module
|
20
|
+
Shoulda::Matchers::ActiveModel
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Shoulda
|
2
|
+
module Matchers
|
3
|
+
module Integrations
|
4
|
+
module Libraries
|
5
|
+
# @private
|
6
|
+
class ActiveRecord
|
7
|
+
Integrations.register_library(self, :active_record)
|
8
|
+
|
9
|
+
include Integrations::Inclusion
|
10
|
+
include Integrations::Rails
|
11
|
+
|
12
|
+
def integrate_with(test_framework)
|
13
|
+
test_framework.include(matchers_module)
|
14
|
+
include_into(ActiveSupport::TestCase, matchers_module)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def matchers_module
|
20
|
+
Shoulda::Matchers::ActiveRecord
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Shoulda
|
2
|
+
module Matchers
|
3
|
+
module Integrations
|
4
|
+
module Libraries
|
5
|
+
# @private
|
6
|
+
class MissingLibrary
|
7
|
+
Integrations.register_library(self, :missing_library)
|
8
|
+
|
9
|
+
def integrate_with(test_framework)
|
10
|
+
end
|
11
|
+
|
12
|
+
def rails?
|
13
|
+
false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Shoulda
|
2
|
+
module Matchers
|
3
|
+
module Integrations
|
4
|
+
module Libraries
|
5
|
+
# @private
|
6
|
+
class Rails
|
7
|
+
Integrations.register_library(self, :rails)
|
8
|
+
|
9
|
+
include Integrations::Rails
|
10
|
+
|
11
|
+
SUB_LIBRARIES = [
|
12
|
+
:active_model,
|
13
|
+
:active_record,
|
14
|
+
:action_controller
|
15
|
+
]
|
16
|
+
|
17
|
+
def integrate_with(test_framework)
|
18
|
+
Shoulda::Matchers.assertion_exception_class =
|
19
|
+
ActiveSupport::TestCase::Assertion
|
20
|
+
|
21
|
+
SUB_LIBRARIES.each do |name|
|
22
|
+
library = Integrations.find_library!(name)
|
23
|
+
library.integrate_with(test_framework)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|