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.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/.hound_config/ruby.yml +7 -0
  3. data/.travis.yml +11 -54
  4. data/Appraisals +45 -100
  5. data/CONTRIBUTING.md +51 -7
  6. data/Gemfile +7 -19
  7. data/Gemfile.lock +60 -134
  8. data/Guardfile +5 -0
  9. data/NEWS.md +203 -0
  10. data/README.md +95 -50
  11. data/Rakefile +1 -0
  12. data/doc_config/yard/templates/default/layout/html/setup.rb +1 -1
  13. data/gemfiles/4.0.0.gemfile +10 -7
  14. data/gemfiles/4.0.0.gemfile.lock +103 -79
  15. data/gemfiles/4.0.1.gemfile +10 -7
  16. data/gemfiles/4.0.1.gemfile.lock +109 -83
  17. data/gemfiles/4.1.gemfile +10 -7
  18. data/gemfiles/4.1.gemfile.lock +109 -85
  19. data/gemfiles/4.2.gemfile +10 -9
  20. data/gemfiles/4.2.gemfile.lock +86 -78
  21. data/lib/shoulda/matchers.rb +13 -18
  22. data/lib/shoulda/matchers/action_controller.rb +4 -1
  23. data/lib/shoulda/matchers/action_controller/flash_store.rb +95 -0
  24. data/lib/shoulda/matchers/action_controller/{strong_parameters_matcher.rb → permit_matcher.rb} +147 -30
  25. data/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +1 -1
  26. data/lib/shoulda/matchers/action_controller/render_template_matcher.rb +1 -1
  27. data/lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb +1 -1
  28. data/lib/shoulda/matchers/action_controller/rescue_from_matcher.rb +1 -1
  29. data/lib/shoulda/matchers/action_controller/route_matcher.rb +5 -1
  30. data/lib/shoulda/matchers/action_controller/route_params.rb +15 -6
  31. data/lib/shoulda/matchers/action_controller/session_store.rb +34 -0
  32. data/lib/shoulda/matchers/action_controller/set_flash_matcher.rb +30 -136
  33. data/lib/shoulda/matchers/action_controller/set_session_matcher.rb +28 -109
  34. data/lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb +103 -0
  35. data/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb +1 -12
  36. data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +79 -10
  37. data/lib/shoulda/matchers/active_model/numericality_matchers/numeric_type_matcher.rb +10 -0
  38. data/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +21 -0
  39. data/lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb +24 -0
  40. data/lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb +22 -5
  41. data/lib/shoulda/matchers/active_model/validate_exclusion_of_matcher.rb +29 -10
  42. data/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +27 -10
  43. data/lib/shoulda/matchers/active_model/validate_length_of_matcher.rb +27 -12
  44. data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +56 -20
  45. data/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +3 -11
  46. data/lib/shoulda/matchers/active_model/validation_message_finder.rb +65 -0
  47. data/lib/shoulda/matchers/active_record/association_matcher.rb +40 -6
  48. data/lib/shoulda/matchers/active_record/association_matchers/join_table_matcher.rb +21 -7
  49. data/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +11 -40
  50. data/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +1 -1
  51. data/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb +2 -6
  52. data/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +137 -22
  53. data/lib/shoulda/matchers/configuration.rb +20 -0
  54. data/lib/shoulda/matchers/doublespeak.rb +11 -1
  55. data/lib/shoulda/matchers/doublespeak/double.rb +29 -11
  56. data/lib/shoulda/matchers/doublespeak/double_collection.rb +4 -3
  57. data/lib/shoulda/matchers/doublespeak/method_call.rb +35 -0
  58. data/lib/shoulda/matchers/doublespeak/object_double.rb +7 -2
  59. data/lib/shoulda/matchers/doublespeak/proxy_implementation.rb +4 -3
  60. data/lib/shoulda/matchers/doublespeak/stub_implementation.rb +3 -3
  61. data/lib/shoulda/matchers/doublespeak/world.rb +21 -1
  62. data/lib/shoulda/matchers/integrations.rb +43 -0
  63. data/lib/shoulda/matchers/integrations/configuration.rb +68 -0
  64. data/lib/shoulda/matchers/integrations/configuration_error.rb +9 -0
  65. data/lib/shoulda/matchers/integrations/inclusion.rb +20 -0
  66. data/lib/shoulda/matchers/integrations/libraries.rb +15 -0
  67. data/lib/shoulda/matchers/integrations/libraries/action_controller.rb +31 -0
  68. data/lib/shoulda/matchers/integrations/libraries/active_model.rb +26 -0
  69. data/lib/shoulda/matchers/integrations/libraries/active_record.rb +26 -0
  70. data/lib/shoulda/matchers/integrations/libraries/missing_library.rb +19 -0
  71. data/lib/shoulda/matchers/integrations/libraries/rails.rb +30 -0
  72. data/lib/shoulda/matchers/integrations/rails.rb +12 -0
  73. data/lib/shoulda/matchers/integrations/registry.rb +28 -0
  74. data/lib/shoulda/matchers/integrations/test_frameworks.rb +16 -0
  75. data/lib/shoulda/matchers/integrations/test_frameworks/active_support_test_case.rb +37 -0
  76. data/lib/shoulda/matchers/integrations/test_frameworks/minitest_4.rb +36 -0
  77. data/lib/shoulda/matchers/integrations/test_frameworks/minitest_5.rb +37 -0
  78. data/lib/shoulda/matchers/integrations/test_frameworks/missing_test_framework.rb +40 -0
  79. data/lib/shoulda/matchers/integrations/test_frameworks/rspec.rb +29 -0
  80. data/lib/shoulda/matchers/integrations/test_frameworks/test_unit.rb +36 -0
  81. data/lib/shoulda/matchers/rails_shim.rb +0 -40
  82. data/lib/shoulda/matchers/version.rb +1 -1
  83. data/script/SUPPORTED_VERSIONS +1 -1
  84. data/script/update_gems_in_all_appraisals +14 -0
  85. data/shoulda-matchers.gemspec +2 -2
  86. data/spec/acceptance/active_model_integration_spec.rb +4 -1
  87. data/spec/acceptance/independent_matchers_spec.rb +6 -6
  88. data/spec/acceptance/multiple_libraries_integration_spec.rb +52 -0
  89. data/spec/acceptance/rails_integration_spec.rb +15 -5
  90. data/spec/acceptance_spec_helper.rb +8 -0
  91. data/spec/doublespeak_spec_helper.rb +14 -0
  92. data/spec/support/acceptance/adds_shoulda_matchers_to_project.rb +110 -0
  93. data/spec/support/acceptance/helpers.rb +2 -0
  94. data/spec/support/acceptance/helpers/base_helpers.rb +6 -1
  95. data/spec/support/acceptance/helpers/command_helpers.rb +6 -2
  96. data/spec/support/acceptance/helpers/minitest_helpers.rb +0 -8
  97. data/spec/support/acceptance/helpers/n_unit_helpers.rb +25 -0
  98. data/spec/support/acceptance/helpers/rspec_helpers.rb +2 -0
  99. data/spec/support/acceptance/helpers/step_helpers.rb +13 -19
  100. data/spec/support/acceptance/matchers/have_output.rb +1 -1
  101. data/spec/support/tests/bundle.rb +1 -1
  102. data/spec/support/tests/command_runner.rb +25 -13
  103. data/spec/support/tests/current_bundle.rb +47 -0
  104. data/spec/support/tests/database.rb +28 -0
  105. data/spec/support/tests/database_adapters/postgresql.rb +25 -0
  106. data/spec/support/tests/database_adapters/sqlite3.rb +26 -0
  107. data/spec/support/tests/database_configuration.rb +33 -0
  108. data/spec/support/tests/database_configuration_registry.rb +28 -0
  109. data/spec/support/tests/filesystem.rb +25 -2
  110. data/spec/support/unit/helpers/active_record_versions.rb +12 -0
  111. data/spec/support/unit/helpers/class_builder.rb +6 -2
  112. data/spec/support/unit/helpers/column_type_helpers.rb +26 -0
  113. data/spec/support/unit/helpers/controller_builder.rb +0 -28
  114. data/spec/support/unit/helpers/database_helpers.rb +18 -0
  115. data/spec/support/unit/helpers/model_builder.rb +38 -6
  116. data/spec/support/unit/helpers/rails_versions.rb +2 -2
  117. data/spec/support/unit/matchers/fail_with_message_including_matcher.rb +9 -8
  118. data/spec/support/unit/matchers/fail_with_message_matcher.rb +1 -1
  119. data/spec/support/unit/rails_application.rb +29 -13
  120. data/spec/support/unit/record_validating_confirmation_builder.rb +1 -2
  121. data/spec/support/unit/shared_examples/set_session_or_flash.rb +355 -0
  122. data/spec/unit/shoulda/matchers/action_controller/permit_matcher_spec.rb +433 -0
  123. data/spec/unit/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb +1 -5
  124. data/spec/unit/shoulda/matchers/action_controller/route_matcher_spec.rb +37 -0
  125. data/spec/unit/shoulda/matchers/action_controller/set_flash_matcher_spec.rb +23 -147
  126. data/spec/unit/shoulda/matchers/action_controller/set_session_matcher_spec.rb +8 -285
  127. data/spec/unit/shoulda/matchers/action_controller/set_session_or_flash_matcher_spec.rb +562 -0
  128. data/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb +81 -14
  129. data/spec/unit/shoulda/matchers/active_model/disallow_value_matcher_spec.rb +16 -8
  130. data/spec/unit/shoulda/matchers/active_model/numericality_matchers/comparison_matcher_spec.rb +101 -9
  131. data/spec/unit/shoulda/matchers/active_model/numericality_matchers/even_number_matcher_spec.rb +39 -1
  132. data/spec/unit/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher_spec.rb +39 -1
  133. data/spec/unit/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher_spec.rb +39 -0
  134. data/spec/unit/shoulda/matchers/active_model/validate_exclusion_of_matcher_spec.rb +0 -17
  135. data/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb +0 -17
  136. data/spec/unit/shoulda/matchers/active_model/validate_length_of_matcher_spec.rb +0 -17
  137. data/spec/unit/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb +838 -271
  138. data/spec/unit/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb +0 -19
  139. data/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb +93 -0
  140. data/spec/unit/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb +3 -3
  141. data/spec/unit/shoulda/matchers/active_record/define_enum_for_matcher_spec.rb +25 -0
  142. data/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb +905 -0
  143. data/spec/unit/shoulda/matchers/doublespeak/double_collection_spec.rb +17 -11
  144. data/spec/unit/shoulda/matchers/doublespeak/double_implementation_registry_spec.rb +1 -1
  145. data/spec/unit/shoulda/matchers/doublespeak/double_spec.rb +144 -43
  146. data/spec/unit/shoulda/matchers/doublespeak/object_double_spec.rb +1 -1
  147. data/spec/unit/shoulda/matchers/doublespeak/proxy_implementation_spec.rb +36 -11
  148. data/spec/unit/shoulda/matchers/doublespeak/stub_implementation_spec.rb +29 -16
  149. data/spec/unit/shoulda/matchers/doublespeak/world_spec.rb +8 -5
  150. data/spec/unit/shoulda/matchers/doublespeak_spec.rb +1 -1
  151. data/spec/unit_spec_helper.rb +15 -14
  152. data/spec/warnings_spy.rb +1 -1
  153. metadata +68 -29
  154. data/docs.watchr +0 -5
  155. data/gemfiles/3.0.gemfile +0 -26
  156. data/gemfiles/3.0.gemfile.lock +0 -173
  157. data/gemfiles/3.1.gemfile +0 -32
  158. data/gemfiles/3.1.gemfile.lock +0 -212
  159. data/gemfiles/3.1_1.9.2.gemfile +0 -32
  160. data/gemfiles/3.1_1.9.2.gemfile.lock +0 -212
  161. data/gemfiles/3.2.gemfile +0 -33
  162. data/gemfiles/3.2.gemfile.lock +0 -212
  163. data/gemfiles/3.2_1.9.2.gemfile +0 -31
  164. data/gemfiles/3.2_1.9.2.gemfile.lock +0 -207
  165. data/lib/shoulda/matchers/assertion_error.rb +0 -27
  166. data/lib/shoulda/matchers/doublespeak/structs.rb +0 -10
  167. data/lib/shoulda/matchers/integrations/nunit_test_case_detection.rb +0 -39
  168. data/lib/shoulda/matchers/integrations/rspec.rb +0 -19
  169. data/lib/shoulda/matchers/integrations/test_unit.rb +0 -34
  170. data/spec/unit/shoulda/matchers/action_controller/strong_parameters_matcher_spec.rb +0 -331
  171. data/spec/unit/shoulda/matchers/active_model/validate_uniqueness_of_matcher_spec.rb +0 -564
@@ -0,0 +1,28 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ # @private
5
+ class Registry
6
+ def register(klass, name)
7
+ registry[name] = klass
8
+ end
9
+
10
+ def find!(name)
11
+ find_class!(name).new
12
+ end
13
+
14
+ private
15
+
16
+ def registry
17
+ @_registry ||= {}
18
+ end
19
+
20
+ def find_class!(name)
21
+ registry.fetch(name) do
22
+ raise ArgumentError, "'#{name}' is not registered"
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,16 @@
1
+ require 'shoulda/matchers/integrations/test_frameworks/active_support_test_case'
2
+ require 'shoulda/matchers/integrations/test_frameworks/minitest_4'
3
+ require 'shoulda/matchers/integrations/test_frameworks/minitest_5'
4
+ require 'shoulda/matchers/integrations/test_frameworks/missing_test_framework'
5
+ require 'shoulda/matchers/integrations/test_frameworks/rspec'
6
+ require 'shoulda/matchers/integrations/test_frameworks/test_unit'
7
+
8
+ module Shoulda
9
+ module Matchers
10
+ module Integrations
11
+ # @private
12
+ module TestFrameworks
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,37 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module TestFrameworks
5
+ # @private
6
+ class ActiveSupportTestCase
7
+ Integrations.register_test_framework(self, :active_support_test_case)
8
+
9
+ def validate!
10
+ end
11
+
12
+ def include(*modules)
13
+ test_case_class.include(*modules)
14
+ end
15
+
16
+ def n_unit?
17
+ true
18
+ end
19
+
20
+ def present?
21
+ true
22
+ end
23
+
24
+ protected
25
+
26
+ attr_reader :configuration
27
+
28
+ private
29
+
30
+ def test_case_class
31
+ ActiveSupport::TestCase
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,36 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module TestFrameworks
5
+ # @private
6
+ class Minitest4
7
+ Integrations.register_test_framework(self, :minitest_4)
8
+
9
+ def validate!
10
+ end
11
+
12
+ def include(*modules)
13
+ test_case_class.class_eval do
14
+ include(*modules)
15
+ extend(*modules)
16
+ end
17
+ end
18
+
19
+ def n_unit?
20
+ true
21
+ end
22
+
23
+ def present?
24
+ true
25
+ end
26
+
27
+ private
28
+
29
+ def test_case_class
30
+ MiniTest::Unit::TestCase
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,37 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module TestFrameworks
5
+ # @private
6
+ class Minitest5
7
+ Integrations.register_test_framework(self, :minitest_5)
8
+ Integrations.register_test_framework(self, :minitest)
9
+
10
+ def validate!
11
+ end
12
+
13
+ def include(*modules)
14
+ test_case_class.class_eval do
15
+ include(*modules)
16
+ extend(*modules)
17
+ end
18
+ end
19
+
20
+ def n_unit?
21
+ true
22
+ end
23
+
24
+ def present?
25
+ true
26
+ end
27
+
28
+ private
29
+
30
+ def test_case_class
31
+ Minitest::Test
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,40 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module TestFrameworks
5
+ # @private
6
+ class MissingTestFramework
7
+ Integrations.register_test_framework(self, :missing_test_framework)
8
+
9
+ def validate!
10
+ raise TestFrameworkNotConfigured, <<-EOT
11
+ You need to set a test framework. Please add the following to your
12
+ test helper:
13
+
14
+ Shoulda::Matchers.configure do |config|
15
+ config.integrate do |with|
16
+ # Choose one:
17
+ with.test_framework :rspec
18
+ with.test_framework :minitest # or, :minitest_5
19
+ with.test_framework :minitest_4
20
+ with.test_framework :test_unit
21
+ end
22
+ end
23
+ EOT
24
+ end
25
+
26
+ def include(*modules)
27
+ end
28
+
29
+ def n_unit?
30
+ false
31
+ end
32
+
33
+ def present?
34
+ false
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,29 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module TestFrameworks
5
+ # @private
6
+ class Rspec
7
+ Integrations.register_test_framework(self, :rspec)
8
+
9
+ def validate!
10
+ end
11
+
12
+ def include(*modules)
13
+ ::RSpec.configure do |config|
14
+ config.include(*modules)
15
+ end
16
+ end
17
+
18
+ def n_unit?
19
+ false
20
+ end
21
+
22
+ def present?
23
+ true
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,36 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module Integrations
4
+ module TestFrameworks
5
+ # @private
6
+ class TestUnit
7
+ Integrations.register_test_framework(self, :test_unit)
8
+
9
+ def validate!
10
+ end
11
+
12
+ def include(*modules)
13
+ test_case_class.class_eval do
14
+ include(*modules)
15
+ extend(*modules)
16
+ end
17
+ end
18
+
19
+ def n_unit?
20
+ true
21
+ end
22
+
23
+ def present?
24
+ true
25
+ end
26
+
27
+ private
28
+
29
+ def test_case_class
30
+ ::Test::Unit::TestCase
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -2,38 +2,6 @@ module Shoulda
2
2
  module Matchers
3
3
  # @private
4
4
  class RailsShim
5
- def self.layouts_ivar
6
- if action_pack_major_version >= 4
7
- '@_layouts'
8
- else
9
- '@layouts'
10
- end
11
- end
12
-
13
- def self.flashes_ivar
14
- if action_pack_major_version >= 4
15
- :@flashes
16
- else
17
- :@used
18
- end
19
- end
20
-
21
- def self.clean_scope(klass)
22
- if active_record_major_version == 4
23
- klass.all
24
- else
25
- klass.scoped
26
- end
27
- end
28
-
29
- def self.validates_confirmation_of_error_attribute(matcher)
30
- if active_model_major_version == 4
31
- matcher.confirmation_attribute
32
- else
33
- matcher.attribute
34
- end
35
- end
36
-
37
5
  def self.verb_for_update
38
6
  if action_pack_gte_4_1?
39
7
  :patch
@@ -91,14 +59,6 @@ module Shoulda
91
59
  ::ActiveRecord::VERSION::MAJOR
92
60
  end
93
61
 
94
- def self.active_model_major_version
95
- ::ActiveModel::VERSION::MAJOR
96
- end
97
-
98
- def self.action_pack_major_version
99
- ::ActionPack::VERSION::MAJOR
100
- end
101
-
102
62
  def self.action_pack_gte_4_1?
103
63
  Gem::Requirement.new('>= 4.1').satisfied_by?(action_pack_version)
104
64
  end
@@ -1,6 +1,6 @@
1
1
  module Shoulda
2
2
  module Matchers
3
3
  # @private
4
- VERSION = '2.8.0'.freeze
4
+ VERSION = '3.0.0.rc1'.freeze
5
5
  end
6
6
  end
@@ -1 +1 @@
1
- 1.9.2 1.9.3 2.0.0 2.1.5
1
+ 2.0.0 2.1.5
@@ -0,0 +1,14 @@
1
+ #!/bin/bash
2
+
3
+ SUPPORTED_VERSIONS=$(<script/SUPPORTED_VERSIONS)
4
+
5
+ update-gems-for-version() {
6
+ local version="$1"
7
+ (export RBENV_VERSION=$version; bundle update "${@:2}" && bundle exec appraisal update "${@:2}")
8
+ }
9
+
10
+ for version in $SUPPORTED_VERSIONS; do
11
+ echo
12
+ echo "*** Updating gems for $version ***"
13
+ update-gems-for-version "$version" "$@"
14
+ done
@@ -18,6 +18,6 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.required_ruby_version = '>= 1.9.2'
22
- s.add_dependency('activesupport', '>= 3.0.0')
21
+ s.required_ruby_version = '>= 2.0.0'
22
+ s.add_dependency('activesupport', '>= 4.0.0')
23
23
  end
@@ -4,7 +4,10 @@ describe 'shoulda-matchers integrates with an ActiveModel project' do
4
4
  specify 'and loads without errors' do
5
5
  create_active_model_project
6
6
 
7
- add_shoulda_matchers_to_project
7
+ add_shoulda_matchers_to_project(
8
+ test_frameworks: [:rspec],
9
+ libraries: [:active_model]
10
+ )
8
11
 
9
12
  write_file 'load_dependencies.rb', <<-FILE
10
13
  require 'active_model'
@@ -2,14 +2,14 @@ require 'acceptance_spec_helper'
2
2
 
3
3
  describe 'shoulda-matchers has independent matchers' do
4
4
  context 'specifically delegate_method' do
5
- specify 'and integrates with a Ruby application that uses Minitest' do
5
+ specify 'and integrates with a Ruby application that uses the default test framework' do
6
6
  create_generic_bundler_project
7
7
 
8
8
  updating_bundle do
9
9
  add_minitest_to_project
10
10
  add_shoulda_context_to_project(manually: true)
11
11
  add_shoulda_matchers_to_project(
12
- test_frameworks: [:n_unit],
12
+ test_frameworks: [default_test_framework],
13
13
  manually: true
14
14
  )
15
15
  end
@@ -35,11 +35,11 @@ describe 'shoulda-matchers has independent matchers' do
35
35
  end
36
36
  FILE
37
37
 
38
- write_minitest_test 'test/courier_test.rb' do |test_case_superclass|
38
+ write_n_unit_test 'test/courier_test.rb' do |test_case_superclass|
39
39
  <<-FILE
40
- require "test_helper"
41
- require "courier"
42
- require "post_office"
40
+ require 'test_helper'
41
+ require 'courier'
42
+ require 'post_office'
43
43
 
44
44
  class CourierTest < #{test_case_superclass}
45
45
  subject { Courier.new(post_office) }
@@ -0,0 +1,52 @@
1
+ require 'acceptance_spec_helper'
2
+
3
+ describe 'shoulda-matchers integrates with multiple libraries' do
4
+ before do
5
+ create_rails_application
6
+
7
+ write_file 'db/migrate/1_create_users.rb', <<-FILE
8
+ class CreateUsers < ActiveRecord::Migration
9
+ def self.up
10
+ create_table :users do |t|
11
+ t.string :name
12
+ end
13
+ end
14
+ end
15
+ FILE
16
+
17
+ run_rake_tasks!(*%w(db:drop db:create db:migrate))
18
+
19
+ write_file 'app/models/user.rb', <<-FILE
20
+ class User < ActiveRecord::Base
21
+ validates_presence_of :name
22
+ validates_uniqueness_of :name
23
+ end
24
+ FILE
25
+
26
+ add_rspec_file 'spec/models/user_spec.rb', <<-FILE
27
+ describe User do
28
+ it { should validate_presence_of(:name) }
29
+ it { should validate_uniqueness_of(:name) }
30
+ end
31
+ FILE
32
+
33
+ updating_bundle do
34
+ add_rspec_rails_to_project!
35
+ add_shoulda_matchers_to_project(
36
+ test_frameworks: [:rspec],
37
+ libraries: [:active_record, :active_model]
38
+ )
39
+ end
40
+ end
41
+
42
+ context 'when using both active_record and active_model libraries' do
43
+ it 'allows the use of matchers from both libraries' do
44
+ result = run_rspec_suite
45
+ expect(result).to have_output('2 examples, 0 failures')
46
+ expect(result).to have_output('should require name to be set')
47
+ expect(result).to have_output(
48
+ 'should require case sensitive unique value for name'
49
+ )
50
+ end
51
+ end
52
+ end