diff_matcher 2.4.1 → 2.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 263716b9ab7bbdc763e3ee639f6a8ecdcca95661
4
- data.tar.gz: 193438c3843d95b7dd6d1d311ea7f5da4c98d6e2
3
+ metadata.gz: 2868c9df6fcb0629a3b11aa0ff612fec55d83c7e
4
+ data.tar.gz: db68ce3ce7834da9517bea0b7987537f3cbb3e85
5
5
  SHA512:
6
- metadata.gz: abbfb0e8738b88efc5a8d5546cb02e7ffc845c76255d7cf1542391c8140abdec7b21d072cb9a913d7d75f876b47a21f7e6b2a71e80c99e0f9490ada00f922571
7
- data.tar.gz: f1d2222a64acc05739651604c378a4a9f33998d91af454f3d0c3805fa02bc0b1d7ec81032ec284da8c0c7afef5d845e46eeac81ad40eb60a30a22a842c3a1192
6
+ metadata.gz: 57f3e4075c94f1ebf5f4ce3862df3c7ee6e32a39ee27eba9f37f65cd6d377686dfda4bcd8a62ae2a0379ad9780c11555dabc43e0e9faa03ea4aa190779c67c3f
7
+ data.tar.gz: 0f5752354f037eed868ccf50fab9c0e84c6593cb710effa098555c73aadc89327bd110cd30d5c2e64360dcf3a42020ab0ab985ae7633306f08a845e6ae30cc00
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### v2.5.0
4
+
5
+ * Add rspec custom matcher `be_matching`
6
+
3
7
  ### v2.4.1
4
8
 
5
9
  * BUGFIX match values where their classes are different but one is a subclass of the other
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.authors = ["locochris"]
11
11
  s.email = "chris@locomote.com.au"
12
12
  s.homepage = "http://github.com/diff-matcher/diff_matcher"
13
+ s.licenses = %w{ BSD MIT }
13
14
 
14
15
  s.summary = %q{Generates a diff by matching against user-defined matchers written in ruby.}
15
16
  s.description = <<EOF
@@ -0,0 +1,3 @@
1
+ require 'rspec/core'
2
+ require 'diff_matcher'
3
+ require 'diff_matcher/rspec/matchers/diff_matcher'
@@ -0,0 +1,31 @@
1
+ # Uses the diff_matcher gem to provide advanced matching abilities, along with nice visual representation of the
2
+ # diff between actual and expected. The functionality set is very helpful for comparing hashes.
3
+ #
4
+ # Usage examples:
5
+ # it { should be_matching(my_var) }
6
+ # it { should be_matching(my_var).with_options(ignore_additional: true) }
7
+ #
8
+ # Options: by default, color_enabled is controlled by Rspec, and quiet is set to true.
9
+ RSpec::Matchers.define :be_matching do |expected|
10
+ match do |actual|
11
+ options = { :color_enabled => RSpec::configuration.color_enabled?, :quiet => true }.merge(@options || {})
12
+ @difference = DiffMatcher::Difference.new(expected, actual, options)
13
+ @difference.matching?
14
+ end
15
+
16
+ chain :with_options do |options|
17
+ @options = options
18
+ end
19
+
20
+ failure_message_for_should do |actual|
21
+ "diff is:\n" + @difference.to_s
22
+ end
23
+
24
+ failure_message_for_should_not do |actual|
25
+ "diff is:\n" + @difference.to_s
26
+ end
27
+
28
+ description do
29
+ "match via DiffMatcher #{expected}" + (@options.blank? ? '' : " with options: #{@options}")
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module DiffMatcher
2
- VERSION = "2.4.1"
2
+ VERSION = "2.5.0"
3
3
  end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+ require 'diff_matcher/rspec'
3
+
4
+ describe :be_matching do
5
+ it "should call DiffMatcher::Difference" do
6
+ DiffMatcher::Difference.should_receive(:new).with(
7
+ :expected, :actual, { :color_enabled => RSpec::configuration.color_enabled?, :quiet => true }.merge({ :foo => 'bar' })
8
+ ).and_return(double(:matching? => true))
9
+
10
+ :actual.should be_matching(:expected).with_options :foo => 'bar'
11
+ end
12
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diff_matcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - locochris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-28 00:00:00.000000000 Z
11
+ date: 2013-07-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  DiffMatcher matches input data (eg. from a JSON API) against values,
@@ -24,7 +24,6 @@ files:
24
24
  - .travis.yml
25
25
  - CHANGELOG.md
26
26
  - Gemfile
27
- - License.txt
28
27
  - README.md
29
28
  - Rakefile
30
29
  - TODO.txt
@@ -34,11 +33,16 @@ files:
34
33
  - lib/diff_matcher.rb
35
34
  - lib/diff_matcher/difference.rb
36
35
  - lib/diff_matcher/escape_to_html.rb
36
+ - lib/diff_matcher/rspec.rb
37
+ - lib/diff_matcher/rspec/matchers/diff_matcher.rb
37
38
  - lib/diff_matcher/version.rb
38
39
  - spec/diff_matcher/difference_spec.rb
40
+ - spec/diff_matcher/rspec/matchers/diff_matcher_spec.rb
39
41
  - spec/spec_helper.rb
40
42
  homepage: http://github.com/diff-matcher/diff_matcher
41
- licenses: []
43
+ licenses:
44
+ - BSD
45
+ - MIT
42
46
  metadata: {}
43
47
  post_install_message:
44
48
  rdoc_options: []
@@ -62,4 +66,5 @@ specification_version: 4
62
66
  summary: Generates a diff by matching against user-defined matchers written in ruby.
63
67
  test_files:
64
68
  - spec/diff_matcher/difference_spec.rb
69
+ - spec/diff_matcher/rspec/matchers/diff_matcher_spec.rb
65
70
  - spec/spec_helper.rb
@@ -1,22 +0,0 @@
1
- (The MIT License)
2
-
3
- Copyright (c) 2011 PlayUp
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.