rspec-sleeping_king_studios 2.2.1 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a624525849f4ac71e4e9379c06485922a45ebcf3
4
- data.tar.gz: d0f25ed5326bf5622fbe7f6ecf5b34876137795b
3
+ metadata.gz: 27bca27d749c25c4832b3d37afd538134f0ee912
4
+ data.tar.gz: f6f3b0722eadb234a5aa816e2aac941690c25dc3
5
5
  SHA512:
6
- metadata.gz: a074ea75dd5cb71099993b2f973e1d597a64e8383a36e57b781524ee4c57c7b3ef961a59a5f16bd296c658e10a8b22eed05f424b8642d0a08d9d5a7e1dd3575f
7
- data.tar.gz: 6523220cde82b00c49377c75f529953f2ff4b92414bf5ba7395e3724a2ec27bdb62c2640e6ac2e78650b6f1aa1629afd00a230c64c4e64517427e366fbe859b8
6
+ metadata.gz: 6e989536954b97e1e936ec60fcb7351d5234dcf0ad7ee12e07cbd3495ba0075f42c474e0119d59e0b1491c017056a1868bd2bf6b993c575616b138a35de8c17c
7
+ data.tar.gz: 8730519c5e59a2a59cd22e30a9aee251cf63330ad17d16f57ae3d7cda414f51fe94cfd32b78eac54e7f567511320573fab3cf313b6de89e22a70983a878046ba
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.2.2
4
+
5
+ Added configuration option to catch empty #include matchers.
6
+
3
7
  ## 2.2.1
4
8
 
5
9
  Fixed dependency on a pre-release SleepingKingStudios::Tools.
data/DEVELOPMENT.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Development Notes
2
2
 
3
- ## Version 2.2.1
3
+ ## Version 2.3
4
4
 
5
5
  ### Features
6
6
 
7
7
  - Alias `have_constant` as `define_constant`.
8
+ - Alias #immutable as #frozen.
8
9
  - Also alias shared examples.
9
10
  - Implement RespondToMatcher#with_at_least(N).arguments, equivalent to with(N).arguments.and_unlimited_arguments.
10
11
  - Revisit failure messages for #respond_to, #be_constructible - see #received/#have_received for example?
@@ -15,8 +16,14 @@
15
16
  - Resolve Aruba deprecation warnings.
16
17
  - Run each file individually as CI step.
17
18
 
19
+ ### Bug Fixes
20
+
21
+ - false negative on #alias_method?
22
+ - compare via Method#source_location equality and Method#original_name is expected?
23
+
18
24
  ### Features
19
25
 
26
+ - let?(:name) { } # Defines a memoized helper, but only if one is not already defined.
20
27
  - Add spy+matcher for expect(my_object, :my_method).to have_changed ?
21
28
  - Add 'should have class reader/writer/property' shared examples.
22
29
  - Add 'should have private reader/writer/property' shared examples.
data/README.md CHANGED
@@ -66,6 +66,20 @@ This option is used with the RSpec matcher examples (see Examples, below), and d
66
66
 
67
67
  #### Matchers
68
68
 
69
+ ##### Allow Empty Include Matchers
70
+
71
+ RSpec.configure do |config|
72
+ config.sleeping_king_studios do |config|
73
+ config.matchers do |config|
74
+ config.allow_empty_include_matchers = false
75
+ end # config
76
+ end # config
77
+ end # config
78
+
79
+ This option is used with the IncludeMatcher (see `#include`, below). If this option is set to false, an ArgumentError will be raised when attempting to instantiate an IncludeMatcher without any expectations.
80
+
81
+ This prevents an insidious bug when using the `do..end` block syntax to create a block expectation while the matcher macro is itself an argument to another function, such as ExpectationTarget#to. This bug causes the block to be silently ignored and any enumerable object to match against the matcher, even an empty object.
82
+
69
83
  ##### Strict Predicate Matching
70
84
 
71
85
  RSpec.configure do |config|
@@ -69,6 +69,35 @@ module RSpec::SleepingKingStudios
69
69
 
70
70
  # Configuration options for RSpec::SleepingKingStudios::Matchers.
71
71
  class Matchers
72
+ # Checks whether the #include matcher can be instantiated without an
73
+ # expectation object or block.
74
+ #
75
+ # @return [Boolean] True if the empty include matchers are permitted,
76
+ # otherwise false.
77
+ def allow_empty_include_matchers
78
+ value = @allow_empty_include_matchers
79
+
80
+ value.nil? ? true : value
81
+ end # method allow_empty_include_matchers
82
+ alias_method :allow_empty_include_matchers?, :allow_empty_include_matchers
83
+
84
+ # Sets whether the #include matcher can be instantiated without an
85
+ # expectation object or block. If this option is set to false, an
86
+ # ArgumentError will be raised when attempting to instantiate an
87
+ # IncludeMatcher without any expectations.
88
+ #
89
+ # This prevents an insidious bug when using the do..end block syntax to
90
+ # create a block expectation while the matcher macro is itself an argument
91
+ # to another function, such as ExpectationTarget#to. This bug causes the
92
+ # block to be silently ignored and any enumerable object to match against
93
+ # the matcher, even an empty object.
94
+ #
95
+ # @return [Boolean] True if the empty include matchers are permitted,
96
+ # otherwise false.
97
+ def allow_empty_include_matchers= value
98
+ @allow_empty_include_matchers = !!value
99
+ end # method allow_empty_include_matchers
100
+
72
101
  # Checks whether predicates are matched "strictly", meaning that they must
73
102
  # return either true or false.
74
103
  #
@@ -77,6 +106,7 @@ module RSpec::SleepingKingStudios
77
106
  def strict_predicate_matching
78
107
  @strict_predicate_matching ||= false
79
108
  end # method strict_predicate_matching
109
+ alias_method :strict_predicate_matching?, :strict_predicate_matching
80
110
 
81
111
  # Sets whether predicates are matched "strictly", meaning that they must
82
112
  # return either true or false.
@@ -19,6 +19,12 @@ module RSpec::SleepingKingStudios::Matchers::BuiltIn
19
19
  def initialize *expected, &block
20
20
  expected << block if block_given?
21
21
 
22
+ if expected.empty? && !allow_empty_matcher?
23
+ raise ArgumentError,
24
+ 'must specify an item expectation',
25
+ caller
26
+ end # if
27
+
22
28
  super *expected
23
29
  end # constructor
24
30
 
@@ -81,6 +87,10 @@ module RSpec::SleepingKingStudios::Matchers::BuiltIn
81
87
  end # if-else
82
88
  end # method actual_matches_proc?
83
89
 
90
+ def allow_empty_matcher?
91
+ RSpec.configure { |config| config.sleeping_king_studios.matchers }.allow_empty_include_matchers?
92
+ end # method strict_matching?
93
+
84
94
  def comparing_proc? expected_item
85
95
  expected_item.is_a?(Proc)
86
96
  end # method comparing_proc?
@@ -13,7 +13,7 @@ module RSpec
13
13
  # Minor version.
14
14
  MINOR = 2
15
15
  # Patch version.
16
- PATCH = 1
16
+ PATCH = 2
17
17
  # Prerelease version.
18
18
  PRERELEASE = nil
19
19
  # Build metadata.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-sleeping_king_studios
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob "Merlin" Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-08 00:00:00.000000000 Z
11
+ date: 2016-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec