equalizer 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/.ruby-version +1 -0
- data/.travis.yml +10 -20
- data/Gemfile +2 -12
- data/Rakefile +3 -32
- data/config/devtools.yml +2 -0
- data/config/flay.yml +4 -0
- data/config/flog.yml +3 -0
- data/config/mutant.yml +2 -0
- data/config/reek.yml +105 -0
- data/config/rubocop.yml +94 -33
- data/config/yardstick.yml +34 -0
- data/equalizer.gemspec +3 -3
- data/lib/equalizer.rb +6 -4
- data/lib/equalizer/version.rb +1 -1
- data/spec/spec_helper.rb +6 -1
- data/spec/unit/equalizer/included_spec.rb +2 -2
- data/spec/unit/equalizer/methods/equality_operator_spec.rb +21 -1
- data/spec/unit/equalizer/universal_spec.rb +11 -12
- metadata +50 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
|
4
|
-
|
5
|
-
SHA512:
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dcbcd58301e2a2cef28808c325df7a4c51eb7714
|
4
|
+
data.tar.gz: e0790eb41a358a41e568eb3393e35fb424c1abc5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6ef3745470a9bb334dfaa746c0246d4255f960fdcd9b4bac246ebcac5865e241ac415831a092c6997aec276db2fb0d77e8009fac76b46e694233ae99b0c92077
|
7
|
+
data.tar.gz: dc186fa2bd0482794f6f63c84db4f6bddee1eaf4c696ab8bae031e44e4656c1800430bc73b1ef1aeeb776b4343a8ec079e78efb4b85e09edb44f42c2c818a07b
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.2.1
|
data/.travis.yml
CHANGED
@@ -1,31 +1,21 @@
|
|
1
|
-
before_install: gem update bundler
|
2
|
-
cache: bundler
|
3
|
-
sudo: false
|
4
|
-
env:
|
5
|
-
global:
|
6
|
-
- JRUBY_OPTS="$JRUBY_OPTS --debug" # for simplecov
|
7
1
|
language: ruby
|
2
|
+
bundler_args: --without yard guard benchmarks
|
8
3
|
script: "bundle exec rake ci"
|
4
|
+
cache: bundler
|
5
|
+
sudo: false
|
9
6
|
rvm:
|
10
|
-
-
|
11
|
-
- 1.9.3
|
12
|
-
- 2.0.0
|
7
|
+
- 2.0
|
13
8
|
- 2.1
|
14
9
|
- 2.2
|
15
|
-
- jruby-18mode
|
16
|
-
- jruby-19mode
|
17
|
-
- jruby-head
|
18
|
-
- rbx-2
|
19
|
-
- ree
|
20
10
|
- ruby-head
|
11
|
+
- rbx-2
|
21
12
|
matrix:
|
13
|
+
include:
|
14
|
+
- rvm: jruby
|
15
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug --2.0" # for simplecov
|
16
|
+
- rvm: jruby-head
|
17
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug --2.0" # for simplecov
|
22
18
|
allow_failures:
|
23
19
|
- rvm: ruby-head
|
24
20
|
- rvm: jruby-head
|
25
21
|
fast_finish: true
|
26
|
-
notifications:
|
27
|
-
irc:
|
28
|
-
channels:
|
29
|
-
- irc.freenode.org#rom-rb
|
30
|
-
on_success: never
|
31
|
-
on_failure: change
|
data/Gemfile
CHANGED
@@ -2,18 +2,8 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
group :test do
|
8
|
-
gem 'backports'
|
9
|
-
gem 'coveralls'
|
10
|
-
gem 'json', :platforms => [:ruby_19]
|
11
|
-
gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
|
12
|
-
gem 'rest-client', '~> 1.6.0', :platforms => [:jruby, :ruby_18]
|
13
|
-
gem 'rspec', '~> 3.0'
|
14
|
-
gem 'rubocop', '>= 0.25', :platforms => [:ruby_19, :ruby_20, :ruby_21, :ruby_22]
|
15
|
-
gem 'simplecov', '>= 0.9'
|
16
|
-
gem 'yardstick'
|
5
|
+
group :development, :test do
|
6
|
+
gem 'devtools', '= 0.0.2', git: 'https://github.com/mbj/devtools.git'
|
17
7
|
end
|
18
8
|
|
19
9
|
gemspec
|
data/Rakefile
CHANGED
@@ -1,34 +1,5 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'bundler'
|
4
|
-
|
5
|
-
|
6
|
-
require 'rspec/core/rake_task'
|
7
|
-
RSpec::Core::RakeTask.new(:spec)
|
8
|
-
|
9
|
-
task :test => :spec
|
10
|
-
task :default => :spec
|
2
|
+
require 'devtools'
|
11
3
|
|
12
|
-
|
13
|
-
|
14
|
-
RuboCop::RakeTask.new do |task|
|
15
|
-
task.options = %w(--config config/rubocop.yml)
|
16
|
-
end
|
17
|
-
rescue LoadError
|
18
|
-
desc 'Run RuboCop'
|
19
|
-
task :rubocop do
|
20
|
-
$stderr.puts 'RuboCop is disabled'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
require 'yardstick/rake/measurement'
|
25
|
-
Yardstick::Rake::Measurement.new do |measurement|
|
26
|
-
measurement.output = 'measurement/report.txt'
|
27
|
-
end
|
28
|
-
|
29
|
-
require 'yardstick/rake/verify'
|
30
|
-
Yardstick::Rake::Verify.new do |verify|
|
31
|
-
verify.threshold = 100
|
32
|
-
end
|
33
|
-
|
34
|
-
task :ci => [:spec, :rubocop, :verify_measurements]
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
Devtools.init_rake_tasks
|
data/config/devtools.yml
ADDED
data/config/flay.yml
ADDED
data/config/flog.yml
ADDED
data/config/mutant.yml
ADDED
data/config/reek.yml
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
---
|
2
|
+
Attribute:
|
3
|
+
enabled: false
|
4
|
+
exclude: []
|
5
|
+
BooleanParameter:
|
6
|
+
enabled: true
|
7
|
+
exclude: []
|
8
|
+
ClassVariable:
|
9
|
+
enabled: true
|
10
|
+
exclude: []
|
11
|
+
ControlParameter:
|
12
|
+
enabled: true
|
13
|
+
exclude: []
|
14
|
+
DataClump:
|
15
|
+
enabled: true
|
16
|
+
exclude: []
|
17
|
+
max_copies: 2
|
18
|
+
min_clump_size: 2
|
19
|
+
DuplicateMethodCall:
|
20
|
+
enabled: true
|
21
|
+
exclude: []
|
22
|
+
max_calls: 1
|
23
|
+
allow_calls: []
|
24
|
+
FeatureEnvy:
|
25
|
+
enabled: true
|
26
|
+
exclude: []
|
27
|
+
IrresponsibleModule:
|
28
|
+
enabled: true
|
29
|
+
exclude: []
|
30
|
+
LongParameterList:
|
31
|
+
enabled: true
|
32
|
+
exclude: []
|
33
|
+
max_params: 2
|
34
|
+
overrides:
|
35
|
+
initialize:
|
36
|
+
max_params: 3
|
37
|
+
LongYieldList:
|
38
|
+
enabled: true
|
39
|
+
exclude: []
|
40
|
+
max_params: 2
|
41
|
+
NestedIterators:
|
42
|
+
enabled: true
|
43
|
+
exclude:
|
44
|
+
- Equalizer#define_cmp_method
|
45
|
+
- Equalizer#define_inspect_method
|
46
|
+
max_allowed_nesting: 1
|
47
|
+
ignore_iterators: []
|
48
|
+
NilCheck:
|
49
|
+
enabled: true
|
50
|
+
exclude: []
|
51
|
+
RepeatedConditional:
|
52
|
+
enabled: true
|
53
|
+
exclude: []
|
54
|
+
max_ifs: 1
|
55
|
+
TooManyInstanceVariables:
|
56
|
+
enabled: true
|
57
|
+
exclude: []
|
58
|
+
max_instance_variables: 3
|
59
|
+
TooManyMethods:
|
60
|
+
enabled: true
|
61
|
+
exclude: []
|
62
|
+
max_methods: 6
|
63
|
+
TooManyStatements:
|
64
|
+
enabled: true
|
65
|
+
exclude:
|
66
|
+
- Equalizer#define_inspect_method
|
67
|
+
max_statements: 5
|
68
|
+
UncommunicativeMethodName:
|
69
|
+
enabled: true
|
70
|
+
exclude: []
|
71
|
+
reject:
|
72
|
+
- !ruby/regexp /^[a-z]$/
|
73
|
+
- !ruby/regexp /[0-9]$/
|
74
|
+
- !ruby/regexp /[A-Z]/
|
75
|
+
accept: []
|
76
|
+
UncommunicativeModuleName:
|
77
|
+
enabled: true
|
78
|
+
exclude: []
|
79
|
+
reject:
|
80
|
+
- !ruby/regexp /^.$/
|
81
|
+
- !ruby/regexp /[0-9]$/
|
82
|
+
accept: []
|
83
|
+
UncommunicativeParameterName:
|
84
|
+
enabled: true
|
85
|
+
exclude: []
|
86
|
+
reject:
|
87
|
+
- !ruby/regexp /^.$/
|
88
|
+
- !ruby/regexp /[0-9]$/
|
89
|
+
- !ruby/regexp /[A-Z]/
|
90
|
+
accept: []
|
91
|
+
UncommunicativeVariableName:
|
92
|
+
enabled: true
|
93
|
+
exclude: []
|
94
|
+
reject:
|
95
|
+
- !ruby/regexp /^.$/
|
96
|
+
- !ruby/regexp /[0-9]$/
|
97
|
+
- !ruby/regexp /[A-Z]/
|
98
|
+
accept: []
|
99
|
+
UnusedParameters:
|
100
|
+
enabled: true
|
101
|
+
exclude: []
|
102
|
+
UtilityFunction:
|
103
|
+
enabled: true
|
104
|
+
exclude: []
|
105
|
+
max_helper_calls: 0
|
data/config/rubocop.yml
CHANGED
@@ -1,54 +1,115 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Metrics/LineLength:
|
5
|
-
AllowURI: true
|
6
|
-
Enabled: false
|
7
|
-
|
8
|
-
Metrics/MethodLength:
|
9
|
-
CountComments: false
|
10
|
-
Max: 15
|
11
|
-
|
12
|
-
Metrics/ParameterLists:
|
13
|
-
Max: 4
|
1
|
+
# Avoid parameter lists longer than five parameters.
|
2
|
+
ParameterLists:
|
3
|
+
Max: 3
|
14
4
|
CountKeywordArgs: true
|
15
5
|
|
16
|
-
|
17
|
-
|
6
|
+
# Avoid more than `Max` levels of nesting.
|
7
|
+
BlockNesting:
|
8
|
+
Max: 3
|
18
9
|
|
19
|
-
|
10
|
+
# Align with the style guide.
|
11
|
+
CollectionMethods:
|
20
12
|
PreferredMethods:
|
21
|
-
|
22
|
-
|
13
|
+
collect: 'map'
|
14
|
+
inject: 'reduce'
|
23
15
|
find: 'detect'
|
24
16
|
find_all: 'select'
|
25
17
|
|
26
|
-
|
18
|
+
# Do not force public/protected/private keyword to be indented at the same
|
19
|
+
# level as the def keyword. My personal preference is to outdent these keywords
|
20
|
+
# because I think when scanning code it makes it easier to identify the
|
21
|
+
# sections of code and visually separate them. When the keyword is at the same
|
22
|
+
# level I think it sort of blends in with the def keywords and makes it harder
|
23
|
+
# to scan the code and see where the sections are.
|
24
|
+
AccessModifierIndentation:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
# Limit line length
|
28
|
+
LineLength:
|
29
|
+
Max: 106
|
30
|
+
|
31
|
+
# Disable documentation checking until a class needs to be documented once
|
32
|
+
Documentation:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
# Do not always use &&/|| instead of and/or.
|
36
|
+
AndOr:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
# Do not favor modifier if/unless usage when you have a single-line body
|
40
|
+
IfUnlessModifier:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
# Allow case equality operator (in limited use within the specs)
|
44
|
+
CaseEquality:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
# Constants do not always have to use SCREAMING_SNAKE_CASE
|
48
|
+
ConstantName:
|
27
49
|
Enabled: false
|
28
50
|
|
29
|
-
|
30
|
-
|
51
|
+
# Not all trivial readers/writers can be defined with attr_* methods
|
52
|
+
TrivialAccessors:
|
53
|
+
Enabled: false
|
31
54
|
|
32
|
-
|
55
|
+
# Allow empty lines around class body
|
56
|
+
EmptyLinesAroundClassBody:
|
33
57
|
Enabled: false
|
34
58
|
|
35
|
-
|
59
|
+
# Allow empty lines around module body
|
60
|
+
EmptyLinesAroundModuleBody:
|
36
61
|
Enabled: false
|
37
62
|
|
38
|
-
|
63
|
+
# Allow empty lines around block body
|
64
|
+
EmptyLinesAroundBlockBody:
|
39
65
|
Enabled: false
|
40
66
|
|
41
|
-
|
42
|
-
|
67
|
+
# Allow multiple line operations to not require indentation
|
68
|
+
MultilineOperationIndentation:
|
69
|
+
Enabled: false
|
43
70
|
|
44
|
-
|
71
|
+
# Prefer String#% over Kernel#sprintf
|
72
|
+
FormatString:
|
45
73
|
Enabled: false
|
46
74
|
|
47
|
-
|
48
|
-
|
75
|
+
# Use square brackets for literal Array objects
|
76
|
+
PercentLiteralDelimiters:
|
77
|
+
PreferredDelimiters:
|
78
|
+
'%': '{}'
|
79
|
+
'%i': '[]'
|
80
|
+
'%q': ()
|
81
|
+
'%Q': ()
|
82
|
+
'%r': '{}'
|
83
|
+
'%s': ()
|
84
|
+
'%w': '[]'
|
85
|
+
'%W': '[]'
|
86
|
+
'%x': ()
|
87
|
+
|
88
|
+
# Use %i[...] for arrays of symbols
|
89
|
+
SymbolArray:
|
90
|
+
Enabled: true
|
49
91
|
|
50
|
-
|
51
|
-
|
92
|
+
# Align if/else blocks with the variable assignment
|
93
|
+
EndAlignment:
|
94
|
+
AlignWith: variable
|
52
95
|
|
53
|
-
|
54
|
-
|
96
|
+
# Do not always align parameters when it is easier to read
|
97
|
+
AlignParameters:
|
98
|
+
Exclude:
|
99
|
+
- spec/**/*_spec.rb
|
100
|
+
|
101
|
+
# Prefer #kind_of? over #is_a?
|
102
|
+
ClassCheck:
|
103
|
+
EnforcedStyle: kind_of?
|
104
|
+
|
105
|
+
# Do not prefer double quotes to be used when %q or %Q is more appropriate
|
106
|
+
UnneededPercentQ:
|
107
|
+
Enabled: false
|
108
|
+
|
109
|
+
# Allow a maximum ABC score
|
110
|
+
Metrics/AbcSize:
|
111
|
+
Max: 8.6
|
112
|
+
|
113
|
+
# Do not prefer lambda.call(...) over lambda.(...)
|
114
|
+
LambdaCall:
|
115
|
+
Enabled: false
|
@@ -0,0 +1,34 @@
|
|
1
|
+
---
|
2
|
+
path: 'lib/**/*.rb'
|
3
|
+
threshold: 100
|
4
|
+
rules:
|
5
|
+
ApiTag::Presence:
|
6
|
+
enabled: true
|
7
|
+
exclude: []
|
8
|
+
ApiTag::Inclusion:
|
9
|
+
enabled: true
|
10
|
+
exclude: []
|
11
|
+
ApiTag::ProtectedMethod:
|
12
|
+
enabled: true
|
13
|
+
exclude: []
|
14
|
+
ApiTag::PrivateMethod:
|
15
|
+
enabled: true
|
16
|
+
exclude: []
|
17
|
+
ExampleTag:
|
18
|
+
enabled: true
|
19
|
+
exclude: []
|
20
|
+
ReturnTag:
|
21
|
+
enabled: true
|
22
|
+
exclude: []
|
23
|
+
Summary::Presence:
|
24
|
+
enabled: true
|
25
|
+
exclude: []
|
26
|
+
Summary::Length:
|
27
|
+
enabled: true
|
28
|
+
exclude: []
|
29
|
+
Summary::Delimiter:
|
30
|
+
enabled: true
|
31
|
+
exclude: []
|
32
|
+
Summary::SingleLine:
|
33
|
+
enabled: true
|
34
|
+
exclude: []
|
data/equalizer.gemspec
CHANGED
@@ -6,16 +6,16 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.name = 'equalizer'
|
7
7
|
gem.version = Equalizer::VERSION.dup
|
8
8
|
gem.authors = ['Dan Kubb', 'Markus Schirp']
|
9
|
-
gem.email = %w
|
9
|
+
gem.email = %w[dan.kubb@gmail.com mbj@schirp-dso.com]
|
10
10
|
gem.description = 'Module to define equality, equivalence and inspection methods'
|
11
11
|
gem.summary = gem.description
|
12
12
|
gem.homepage = 'https://github.com/dkubb/equalizer'
|
13
13
|
gem.licenses = 'MIT'
|
14
14
|
|
15
|
-
gem.require_paths = %w
|
15
|
+
gem.require_paths = %w[lib]
|
16
16
|
gem.files = `git ls-files`.split("\n")
|
17
17
|
gem.test_files = `git ls-files -- spec/{unit,integration}`.split("\n")
|
18
|
-
gem.extra_rdoc_files = %w
|
18
|
+
gem.extra_rdoc_files = %w[LICENSE README.md CONTRIBUTING.md]
|
19
19
|
|
20
20
|
gem.required_ruby_version = '>= 1.8.7'
|
21
21
|
|
data/lib/equalizer.rb
CHANGED
@@ -52,7 +52,9 @@ private
|
|
52
52
|
def define_cmp_method
|
53
53
|
keys = @keys
|
54
54
|
define_method(:cmp?) do |comparator, other|
|
55
|
-
keys.all?
|
55
|
+
keys.all? do |key|
|
56
|
+
__send__(key).public_send(comparator, other.__send__(key))
|
57
|
+
end
|
56
58
|
end
|
57
59
|
private :cmp?
|
58
60
|
end
|
@@ -65,7 +67,7 @@ private
|
|
65
67
|
def define_hash_method
|
66
68
|
keys = @keys
|
67
69
|
define_method(:hash) do | |
|
68
|
-
keys.
|
70
|
+
keys.map(&method(:send)).push(self.class).hash
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
@@ -79,7 +81,7 @@ private
|
|
79
81
|
define_method(:inspect) do | |
|
80
82
|
klass = self.class
|
81
83
|
name = klass.name || klass.inspect
|
82
|
-
"#<#{name}#{keys.
|
84
|
+
"#<#{name}#{keys.map { |key| " #{key}=#{__send__(key).inspect}" }.join}>"
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
@@ -113,7 +115,7 @@ private
|
|
113
115
|
# @api public
|
114
116
|
def ==(other)
|
115
117
|
other = coerce(other).first if respond_to?(:coerce, true)
|
116
|
-
other.
|
118
|
+
other.kind_of?(self.class) && cmp?(__method__, other)
|
117
119
|
end
|
118
120
|
end # module Methods
|
119
121
|
end # class Equalizer
|
data/lib/equalizer/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,10 @@ if ENV['COVERAGE'] == 'true'
|
|
4
4
|
require 'simplecov'
|
5
5
|
require 'coveralls'
|
6
6
|
|
7
|
-
SimpleCov.formatters = [
|
7
|
+
SimpleCov.formatters = [
|
8
|
+
SimpleCov::Formatter::HTMLFormatter,
|
9
|
+
Coveralls::SimpleCov::Formatter
|
10
|
+
]
|
8
11
|
|
9
12
|
SimpleCov.start do
|
10
13
|
command_name 'spec:unit'
|
@@ -20,6 +23,8 @@ end
|
|
20
23
|
require 'equalizer'
|
21
24
|
|
22
25
|
RSpec.configure do |config|
|
26
|
+
config.raise_errors_for_deprecations!
|
27
|
+
|
23
28
|
config.expect_with :rspec do |expect_with|
|
24
29
|
expect_with.syntax = :expect
|
25
30
|
end
|
@@ -11,7 +11,7 @@ describe Equalizer, '#included' do
|
|
11
11
|
|
12
12
|
before do
|
13
13
|
# Prevent Module.included from being called through inheritance
|
14
|
-
described_class::Methods.
|
14
|
+
allow(described_class::Methods).to receive(:included)
|
15
15
|
end
|
16
16
|
|
17
17
|
around do |example|
|
@@ -36,7 +36,7 @@ describe Equalizer, '#included' do
|
|
36
36
|
# Otherwise, other module includes (which get triggered internally
|
37
37
|
# in RSpec when `change` is used for the first time, since it uses
|
38
38
|
# autoloading for its matchers) will wrongly set this flag.
|
39
|
-
included = true if self.
|
39
|
+
included = true if self.kind_of?(Equalizer)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -83,7 +83,7 @@ describe Equalizer::Methods, '#==' do
|
|
83
83
|
# declare a private #coerce method
|
84
84
|
described_class.class_eval do
|
85
85
|
def coerce(other)
|
86
|
-
[self.class.new(
|
86
|
+
[self.class.new(![nil, false].include?(other)), self]
|
87
87
|
end
|
88
88
|
private :coerce
|
89
89
|
end
|
@@ -96,6 +96,26 @@ describe Equalizer::Methods, '#==' do
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
+
context 'with a different object after coercion' do
|
100
|
+
let(:other) { nil }
|
101
|
+
|
102
|
+
before do
|
103
|
+
# declare a private #coerce method
|
104
|
+
described_class.class_eval do
|
105
|
+
def coerce(other)
|
106
|
+
[self.class.new(![nil, false].include?(other)), self]
|
107
|
+
end
|
108
|
+
private :coerce
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
it { should be(false) }
|
113
|
+
|
114
|
+
it 'is symmetric' do
|
115
|
+
should eql(other == object)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
99
119
|
context 'with a different object' do
|
100
120
|
let(:other) { described_class.new(false) }
|
101
121
|
|
@@ -12,7 +12,7 @@ describe Equalizer, '.new' do
|
|
12
12
|
|
13
13
|
before do
|
14
14
|
# specify the class #name method
|
15
|
-
klass.
|
15
|
+
allow(klass).to receive(:name).and_return(name)
|
16
16
|
klass.send(:include, subject)
|
17
17
|
end
|
18
18
|
|
@@ -23,8 +23,8 @@ describe Equalizer, '.new' do
|
|
23
23
|
it { should be_frozen }
|
24
24
|
|
25
25
|
it 'defines #hash and #inspect methods dynamically' do
|
26
|
-
expect(subject.public_instance_methods(false).
|
27
|
-
to eql(%w
|
26
|
+
expect(subject.public_instance_methods(false).map(&:to_s).sort)
|
27
|
+
.to eql(%w[hash inspect])
|
28
28
|
end
|
29
29
|
|
30
30
|
describe '#eql?' do
|
@@ -75,7 +75,7 @@ describe Equalizer, '.new' do
|
|
75
75
|
context 'with keys' do
|
76
76
|
subject { object.new(*keys) }
|
77
77
|
|
78
|
-
let(:keys) { [
|
78
|
+
let(:keys) { %i[firstname lastname].freeze }
|
79
79
|
let(:firstname) { 'John' }
|
80
80
|
let(:lastname) { 'Doe' }
|
81
81
|
let(:instance) { klass.new(firstname, lastname) }
|
@@ -93,8 +93,7 @@ describe Equalizer, '.new' do
|
|
93
93
|
|
94
94
|
before do
|
95
95
|
# specify the class #inspect method
|
96
|
-
klass.
|
97
|
-
klass.stub(:inspect).and_return(name)
|
96
|
+
allow(klass).to receive_messages(name: nil, inspect: name)
|
98
97
|
klass.send(:include, subject)
|
99
98
|
end
|
100
99
|
|
@@ -103,8 +102,8 @@ describe Equalizer, '.new' do
|
|
103
102
|
it { should be_frozen }
|
104
103
|
|
105
104
|
it 'defines #hash and #inspect methods dynamically' do
|
106
|
-
expect(subject.public_instance_methods(false).
|
107
|
-
to eql(%w
|
105
|
+
expect(subject.public_instance_methods(false).map(&:to_s).sort)
|
106
|
+
.to eql(%w[hash inspect])
|
108
107
|
end
|
109
108
|
|
110
109
|
describe '#eql?' do
|
@@ -143,15 +142,15 @@ describe Equalizer, '.new' do
|
|
143
142
|
|
144
143
|
describe '#hash' do
|
145
144
|
it 'returns the expected hash' do
|
146
|
-
expect(instance.hash)
|
147
|
-
to eql([firstname, lastname, klass].hash)
|
145
|
+
expect(instance.hash)
|
146
|
+
.to eql([firstname, lastname, klass].hash)
|
148
147
|
end
|
149
148
|
end
|
150
149
|
|
151
150
|
describe '#inspect' do
|
152
151
|
it 'returns the expected string' do
|
153
|
-
expect(instance.inspect)
|
154
|
-
to eql('#<User firstname="John" lastname="Doe">')
|
152
|
+
expect(instance.inspect)
|
153
|
+
.to eql('#<User firstname="John" lastname="Doe">')
|
155
154
|
end
|
156
155
|
end
|
157
156
|
end
|
metadata
CHANGED
@@ -1,55 +1,66 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: equalizer
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Dan Kubb
|
8
8
|
- Markus Schirp
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
version: "1.3"
|
12
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.3'
|
22
21
|
- - ">="
|
23
|
-
- !ruby/object:Gem::Version
|
22
|
+
- !ruby/object:Gem::Version
|
24
23
|
version: 1.3.5
|
25
|
-
|
24
|
+
type: :development
|
26
25
|
prerelease: false
|
27
|
-
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - "~>"
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '1.3'
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.3.5
|
28
34
|
description: Module to define equality, equivalence and inspection methods
|
29
|
-
email:
|
35
|
+
email:
|
30
36
|
- dan.kubb@gmail.com
|
31
37
|
- mbj@schirp-dso.com
|
32
38
|
executables: []
|
33
|
-
|
34
39
|
extensions: []
|
35
|
-
|
36
|
-
extra_rdoc_files:
|
40
|
+
extra_rdoc_files:
|
37
41
|
- LICENSE
|
38
42
|
- README.md
|
39
43
|
- CONTRIBUTING.md
|
40
|
-
files:
|
41
|
-
- .gitignore
|
42
|
-
- .rspec
|
43
|
-
- .rubocop.yml
|
44
|
-
- .ruby-gemset
|
45
|
-
- .
|
46
|
-
- .
|
44
|
+
files:
|
45
|
+
- ".gitignore"
|
46
|
+
- ".rspec"
|
47
|
+
- ".rubocop.yml"
|
48
|
+
- ".ruby-gemset"
|
49
|
+
- ".ruby-version"
|
50
|
+
- ".travis.yml"
|
51
|
+
- ".yardstick.yml"
|
47
52
|
- CONTRIBUTING.md
|
48
53
|
- Gemfile
|
49
54
|
- LICENSE
|
50
55
|
- README.md
|
51
56
|
- Rakefile
|
57
|
+
- config/devtools.yml
|
58
|
+
- config/flay.yml
|
59
|
+
- config/flog.yml
|
60
|
+
- config/mutant.yml
|
61
|
+
- config/reek.yml
|
52
62
|
- config/rubocop.yml
|
63
|
+
- config/yardstick.yml
|
53
64
|
- equalizer.gemspec
|
54
65
|
- lib/equalizer.rb
|
55
66
|
- lib/equalizer/version.rb
|
@@ -60,33 +71,30 @@ files:
|
|
60
71
|
- spec/unit/equalizer/methods/equality_operator_spec.rb
|
61
72
|
- spec/unit/equalizer/universal_spec.rb
|
62
73
|
homepage: https://github.com/dkubb/equalizer
|
63
|
-
licenses:
|
74
|
+
licenses:
|
64
75
|
- MIT
|
65
76
|
metadata: {}
|
66
|
-
|
67
77
|
post_install_message:
|
68
78
|
rdoc_options: []
|
69
|
-
|
70
|
-
require_paths:
|
79
|
+
require_paths:
|
71
80
|
- lib
|
72
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
74
83
|
- - ">="
|
75
|
-
- !ruby/object:Gem::Version
|
84
|
+
- !ruby/object:Gem::Version
|
76
85
|
version: 1.8.7
|
77
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
79
88
|
- - ">="
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version:
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
82
91
|
requirements: []
|
83
|
-
|
84
92
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.4.
|
93
|
+
rubygems_version: 2.4.5
|
86
94
|
signing_key:
|
87
95
|
specification_version: 4
|
88
96
|
summary: Module to define equality, equivalence and inspection methods
|
89
|
-
test_files:
|
97
|
+
test_files:
|
90
98
|
- spec/unit/equalizer/included_spec.rb
|
91
99
|
- spec/unit/equalizer/methods/eql_predicate_spec.rb
|
92
100
|
- spec/unit/equalizer/methods/equality_operator_spec.rb
|