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 +4 -4
- data/CHANGELOG.md +4 -0
- data/DEVELOPMENT.md +8 -1
- data/README.md +14 -0
- data/lib/rspec/sleeping_king_studios/configuration.rb +30 -0
- data/lib/rspec/sleeping_king_studios/matchers/built_in/include_matcher.rb +10 -0
- data/lib/rspec/sleeping_king_studios/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27bca27d749c25c4832b3d37afd538134f0ee912
|
4
|
+
data.tar.gz: f6f3b0722eadb234a5aa816e2aac941690c25dc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e989536954b97e1e936ec60fcb7351d5234dcf0ad7ee12e07cbd3495ba0075f42c474e0119d59e0b1491c017056a1868bd2bf6b993c575616b138a35de8c17c
|
7
|
+
data.tar.gz: 8730519c5e59a2a59cd22e30a9aee251cf63330ad17d16f57ae3d7cda414f51fe94cfd32b78eac54e7f567511320573fab3cf313b6de89e22a70983a878046ba
|
data/CHANGELOG.md
CHANGED
data/DEVELOPMENT.md
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# Development Notes
|
2
2
|
|
3
|
-
## Version 2.
|
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?
|
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.
|
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-
|
11
|
+
date: 2016-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|