shoulda-matchers 3.0.1 → 3.1.0

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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +3 -3
  4. data/CONTRIBUTING.md +60 -28
  5. data/Gemfile +1 -0
  6. data/Gemfile.lock +15 -12
  7. data/NEWS.md +111 -0
  8. data/README.md +94 -6
  9. data/Rakefile +10 -8
  10. data/custom_plan.rb +88 -0
  11. data/gemfiles/4.0.0.gemfile +1 -0
  12. data/gemfiles/4.0.0.gemfile.lock +21 -18
  13. data/gemfiles/4.0.1.gemfile +1 -0
  14. data/gemfiles/4.0.1.gemfile.lock +21 -18
  15. data/gemfiles/4.1.gemfile +1 -0
  16. data/gemfiles/4.1.gemfile.lock +21 -18
  17. data/gemfiles/4.2.gemfile +1 -0
  18. data/gemfiles/4.2.gemfile.lock +24 -21
  19. data/lib/shoulda/matchers/action_controller/permit_matcher.rb +6 -11
  20. data/lib/shoulda/matchers/active_model.rb +10 -1
  21. data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +258 -180
  22. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error.rb +45 -0
  23. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_does_not_exist_error.rb +23 -0
  24. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setter.rb +236 -0
  25. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setter_and_validator.rb +62 -0
  26. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb +40 -0
  27. data/lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators.rb +48 -0
  28. data/lib/shoulda/matchers/active_model/allow_value_matcher/successful_check.rb +14 -0
  29. data/lib/shoulda/matchers/active_model/allow_value_matcher/successful_setting.rb +14 -0
  30. data/lib/shoulda/matchers/active_model/disallow_value_matcher.rb +34 -14
  31. data/lib/shoulda/matchers/active_model/helpers.rb +9 -17
  32. data/lib/shoulda/matchers/active_model/numericality_matchers/comparison_matcher.rb +13 -6
  33. data/lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb +13 -2
  34. data/lib/shoulda/matchers/active_model/numericality_matchers/numeric_type_matcher.rb +19 -35
  35. data/lib/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher.rb +13 -2
  36. data/lib/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher.rb +12 -2
  37. data/lib/shoulda/matchers/active_model/qualifiers.rb +12 -0
  38. data/lib/shoulda/matchers/active_model/qualifiers/ignore_interference_by_writer.rb +101 -0
  39. data/lib/shoulda/matchers/active_model/qualifiers/ignoring_interference_by_writer.rb +21 -0
  40. data/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +30 -32
  41. data/lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb +5 -8
  42. data/lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb +22 -22
  43. data/lib/shoulda/matchers/active_model/validate_exclusion_of_matcher.rb +27 -16
  44. data/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb +58 -15
  45. data/lib/shoulda/matchers/active_model/validate_length_of_matcher.rb +22 -12
  46. data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +165 -87
  47. data/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +7 -9
  48. data/lib/shoulda/matchers/active_model/validation_matcher.rb +111 -49
  49. data/lib/shoulda/matchers/active_model/validation_matcher/build_description.rb +60 -0
  50. data/lib/shoulda/matchers/active_model/validator.rb +71 -52
  51. data/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb +19 -5
  52. data/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +450 -124
  53. data/lib/shoulda/matchers/util.rb +43 -0
  54. data/lib/shoulda/matchers/util/word_wrap.rb +59 -31
  55. data/lib/shoulda/matchers/version.rb +1 -1
  56. data/script/update_gem_in_all_appraisals +1 -1
  57. data/script/update_gems_in_all_appraisals +1 -1
  58. data/spec/acceptance/multiple_libraries_integration_spec.rb +5 -2
  59. data/spec/acceptance/rails_integration_spec.rb +6 -2
  60. data/spec/spec_helper.rb +1 -3
  61. data/spec/support/acceptance/helpers/step_helpers.rb +4 -1
  62. data/spec/support/tests/current_bundle.rb +21 -7
  63. data/spec/support/unit/active_record/create_table.rb +54 -0
  64. data/spec/support/unit/attribute.rb +47 -0
  65. data/spec/support/unit/capture.rb +6 -0
  66. data/spec/support/unit/change_value.rb +111 -0
  67. data/spec/support/unit/create_model_arguments/basic.rb +135 -0
  68. data/spec/support/unit/create_model_arguments/has_many.rb +15 -0
  69. data/spec/support/unit/create_model_arguments/uniqueness_matcher.rb +74 -0
  70. data/spec/support/unit/helpers/active_record_versions.rb +1 -1
  71. data/spec/support/unit/helpers/class_builder.rb +61 -47
  72. data/spec/support/unit/helpers/database_helpers.rb +5 -3
  73. data/spec/support/unit/helpers/model_builder.rb +77 -97
  74. data/spec/support/unit/helpers/validation_matcher_scenario_helpers.rb +44 -0
  75. data/spec/support/unit/load_environment.rb +12 -0
  76. data/spec/support/unit/matchers/fail_with_message_including_matcher.rb +2 -2
  77. data/spec/support/unit/matchers/fail_with_message_matcher.rb +12 -1
  78. data/spec/support/unit/model_creation_strategies/active_model.rb +111 -0
  79. data/spec/support/unit/model_creation_strategies/active_record.rb +77 -0
  80. data/spec/support/unit/model_creators.rb +19 -0
  81. data/spec/support/unit/model_creators/active_model.rb +39 -0
  82. data/spec/support/unit/model_creators/active_record.rb +43 -0
  83. data/spec/support/unit/model_creators/active_record/has_and_belongs_to_many.rb +95 -0
  84. data/spec/support/unit/model_creators/active_record/has_many.rb +67 -0
  85. data/spec/support/unit/model_creators/active_record/uniqueness_matcher.rb +42 -0
  86. data/spec/support/unit/model_creators/basic.rb +97 -0
  87. data/spec/support/unit/rails_application.rb +1 -1
  88. data/spec/support/unit/record_validating_confirmation_builder.rb +3 -7
  89. data/spec/support/unit/shared_examples/ignoring_interference_by_writer.rb +79 -0
  90. data/spec/support/unit/validation_matcher_scenario.rb +62 -0
  91. data/spec/unit/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb +4 -0
  92. data/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb +575 -140
  93. data/spec/unit/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb +115 -15
  94. data/spec/unit/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb +42 -4
  95. data/spec/unit/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb +92 -6
  96. data/spec/unit/shoulda/matchers/active_model/validate_exclusion_of_matcher_spec.rb +122 -10
  97. data/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb +306 -58
  98. data/spec/unit/shoulda/matchers/active_model/validate_length_of_matcher_spec.rb +122 -3
  99. data/spec/unit/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb +805 -131
  100. data/spec/unit/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb +196 -29
  101. data/spec/unit/shoulda/matchers/active_record/define_enum_for_matcher_spec.rb +82 -40
  102. data/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb +600 -101
  103. data/spec/unit/shoulda/matchers/util/word_wrap_spec.rb +88 -33
  104. data/spec/unit_spec_helper.rb +10 -22
  105. data/zeus.json +11 -0
  106. metadata +64 -23
  107. data/lib/shoulda/matchers/active_model/strict_validator.rb +0 -51
  108. data/spec/support/unit/shared_examples/numerical_type_submatcher.rb +0 -15
  109. data/spec/unit/shoulda/matchers/active_model/numericality_matchers/comparison_matcher_spec.rb +0 -288
  110. data/spec/unit/shoulda/matchers/active_model/numericality_matchers/even_number_matcher_spec.rb +0 -100
  111. data/spec/unit/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher_spec.rb +0 -100
  112. data/spec/unit/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher_spec.rb +0 -100
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fe80273c48fdbadb3d479406470fa875abfcf61
4
- data.tar.gz: 3cac554e34d73023e1e3cd5a65bc23291159ff87
3
+ metadata.gz: 958afbf8d323fd9b923340fdffc6156b7a3249cc
4
+ data.tar.gz: d20c30587592682f62e4b061619d32254625de23
5
5
  SHA512:
6
- metadata.gz: df7679b9a7384f93e221a7a9a07411bd6e6f93cd3dc267e262e803b3c7359b3272b4adb037039e09662bf7bb6e9b31d094748109dec3e9050967df8d3691f8f8
7
- data.tar.gz: f5c6cea2751c9cf331b96447af1d8f70c6ecd1edae2aac4c587361e438a14caa8cd8da563873135b0421450f28663e1c1b7c4f542182b9a5311cee1480d29520
6
+ metadata.gz: b2141dd710f58fa62201e4fa3de70c324bbb9e6d225f41d88ecef413c401a10f1426f59025849e466c58d7c58bf6f94b0330b6e82c7577e3797f6bd0f91d97a2
7
+ data.tar.gz: d22c37a1994c433c9213b1a3090f6cd06201a49d19fbc7cdbeca7bc826fec4b0853a7a216e8977df578b1627011eb23786fe276dc12e2a906116822dd88f0f1b
data/.gitignore CHANGED
@@ -8,4 +8,5 @@ build
8
8
  doc
9
9
  pkg
10
10
  source
11
+ spec/examples.txt
11
12
  tmp
@@ -8,9 +8,9 @@ env:
8
8
  - DATABASE_ADAPTER=postgresql
9
9
 
10
10
  rvm:
11
- - 2.0.0
12
- - 2.1.4
13
- - 2.2.0
11
+ - 2.0
12
+ - 2.1
13
+ - 2.2
14
14
 
15
15
  gemfile:
16
16
  - gemfiles/4.0.0.gemfile
@@ -1,24 +1,56 @@
1
+ # Contributing to shoulda-matchers
2
+
1
3
  We love contributions from the community! Here's a quick guide to making a pull
2
4
  request.
3
5
 
4
- ## Overview
6
+ 1. If you haven't contributed before, please read and understand the [Code of
7
+ Conduct].
8
+
9
+ 1. Ensure that you have a [working Ruby environment].
10
+
11
+ 1. Fork the repo on GitHub, then clone it to your machine.
12
+
13
+ 1. Now that you've cloned the repo, navigate to it and install dependencies by
14
+ running:
5
15
 
6
- 0. If you haven't contributed before, please read and understand the [Code of
7
- Conduct].
16
+ ```
17
+ bundle install
18
+ ```
8
19
 
9
- 1. Fork the repo.
20
+ 1. All tests should be passing, but it's a good idea to run them anyway
21
+ before starting any work:
22
+
23
+ ```
24
+ bundle exec rake
25
+ ```
10
26
 
11
- 2. Install [dependencies](#installing-dependencies).
27
+ 1. If you're adding functionality or fixing a bug, you'll want to add a
28
+ failing test for the issue first.
12
29
 
13
- 3. Run the tests. We only take pull requests with passing tests, and it's great
14
- to know that you have a clean slate: `bundle && bundle exec rake`
30
+ 1. Now you can implement the feature or bugfix.
15
31
 
16
- 4. If you're adding functionality or fixing a bug, add a failing test for the
17
- issue first.
32
+ 1. Since we only accept pull requests with passing tests, it's a good idea to
33
+ run the tests again. Since you're probably working on a single file, you can
34
+ run the tests for that file with the following command:
18
35
 
19
- 5. Make the test pass.
36
+ ```
37
+ appraisal 4.2 rspec <path of test file to run>
38
+ ```
20
39
 
21
- 6. Finally, push to your fork and submit a pull request.
40
+ You can also run unit tests by running `zeus start` in one shell, and then
41
+ running the following in another:
42
+
43
+ ```
44
+ zeus rspec <path of test file to run>
45
+ ```
46
+
47
+ And to run the entire test suite again:
48
+
49
+ ```
50
+ bundle exec rake
51
+ ```
52
+
53
+ 1. Finally, push to your fork and submit a pull request.
22
54
 
23
55
  At this point you're waiting on us. We try to respond to issues and pull
24
56
  requests within a few business days. We may suggest some changes to make to your
@@ -26,35 +58,27 @@ code to fit with our [code style] or the project style, or discuss alternate
26
58
  ways of addressing the issue in question. When we're happy with everything,
27
59
  we'll bring your changes into master. Now you're a contributor!
28
60
 
29
- ## Installing Dependencies
61
+ ## Addendum: Setting up your environment
30
62
 
31
- ### On Debian/Ubuntu-based systems
63
+ ### Installing dependencies (Linux only)
32
64
 
33
- ```
34
- sudo apt-get install -y ruby-dev libpq-dev libsqlite3-dev nodejs
35
- ```
65
+ #### Debian/Ubuntu
36
66
 
37
- Ubuntu, as of 14.04, ships with Ruby 1.9.2. shoulda-matchers is only compatible
38
- with Ruby 2, so use your Ruby version manager of choice to install the latest
39
- version of Ruby (2.2.1 at the time of this writing).
67
+ Run this command to install necessary dependencies:
40
68
 
41
69
  ```
42
- # RVM
43
- rvm install 2.2
44
- rvm use 2.2
45
-
46
- # rbenv
47
- rbenv install 2.2.1
48
- rbenv shell 2.2.1
70
+ sudo apt-get install -y ruby-dev libpq-dev libsqlite3-dev nodejs
49
71
  ```
50
72
 
51
- ### On RedHat-based systems
73
+ #### RedHat
74
+
75
+ Run this command to install necessary dependencies:
52
76
 
53
77
  ```
54
78
  sudo yum install -y ruby-devel postgresql-devel sqlite-devel zlib-devel
55
79
  ```
56
80
 
57
- Also, install one of the JavaScript runtimes supported by [execjs]. For
81
+ Then, install one of the JavaScript runtimes supported by [execjs]. For
58
82
  instance, to install node.js:
59
83
 
60
84
  ```
@@ -63,6 +87,14 @@ curl -sL https://rpm.nodesource.com/setup | bash -
63
87
  yum install -y nodejs
64
88
  ```
65
89
 
90
+ ### Installing Ruby (all platforms)
91
+
92
+ shoulda-matchers is only compatible with Ruby 2.x. A `.ruby-version` is included
93
+ in the repo, so if you're using one of the Ruby version manager tools, then you
94
+ should be using (or have been prompted to install) the latest version of Ruby.
95
+ If not, you'll want to do that.
96
+
97
+ [working Ruby environment]: #addendum-setting-up-your-environment
66
98
  [Code of Conduct]: https://thoughtbot.com/open-source-code-of-conduct
67
99
  [code style]: https://github.com/thoughtbot/guides/tree/master/style
68
100
  [execjs]: https://github.com/sstephenson/execjs
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ gem 'pry', github: 'pry/pry'
6
6
  gem 'pry-byebug'
7
7
  gem 'rake', '~> 10.0'
8
8
  gem 'rspec', '~> 3.2'
9
+ gem 'zeus'
9
10
 
10
11
  # YARD
11
12
  gem 'yard'
@@ -30,23 +30,25 @@ GEM
30
30
  yajl-ruby (~> 1.1.0)
31
31
  rake (10.4.2)
32
32
  redcarpet (3.0.0)
33
- rspec (3.3.0)
34
- rspec-core (~> 3.3.0)
35
- rspec-expectations (~> 3.3.0)
36
- rspec-mocks (~> 3.3.0)
37
- rspec-core (3.3.2)
38
- rspec-support (~> 3.3.0)
39
- rspec-expectations (3.3.1)
33
+ rspec (3.4.0)
34
+ rspec-core (~> 3.4.0)
35
+ rspec-expectations (~> 3.4.0)
36
+ rspec-mocks (~> 3.4.0)
37
+ rspec-core (3.4.1)
38
+ rspec-support (~> 3.4.0)
39
+ rspec-expectations (3.4.0)
40
40
  diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.3.0)
42
- rspec-mocks (3.3.2)
41
+ rspec-support (~> 3.4.0)
42
+ rspec-mocks (3.4.0)
43
43
  diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.3.0)
45
- rspec-support (3.3.0)
44
+ rspec-support (~> 3.4.0)
45
+ rspec-support (3.4.1)
46
46
  slop (3.6.0)
47
47
  thor (0.19.1)
48
48
  yajl-ruby (1.1.0)
49
49
  yard (0.8.7.3)
50
+ zeus (0.15.4)
51
+ method_source (>= 0.6.7)
50
52
 
51
53
  PLATFORMS
52
54
  ruby
@@ -62,6 +64,7 @@ DEPENDENCIES
62
64
  redcarpet
63
65
  rspec (~> 3.2)
64
66
  yard
67
+ zeus
65
68
 
66
69
  BUNDLED WITH
67
- 1.10.6
70
+ 1.11.1
data/NEWS.md CHANGED
@@ -1,3 +1,114 @@
1
+ # 3.1.0
2
+
3
+ ### Bug fixes
4
+
5
+ * Update `validate_numericality_of` so that submatchers are applied lazily
6
+ instead of immediately. Previously, qualifiers were order-dependent, meaning
7
+ that if you used `strict` before you used, say, `odd`, then `strict` wouldn't
8
+ actually apply to `odd`. Now the order that you specify qualifiers doesn't
9
+ matter.
10
+
11
+ * *Source: [6c67a5e]*
12
+
13
+ * Fix `allow_value` so that it does not raise an AttributeChangedValueError
14
+ (formerly CouldNotSetAttributeError) when used against an attribute that is an
15
+ enum in an ActiveRecord model.
16
+
17
+ * *Source: [9e8603e]*
18
+
19
+ * Add a `ignoring_interference_by_writer` qualifier to all matchers, not just
20
+ `allow_value`. *This is enabled by default, which means that you should never
21
+ get a CouldNotSetAttributeError again.* (You may get some more information if
22
+ a test fails, however.)
23
+
24
+ * *Source: [1189934], [5532f43]*
25
+ * *Fixes: [#786], [#799], [#801], [#804], [#817], [#841], [#849], [#872],
26
+ [#873], and [#874]*
27
+
28
+ * Fix `validate_numericality_of` so that it does not blow up when used against
29
+ a virtual attribute defined in an ActiveRecord model (that is, an attribute
30
+ that is not present in the database but is defined using `attr_accessor`).
31
+
32
+ * *Source: [#822]*
33
+
34
+ * Update `validate_numericality_of` so that it no longer raises an
35
+ IneffectiveTestError if used against a numeric column.
36
+
37
+ * *Source: [5ed0362]*
38
+ * *Fixes: [#832]*
39
+
40
+ [6c67a5e]: https://github.com/thoughtbot/shoulda-matchers/commit/6c67a5eb0df265d3a565aa7d1a7e2b645051eb5a
41
+ [9e8603e]: https://github.com/thoughtbot/shoulda-matchers/commit/9e8603eb745bfa2a5aea6dfef85adf680d447151
42
+ [1189934]: https://github.com/thoughtbot/shoulda-matchers/commit/118993480604d39c73687d069f7af3726f3e3f3e
43
+ [5532f43]: https://github.com/thoughtbot/shoulda-matchers/commit/5532f4359aa332b10de7d46f876eaffd4a95b5b6
44
+ [#786]: https://github.com/thoughtbot/shoulda-matchers/issues/786
45
+ [#799]: https://github.com/thoughtbot/shoulda-matchers/issues/799
46
+ [#801]: https://github.com/thoughtbot/shoulda-matchers/issues/801
47
+ [#804]: https://github.com/thoughtbot/shoulda-matchers/issues/804
48
+ [#817]: https://github.com/thoughtbot/shoulda-matchers/issues/817
49
+ [#841]: https://github.com/thoughtbot/shoulda-matchers/issues/841
50
+ [#849]: https://github.com/thoughtbot/shoulda-matchers/issues/849
51
+ [#872]: https://github.com/thoughtbot/shoulda-matchers/issues/872
52
+ [#873]: https://github.com/thoughtbot/shoulda-matchers/issues/873
53
+ [#874]: https://github.com/thoughtbot/shoulda-matchers/issues/874
54
+ [#822]: https://github.com/thoughtbot/shoulda-matchers/pull/822
55
+ [5ed0362]: https://github.com/thoughtbot/shoulda-matchers/commit/5ed03624197314865ff5463e473e5e84bb91d9ea
56
+ [#832]: https://github.com/thoughtbot/shoulda-matchers/issues/832
57
+
58
+ ### Features
59
+
60
+ * Add a new qualifier, `ignoring_case_sensitivity`, to `validate_uniqueness_of`.
61
+ This provides a way to test uniqueness of an attribute whose case is
62
+ normalized, either in a custom writer method for that attribute, or in a
63
+ custom `before_validation` callback.
64
+
65
+ * *Source: [#840]*
66
+ * *Fixes: [#836]*
67
+
68
+ [#840]: https://github.com/thoughtbot/shoulda-matchers/pull/840
69
+ [#836]: https://github.com/thoughtbot/shoulda-matchers/issues/836
70
+
71
+ ### Improvements
72
+
73
+ * Improve failure messages and descriptions of all matchers across the board so
74
+ that it is easier to understand what the matcher was doing when it failed.
75
+ (You'll see a huge difference in the output of the numericality and uniqueness
76
+ matchers in particular.)
77
+
78
+ * Matchers now raise an error if any attributes that the matcher is attempting
79
+ to set do not exist on the model.
80
+
81
+ * *Source: [2962112]*
82
+
83
+ * Update `validate_numericality_of` so that it doesn't always run all of the
84
+ submatchers, but stops on the first one that fails. Since failure messages
85
+ now contain information as to what value the matcher set on the attribute when
86
+ it failed, this change guarantees that the correct value will be shown.
87
+
88
+ * *Source: [8e24a6e]*
89
+
90
+ * Continue to detect if attributes change incoming values, but now instead of
91
+ immediately seeing a CouldNotSetAttributeError, you will only be informed
92
+ about it if the test you've written fails.
93
+
94
+ * *Source: [1189934]*
95
+
96
+ * Add an additional check to `define_enum_for` to ensure that the column that
97
+ underlies the enum attribute you're testing is an integer column.
98
+
99
+ * *Source: [68dd70a]*
100
+
101
+ * Add a test for `validate_numericality_of` so that it officially supports money
102
+ columns.
103
+
104
+ * *Source: [a559713]*
105
+ * *Refs: [#841]*
106
+
107
+ [2962112]: https://github.com/thoughtbot/shoulda-matchers/commit/296211211497e624dde87adae68b385ad4cdae3a
108
+ [8e24a6e]: https://github.com/thoughtbot/shoulda-matchers/commit/8e24a6e9b2b147f2c51fb03aa02543f213acab34
109
+ [68dd70a]: https://github.com/thoughtbot/shoulda-matchers/commit/68dd70a23d8997a490683adcd2108a4a5cadf8ba
110
+ [a559713]: https://github.com/thoughtbot/shoulda-matchers/commit/a559713f96303414551c0bc1767fb11eb19bcc5d
111
+
1
112
  # 3.0.1
2
113
 
3
114
  ### Bug fixes
data/README.md CHANGED
@@ -97,7 +97,7 @@ complex, and error-prone.
97
97
  tests that an object forwards messages to other, internal objects by way of
98
98
  delegation.
99
99
 
100
- ## Installation
100
+ ## Getting started
101
101
 
102
102
  ### RSpec
103
103
 
@@ -120,6 +120,42 @@ describe Person do
120
120
  end
121
121
  ```
122
122
 
123
+ #### Availability of matchers in various example groups
124
+
125
+ Since shoulda-matchers provides four categories of matchers, there are four
126
+ different levels where you can use these matchers:
127
+
128
+ * ActiveRecord and ActiveModel matchers are available only in model example
129
+ groups, i.e., those tagged with `type: :model` or in files located under
130
+ `spec/models`.
131
+ * ActionController matchers are available only in controller example groups,
132
+ i.e., those tagged with `type: :controller` or in files located under
133
+ `spec/controllers`.
134
+ * The `route` matcher is available also in routing example groups, i.e., those
135
+ tagged with `type: :routing` or in files located under `spec/routing`.
136
+ * Independent matchers are available in all example groups.
137
+
138
+ **If you are using ActiveModel or ActiveRecord outside of Rails** and you want
139
+ to use model matchers in certain example groups, you'll need to manually include
140
+ them. Here's a good way of doing that:
141
+
142
+ ``` ruby
143
+ RSpec.configure do |config|
144
+ config.include(Shoulda::Matchers::ActiveModel, type: :model)
145
+ config.include(Shoulda::Matchers::ActiveRecord, type: :model)
146
+ end
147
+ ```
148
+
149
+ Then you can say:
150
+
151
+ ``` ruby
152
+ describe MyModel, type: :model do
153
+ # ...
154
+ end
155
+ ```
156
+
157
+ #### `should` vs `is_expected.to`
158
+
123
159
  Note that in this README and throughout the documentation we're using the
124
160
  `should` form of RSpec's one-liner syntax over `is_expected.to`. The `should`
125
161
  form works regardless of how you've configured RSpec -- meaning you can still
@@ -136,12 +172,15 @@ end
136
172
 
137
173
  Shoulda Matchers was originally a component of [Shoulda][shoulda], a gem that
138
174
  also provides `should` and `context` syntax via
139
- [`shoulda-context`][shoulda-context]. For this reason you'll want to include this
140
- gem in your Gemfile instead:
175
+ [`shoulda-context`][shoulda-context].
176
+
177
+ At the moment, `shoulda` has not been updated to support `shoulda-matchers` 3.0,
178
+ so you'll want to add the following to your Gemfile:
141
179
 
142
180
  ```ruby
143
181
  group :test do
144
182
  gem 'shoulda', '~> 3.5'
183
+ gem 'shoulda-matchers', '~> 2.0'
145
184
  end
146
185
  ```
147
186
 
@@ -164,7 +203,8 @@ Before you can use Shoulda Matchers, you'll need to tell it a couple of things:
164
203
  * Which portion of the matchers you want to use
165
204
 
166
205
  You can supply this information by using a configuration block. Place the
167
- following in your test or spec helper:
206
+ following in `rails_helper.rb` (if you're using RSpec) or `test_helper.rb` (if
207
+ you're using Minitest):
168
208
 
169
209
  ``` ruby
170
210
  Shoulda::Matchers.configure do |config|
@@ -185,6 +225,52 @@ Shoulda::Matchers.configure do |config|
185
225
  end
186
226
  ```
187
227
 
228
+ ## Running tests
229
+
230
+ ### Unit tests
231
+
232
+ Unit tests are the most common kind of tests in this gem, and the best way to
233
+ run them is by using [Zeus].
234
+
235
+ You'll want to run `zeus start` in one shell, then in another shell, instead of
236
+ using `rspec` to run tests, you can use `zeus rspec`. So for instance, you might
237
+ say:
238
+
239
+ ```
240
+ zeus rspec spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb
241
+ ```
242
+
243
+ As a shortcut, you can also drop the initial part of the path and say this
244
+ instead:
245
+
246
+ ```
247
+ zeus rspec active_model/validate_inclusion_of_matcher_spec.rb
248
+ ```
249
+
250
+ ### Acceptance tests
251
+
252
+ The gem uses [Appraisal] to test against multiple versions of Rails and Ruby.
253
+ This means that if you're trying to run a single test file, you'll need to
254
+ specify which appraisal to use. For instance, you can't simply say:
255
+
256
+ ```
257
+ rspec spec/acceptance/active_model_integration_spec.rb
258
+ ```
259
+
260
+ Instead, you need to say
261
+
262
+ ```
263
+ bundle exec appraisal 4.2 rspec spec/acceptance/active_model_integration_spec.rb
264
+ ```
265
+
266
+ ### All tests
267
+
268
+ You can run all tests by saying:
269
+
270
+ ```
271
+ bundle exec rake
272
+ ```
273
+
188
274
  ## Generating documentation
189
275
 
190
276
  YARD is used to generate documentation, which can be viewed [online][rubydocs].
@@ -212,7 +298,7 @@ pull request.
212
298
  ## Compatibility
213
299
 
214
300
  Shoulda Matchers is tested and supported against Rails 4.x, RSpec 3.x, Minitest
215
- 5, and Ruby 2.x.
301
+ 5, Minitest 4, and Ruby 2.x.
216
302
 
217
303
  ## Versioning
218
304
 
@@ -221,7 +307,7 @@ Shoulda Matchers follows Semantic Versioning 2.0 as defined at
221
307
 
222
308
  ## License
223
309
 
224
- Shoulda Matchers is copyright © 2006-2015
310
+ Shoulda Matchers is copyright © 2006-2016
225
311
  [thoughtbot, inc](https://thoughtbot.com/). It is free software,
226
312
  and may be redistributed under the terms specified in the
227
313
  [MIT-LICENSE](MIT-LICENSE) file.
@@ -248,3 +334,5 @@ We are [available for hire][hire].
248
334
  [contributors]: https://github.com/thoughtbot/shoulda-matchers/contributors
249
335
  [shoulda]: http://github.com/thoughtbot/shoulda
250
336
  [shoulda-context]: http://github.com/thoughtbot/shoulda-context
337
+ [Zeus]: https://github.com/burke/zeus
338
+ [Appraisal]: https://github.com/thoughtbot/appraisal