mumukit-core 1.0.1 → 1.1.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: 467ae6e58f5ea9c2b81abc793f26c9a0f19ac743
4
- data.tar.gz: ebaa76f63eb42f336b8384531aee4e34cc9c9ac7
3
+ metadata.gz: 7d29995e68bef879dab6d23d988cf2d71fb2f6f9
4
+ data.tar.gz: cc2f8ff45f2380a9b8414b5e955b386e3fa9c8fd
5
5
  SHA512:
6
- metadata.gz: 23915e5e3e682e7a83d28bda8aac0439caf38fdf23963530c50817565ad55abb235476482b7b17f64c6b27b200dc1413baffd48838ee34df3f46d772d434130e
7
- data.tar.gz: 8e32e29269281978a51685acb6537ebf293dfc0207ad1bdcf7f587a09392ffad1af1972b3a9430b11927c164b270af6675220afbe9f1deb42bbf4d0c97253289
6
+ metadata.gz: 352a3b7d13c68912d9a84973594cda7dad82a7508857bd8f7eff139fdb41866eee3ba6632a859c2f920ec2a10b24afcc3e1b4bf075faad53c2e0a57cab3cbb2d
7
+ data.tar.gz: 703f21b0ed2c80d57ca4ea29cb2d70a1596511b844e841051ec6a1ff194dda1f7e777e27de1f0e2f1217ef7169d06d793b53838b34f429ad4eefc237f725d4be
@@ -1,2 +1,34 @@
1
- require_relative './rspec/json_like'
2
- require_relative './rspec/json_eq'
1
+ [:json_eq, :json_like].each do |it|
2
+
3
+ def as_matcher_json(obj, options = {})
4
+ new_options = options.with_indifferent_access
5
+ new_options['only'] = [*new_options['only']].map &:to_s if new_options['only']
6
+ new_options['except'] = [*new_options['except']].map &:to_s if new_options['except']
7
+ if obj.instance_of? String
8
+ JSON.parse(obj).as_json new_options
9
+ else
10
+ JSON.parse(JSON.unparse obj).as_json new_options
11
+ end
12
+ end
13
+
14
+ RSpec::Matchers.define it do |expected, options={}|
15
+ match do |actual|
16
+ as_matcher_json(actual, options) == as_matcher_json(expected, options)
17
+ end
18
+
19
+ failure_message_for_should do |actual|
20
+ <<-EOS
21
+ expected: #{as_matcher_json(expected, options)} (#{expected.class})
22
+ got: #{as_matcher_json(actual, options)} (#{actual.class})
23
+ EOS
24
+ end
25
+
26
+ failure_message_for_should_not do |actual|
27
+ <<-EOS
28
+ expected: value != #{as_matcher_json(expected, options)} (#{expected.class})
29
+ got: #{as_matcher_json(actual, options)} (#{actual.class})
30
+ EOS
31
+ end
32
+ end
33
+
34
+ end
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  module Core
3
- VERSION = '1.0.1'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumukit-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-09 00:00:00.000000000 Z
11
+ date: 2017-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -143,8 +143,6 @@ files:
143
143
  - lib/mumukit/core/regexp.rb
144
144
  - lib/mumukit/core/request.rb
145
145
  - lib/mumukit/core/rspec.rb
146
- - lib/mumukit/core/rspec/json_eq.rb
147
- - lib/mumukit/core/rspec/json_like.rb
148
146
  - lib/mumukit/core/string.rb
149
147
  - lib/mumukit/core/version.rb
150
148
  - lib/mumukit/core/yaml.rb
@@ -169,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
167
  version: '0'
170
168
  requirements: []
171
169
  rubyforge_project:
172
- rubygems_version: 2.6.13
170
+ rubygems_version: 2.6.14
173
171
  signing_key:
174
172
  specification_version: 4
175
173
  summary: Ruby core extensions for mumuki on top of active support
@@ -1,5 +0,0 @@
1
- RSpec::Matchers.define :json_eq do |expected_json_hash|
2
- match do |actual_json|
3
- expected_json_hash.with_indifferent_access == ActiveSupport::JSON.decode(actual_json)
4
- end
5
- end
@@ -1,20 +0,0 @@
1
- RSpec::Matchers.define :json_like do |expected, options={}|
2
- except = options[:except] || []
3
- match do |actual|
4
- actual.as_json.with_indifferent_access.except(except) == expected.as_json.with_indifferent_access
5
- end
6
-
7
- failure_message_for_should do |actual|
8
- <<-EOS
9
- expected: #{expected.as_json} (#{expected.class})
10
- got: #{actual.as_json} (#{actual.class})
11
- EOS
12
- end
13
-
14
- failure_message_for_should_not do |actual|
15
- <<-EOS
16
- expected: value != #{expected.as_json} (#{expected.class})
17
- got: #{actual.as_json} (#{actual.class})
18
- EOS
19
- end
20
- end