minitest-expect_hashkeys 0.0.1
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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/lib/minitest/expect_hashkeys.rb +21 -0
- data/lib/minitest/expect_hashkeys/version.rb +5 -0
- data/minitest-expect_hashkeys.gemspec +22 -0
- data/test/expect_hashkeys_test.rb +26 -0
- data/test/minitest_helper.rb +2 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 044fa6d3d48b60449e25ebabc042edd24490522a
|
4
|
+
data.tar.gz: a1c590d2678ff5aea99edafa18411fc0bd3235ae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9d6b512fe02b210bdf682e575c8520e22475ae68157de7e7d3b4231d4f496d0bdcad14096a6b91cf4d660ef09a59a035d730f81090359dbe7c256a362b0dc5a5
|
7
|
+
data.tar.gz: 2389c03ed89ebb341b4c3c2d0d1dcd8f6d7ded1bef8d6a1a353ff3ce49f407e1c2e19779c55226d01509de989909d3873bab844f7ed29e6a085be320b2370ed0
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 John Stewart
|
2
|
+
|
3
|
+
MIT License
|
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
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Minitest::Expect::Hashkeys
|
2
|
+
|
3
|
+
Add a simple assertion to compare the keys of two (possibly deep) hashes
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'minitest-expect_hashkeys'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install minitest-expect_hashkeys
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
assert_deep_hash_key_equality(expected_hash, actual_hash)
|
24
|
+
|
25
|
+
OR
|
26
|
+
|
27
|
+
actual.must_have_deep_hash_key_equality expected
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it ( https://github.com/[my-github-username]/minitest-expect-hashkeys/fork )
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "minitest/expect_hashkeys/version"
|
2
|
+
|
3
|
+
module Minitest::Assertions
|
4
|
+
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def assert_deep_hash_key_equality(expected, actual, message = nil)
|
8
|
+
actual.keys.sort.must_equal(expected.keys.sort, message || "expected #{actual.class} #{actual} to have same keys as Hash #{expected}")
|
9
|
+
expected.each do |key, value|
|
10
|
+
if value.is_a? Hash
|
11
|
+
if actual[key].is_a?(Hash)
|
12
|
+
assert_deep_hash_key_equality(value, actual[key])
|
13
|
+
else
|
14
|
+
flunk("expected Hash #{value}, got #{actual[key]}")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Hash.infect_an_assertion :assert_deep_hash_key_equality, :must_have_deep_hash_key_equality
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'minitest/expect_hashkeys/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "minitest-expect_hashkeys"
|
8
|
+
spec.version = Minitest::ExpectHashkeys::VERSION
|
9
|
+
spec.authors = ["John Stewart"]
|
10
|
+
spec.email = ["lead.j2ee.engineer@gmail.com"]
|
11
|
+
spec.summary = %q{Simple minitest assertion to compare keys of nested Hashes}
|
12
|
+
spec.homepage = "https://github.com/johnsinco/minitest-expect_hashkeys"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency "minitest", "~> 5.5"
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe "assert_deep_hash_key_equality" do
|
4
|
+
it "exists" do
|
5
|
+
exp = {a: 1}
|
6
|
+
act = {a: 1}
|
7
|
+
assert_deep_hash_key_equality(exp, act)
|
8
|
+
end
|
9
|
+
it "is equal for a simple hash" do
|
10
|
+
exp = {a: '1', b: '2', c: 3}
|
11
|
+
assert_deep_hash_key_equality(exp, exp)
|
12
|
+
l = lambda { assert_deep_hash_key_equality(exp, {d: 1}) }
|
13
|
+
error = assert_raises(Minitest::Assertion, &l)
|
14
|
+
error.message.must_match(/have same keys/)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "is equal for a nested hash" do
|
18
|
+
exp = {a: 1, b: '2',
|
19
|
+
c: {d: '3', e: 'four'}
|
20
|
+
}
|
21
|
+
assert_deep_hash_key_equality(exp, exp)
|
22
|
+
l = lambda { assert_deep_hash_key_equality(exp, {a: 1, b: {d: '3'}}) }
|
23
|
+
error = assert_raises(Minitest::Assertion, &l)
|
24
|
+
error.message.must_match(/have same keys/)
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-expect_hashkeys
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Stewart
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- lead.j2ee.engineer@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/minitest/expect_hashkeys.rb
|
68
|
+
- lib/minitest/expect_hashkeys/version.rb
|
69
|
+
- minitest-expect_hashkeys.gemspec
|
70
|
+
- test/expect_hashkeys_test.rb
|
71
|
+
- test/minitest_helper.rb
|
72
|
+
homepage: https://github.com/johnsinco/minitest-expect_hashkeys
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.4.3
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Simple minitest assertion to compare keys of nested Hashes
|
96
|
+
test_files:
|
97
|
+
- test/expect_hashkeys_test.rb
|
98
|
+
- test/minitest_helper.rb
|
99
|
+
has_rdoc:
|