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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 001e7809e65b97646a63c8a663bcba7472df5327
4
- data.tar.gz: a0309fd6b2ace7e0cceb015929d0b3449cb327df
3
+ metadata.gz: f3427b043889c866103ff0e5a58222621798f825
4
+ data.tar.gz: 3f7ea93de6bc4be9d9c6a5687be25eb57b406e78
5
5
  SHA512:
6
- metadata.gz: 23957e513898499443a028ed1aadbed73aa31b19a7deec654988c418710c25cc7362791ea627344a1b2ed87ff25bf4580b4b819d2a9f553f5529da4874245296
7
- data.tar.gz: 4ff7d63a7da8145d064e6c7902be789332ffd6613aa52c51db8540b2639a4c16e671ce5c7322f04fa51cdea4670b46749a80f1a31bb42c04910da961b110f6a7
6
+ metadata.gz: 5696860258e7bb62a86b97af732f8cab837bca81f6665cffb46dcf28ec407b54031e8c6d28029762b8039b5eab220db4515d39c35773593946ad6d42b8b2af9c
7
+ data.tar.gz: ec5dcd4a1a3ecd74e7dbf88e3761a27ed3e5e46fb295709a64b54a9f4b27cc9632311ef6883add79968104747c6d67a6eaa5654a135026c805f71c68e49326fd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.3
4
+
5
+ Internal update to add support for RSpec 3.3.
6
+
3
7
  ## 2.0.2
4
8
 
5
9
  #### `construct` and `respond_to` Matchers
data/DEVELOPMENT.md CHANGED
@@ -4,12 +4,11 @@
4
4
 
5
5
  ### Release Candidate
6
6
 
7
- ### 2.0.2
7
+ ### 2.0.3
8
8
 
9
- - Add additional syntax option for #respond_to keywords, e.g. 'expect().to respond_to(:method).with(1).arguments.and_keywords(:foo, :bar)' DONE
10
- - `expect().to respond_to().with_keywords()'
11
- - `expect().to respond_to().with_arbitrary_keywords'
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.2.
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
 
@@ -7,8 +7,6 @@ module RSpec::SleepingKingStudios::Matchers
7
7
  #
8
8
  # @since 1.0.0
9
9
  class BaseMatcher
10
- include RSpec::Matchers::Pretty
11
-
12
10
  attr_reader :actual
13
11
 
14
12
  # A short string that describes the purpose of the matcher.
@@ -21,7 +21,22 @@ module RSpec::SleepingKingStudios::Matchers::BuiltIn
21
21
 
22
22
  # @api private
23
23
  #
24
- # Converts the expected item to a human-readable string.
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
- def perform_match(predicate, hash_subset_predicate)
57
- return false unless actual.respond_to?(:include?)
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.__send__(predicate) do |expected_item|
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.__send__(hash_subset_predicate) do |(key, value)|
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?
@@ -13,7 +13,7 @@ module RSpec
13
13
  # Minor version.
14
14
  MINOR = 0
15
15
  # Patch version.
16
- PATCH = 2
16
+ PATCH = 3
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.0.2
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-06-03 00:00:00.000000000 Z
11
+ date: 2015-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec