rspec-sleeping_king_studios 2.0.2 → 2.0.3
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 +4 -5
- data/README.md +2 -2
- data/lib/rspec/sleeping_king_studios/matchers/base_matcher.rb +0 -2
- data/lib/rspec/sleeping_king_studios/matchers/built_in/include.rb +42 -15
- 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: f3427b043889c866103ff0e5a58222621798f825
|
4
|
+
data.tar.gz: 3f7ea93de6bc4be9d9c6a5687be25eb57b406e78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5696860258e7bb62a86b97af732f8cab837bca81f6665cffb46dcf28ec407b54031e8c6d28029762b8039b5eab220db4515d39c35773593946ad6d42b8b2af9c
|
7
|
+
data.tar.gz: ec5dcd4a1a3ecd74e7dbf88e3761a27ed3e5e46fb295709a64b54a9f4b27cc9632311ef6883add79968104747c6d67a6eaa5654a135026c805f71c68e49326fd
|
data/CHANGELOG.md
CHANGED
data/DEVELOPMENT.md
CHANGED
@@ -4,12 +4,11 @@
|
|
4
4
|
|
5
5
|
### Release Candidate
|
6
6
|
|
7
|
-
### 2.0.
|
7
|
+
### 2.0.3
|
8
8
|
|
9
|
-
- Add
|
10
|
-
-
|
11
|
-
-
|
12
|
-
- Add additional syntax (see above) to #be_constructible. DONE
|
9
|
+
- Add support for RSpec 3.3
|
10
|
+
- Transition from RSpec::Matchers::Pretty to RSpec::Matchers::EnglishPhrasing?
|
11
|
+
- Support new implementation of RSpec::Matchers::BuiltIn::Include
|
13
12
|
|
14
13
|
### 2.1.0+
|
15
14
|
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ A collection of matchers and extensions to ease TDD/BDD using RSpec. Extends bui
|
|
4
4
|
|
5
5
|
## Support
|
6
6
|
|
7
|
-
RSpec::SleepingKingStudios is tested against RSpec 3.0, 3.1, and 3.
|
7
|
+
RSpec::SleepingKingStudios is tested against RSpec 3.0, 3.1, 3.2, and 3.3.
|
8
8
|
|
9
9
|
Currently, the following versions of Ruby are officially supported:
|
10
10
|
|
@@ -12,7 +12,7 @@ Currently, the following versions of Ruby are officially supported:
|
|
12
12
|
* 2.1
|
13
13
|
* 2.2
|
14
14
|
|
15
|
-
If you require a previous version of Ruby or RSpec, the 1.0 branch supports Ruby 1.9.3 and RSpec 2: `gem "rspec-sleeping_king_studios", "~> 1.0.1"`.
|
15
|
+
If you require a previous version of Ruby or RSpec, the 1.0 branch supports Ruby 1.9.3 and RSpec 2: `gem "rspec-sleeping_king_studios", "~> 1.0.1"`. However, changes from 2.0 and higher will not be backported.
|
16
16
|
|
17
17
|
## Contribute
|
18
18
|
|
@@ -21,7 +21,22 @@ module RSpec::SleepingKingStudios::Matchers::BuiltIn
|
|
21
21
|
|
22
22
|
# @api private
|
23
23
|
#
|
24
|
-
#
|
24
|
+
# @return [Boolean]
|
25
|
+
def matches?(actual)
|
26
|
+
perform_match(actual) { |v| v }
|
27
|
+
end # method matches?
|
28
|
+
|
29
|
+
# @api private
|
30
|
+
#
|
31
|
+
# @return [Boolean]
|
32
|
+
def does_not_match?(actual)
|
33
|
+
perform_match(actual) { |v| !v }
|
34
|
+
end # method does_not_match?
|
35
|
+
|
36
|
+
# @api private
|
37
|
+
#
|
38
|
+
# Converts the expected item to a human-readable string. Retained for
|
39
|
+
# pre-3.3 compatibility.
|
25
40
|
def to_word expected_item
|
26
41
|
case
|
27
42
|
when is_matcher_with_description?(expected_item)
|
@@ -35,7 +50,7 @@ module RSpec::SleepingKingStudios::Matchers::BuiltIn
|
|
35
50
|
|
36
51
|
# (see BaseMatcher#failure_message)
|
37
52
|
def failure_message
|
38
|
-
message = super
|
53
|
+
message = super.sub ':__block_comparison__', 'an item matching the block'
|
39
54
|
|
40
55
|
message << ", but it does not respond to `include?`" unless actual.respond_to?(:include?) || message =~ /does not respond to/
|
41
56
|
|
@@ -44,7 +59,7 @@ module RSpec::SleepingKingStudios::Matchers::BuiltIn
|
|
44
59
|
|
45
60
|
# (see BaseMatcher#failure_message_when_negated)
|
46
61
|
def failure_message_when_negated
|
47
|
-
message = super
|
62
|
+
message = super.sub ':__block_comparison__', 'an item matching the block'
|
48
63
|
|
49
64
|
message << ", but it does not respond to `include?`" unless actual.respond_to?(:include?) || message =~ /does not respond to/
|
50
65
|
|
@@ -53,28 +68,40 @@ module RSpec::SleepingKingStudios::Matchers::BuiltIn
|
|
53
68
|
|
54
69
|
private
|
55
70
|
|
56
|
-
|
57
|
-
|
71
|
+
# @api private
|
72
|
+
def perform_match(actual, &block)
|
73
|
+
@actual = actual
|
74
|
+
@divergent_items = excluded_from_actual(&block)
|
75
|
+
actual.respond_to?(:include?) && @divergent_items.empty?
|
76
|
+
end # method perform_match
|
77
|
+
|
78
|
+
# @api private
|
79
|
+
def excluded_from_actual
|
80
|
+
return [] unless @actual.respond_to?(:include?)
|
58
81
|
|
59
|
-
expected.
|
82
|
+
expected.inject([]) do |memo, expected_item|
|
60
83
|
if comparing_proc?(expected_item)
|
61
|
-
actual_matches_proc?(expected_item)
|
84
|
+
memo << :__block_comparison__ unless yield actual_matches_proc?(expected_item)
|
62
85
|
elsif comparing_hash_to_a_subset?(expected_item)
|
63
|
-
expected_item.
|
64
|
-
actual_hash_includes?(key, value)
|
65
|
-
end
|
86
|
+
expected_item.each do |(key, value)|
|
87
|
+
memo << { key => value } unless yield actual_hash_includes?(key, value)
|
88
|
+
end # each
|
66
89
|
elsif comparing_hash_keys?(expected_item)
|
67
|
-
actual_hash_has_key?(expected_item)
|
90
|
+
memo << expected_item unless yield actual_hash_has_key?(expected_item)
|
68
91
|
else
|
69
|
-
actual_collection_includes?(expected_item)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
92
|
+
memo << expected_item unless yield actual_collection_includes?(expected_item)
|
93
|
+
end # if-elsif-else
|
73
94
|
|
95
|
+
memo
|
96
|
+
end # inject
|
97
|
+
end # method excluded_from_actual
|
98
|
+
|
99
|
+
# @api private
|
74
100
|
def actual_matches_proc? expected_item
|
75
101
|
!!actual.detect(&expected_item)
|
76
102
|
end # method actual_matches_proc?
|
77
103
|
|
104
|
+
# @api private
|
78
105
|
def comparing_proc? expected_item
|
79
106
|
expected_item.is_a?(Proc)
|
80
107
|
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.0.
|
4
|
+
version: 2.0.3
|
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: 2015-
|
11
|
+
date: 2015-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|