mismatch-inspectable 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: 5d1a63392c8810b446da003f2a520b13ed9c820a9e38d825d2b1d90a9b56ac55
4
- data.tar.gz: f5e50d3286ab7bcd0d75f584902272cbed5ddef4cc55b82e0709b4ab9228f25d
3
+ metadata.gz: 0f2e711a465a93a6cf4a13d5f4536df7633f1d42e0a445c4e01558aa9c33e25e
4
+ data.tar.gz: 3c8439ca0fb0937d4c969d023b40a5bf2571933dc137469755e284c258100b96
5
5
  SHA512:
6
- metadata.gz: 898f167833de14ad907bb1038d326b5b356fd3d7c0a7388f172f72b77f8a9aee8b084b8cf502ea42ddbb2f13a67aaa9b7b56f897eb294c7894a9d6cbc165695e
7
- data.tar.gz: 550bfa28af86449bcd1931f520d99a1075cc3447baf9f00a9254e6f23113a0c5247eeaf3e6bc047c849bca35e9544e20768f084716b58f9604aa1dbc904efdd5
6
+ metadata.gz: ca368e42844554edf57a7a450f4aadf8d2ac799b8ce711be465d2146c022456d379502dda5d030849ac0a8768254c67dbb7688a5db695e64de76aeb689240ab0
7
+ data.tar.gz: 309644a355739a5a97d9b0e6dd58683514698be2020e9deeab76863ac1f504901a1e44d395107cbd58d1b952d870b70281e5fa450fa21f4b2906c7b31cdfb413
@@ -1,14 +1,10 @@
1
- require_relative 'hash_formatter'
2
- require_relative 'array_formatter'
3
- require_relative 'object_formatter'
1
+ require_relative "hash_formatter"
2
+ require_relative "array_formatter"
3
+ require_relative "object_formatter"
4
4
 
5
5
  module MismatchInspectable
6
- class << self
7
- def included(base)
8
- class << base
9
- include ClassMethods
10
- end
11
- end
6
+ def self.included(target_class)
7
+ target_class.extend ClassMethods
12
8
  end
13
9
 
14
10
  module ClassMethods
@@ -25,7 +21,7 @@ module MismatchInspectable
25
21
  end
26
22
  end
27
23
 
28
- def inspect_mismatch(other, recursive: false, include_class: true, prefix: '', format: :array)
24
+ def inspect_mismatch(other, recursive: false, include_class: true, prefix: "", format: :array)
29
25
  return if self.class != other.class
30
26
 
31
27
  formatter = select_formatter(format)
@@ -49,6 +45,7 @@ module MismatchInspectable
49
45
  end
50
46
  end
51
47
 
48
+ # rubocop:disable Metrics/ParameterLists
52
49
  def process_attributes(formatter, other, recursive, include_class, prefix, format)
53
50
  raise MissingCompareMethodsError if compare_methods.nil?
54
51
 
@@ -73,13 +70,14 @@ module MismatchInspectable
73
70
  nested_mismatches = curr_val.inspect_mismatch(
74
71
  other_val,
75
72
  recursive: true,
76
- include_class: include_class,
73
+ include_class:,
77
74
  prefix: "#{prefix}#{attribute}.",
78
- format: format
75
+ format:
79
76
  )
80
77
 
81
78
  formatter.merge_mismatches(nested_mismatches) unless no_nested_mismatches?(nested_mismatches)
82
79
  end
80
+ # rubocop:enable Metrics/ParameterLists
83
81
 
84
82
  def update_prefix(include_class, prefix)
85
83
  comparable_prefix = get_comparable_prefix(prefix)
@@ -91,7 +89,7 @@ module MismatchInspectable
91
89
  end
92
90
 
93
91
  def get_comparable_prefix(prefix)
94
- prefixes = prefix.split('.')
92
+ prefixes = prefix.split(".")
95
93
  prefixes.length >= 2 ? prefixes[-1] : prefix
96
94
  end
97
95
  end
@@ -1,4 +1,4 @@
1
- require_relative 'deep_merge'
1
+ require_relative "deep_merge"
2
2
 
3
3
  class ObjectFormatter
4
4
  def initialize
@@ -8,7 +8,7 @@ class ObjectFormatter
8
8
  attr_reader :mismatches
9
9
 
10
10
  def add_mismatch(prefix, attribute, curr_val, other_val)
11
- prefix_parts = prefix.split('.').flat_map { |part| part.split('#') }.collect(&:to_sym)
11
+ prefix_parts = prefix.split(".").flat_map { |part| part.split("#") }.collect(&:to_sym)
12
12
  curr = mismatches
13
13
 
14
14
  prefix_parts.each do |part|
@@ -1,3 +1,3 @@
1
1
  module MismatchInspectable
2
- VERSION = '0.1.1'
2
+ VERSION = "0.1.2".freeze
3
3
  end
@@ -1 +1 @@
1
- require_relative 'mismatch_inspectable/mismatch_inspectable'
1
+ require_relative "mismatch_inspectable/mismatch_inspectable"
data/spec/examples.txt CHANGED
@@ -1,24 +1,24 @@
1
1
  example_id | status | run_time |
2
2
  ---------------------------------------------------------- | ------ | --------------- |
3
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:1:1] | passed | 0.00118 seconds |
4
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:1:1] | passed | 0.00041 seconds |
5
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:1:2:1] | passed | 0.0001 seconds |
6
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:1:3:1:1:1] | passed | 0.00015 seconds |
7
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:1:3:1:1:2:1] | passed | 0.00013 seconds |
8
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:1:3:1:2:1] | passed | 0.00014 seconds |
9
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:1:3:1:2:2:1] | passed | 0.00014 seconds |
10
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:1:3:2:1] | passed | 0.00011 seconds |
11
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:1:1] | passed | 0.0001 seconds |
12
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:2:1] | passed | 0.00025 seconds |
13
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:3:1] | passed | 0.00014 seconds |
14
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:1:1:1:1] | passed | 0.00014 seconds |
15
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:1:1:2:1] | passed | 0.00013 seconds |
16
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:1:1:3:1] | passed | 0.00013 seconds |
17
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:1:2:1:1] | passed | 0.00031 seconds |
18
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:1:2:2:1] | passed | 0.0002 seconds |
19
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:1:2:3:1] | passed | 0.00017 seconds |
20
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:2:1:1] | passed | 0.00014 seconds |
21
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:2:2:1] | passed | 0.00012 seconds |
22
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:2:3:1] | passed | 0.00013 seconds |
23
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:3:1:1] | passed | 0.00028 seconds |
24
- ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:3:2:1] | passed | 0.00049 seconds |
3
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:1:1] | passed | 0.00088 seconds |
4
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:1:1] | passed | 0.00045 seconds |
5
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:1:2:1] | passed | 0.00012 seconds |
6
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:1:3:1:1:1] | passed | 0.00146 seconds |
7
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:1:3:1:1:2:1] | passed | 0.00014 seconds |
8
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:1:3:1:2:1] | passed | 0.00012 seconds |
9
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:1:3:1:2:2:1] | passed | 0.00013 seconds |
10
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:1:3:2:1] | passed | 0.0001 seconds |
11
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:1:1] | passed | 0.00009 seconds |
12
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:2:1] | passed | 0.0001 seconds |
13
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:3:1] | passed | 0.00011 seconds |
14
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:1:1:1:1] | passed | 0.00012 seconds |
15
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:1:1:2:1] | passed | 0.00011 seconds |
16
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:1:1:3:1] | passed | 0.00033 seconds |
17
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:1:2:1:1] | passed | 0.00012 seconds |
18
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:1:2:2:1] | passed | 0.00013 seconds |
19
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:1:2:3:1] | passed | 0.00015 seconds |
20
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:2:1:1] | passed | 0.0001 seconds |
21
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:2:2:1] | passed | 0.00011 seconds |
22
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:2:3:1] | passed | 0.00011 seconds |
23
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:3:1:1] | passed | 0.00017 seconds |
24
+ ./spec/lib/mismatch_inspectable_spec.rb[1:1:2:2:4:3:2:1] | passed | 0.0002 seconds |
@@ -1,6 +1,6 @@
1
- require 'rspec'
2
- require 'spec_helper'
3
- require 'mismatch_inspectable'
1
+ require "rspec"
2
+ require "spec_helper"
3
+ require "mismatch_inspectable"
4
4
 
5
5
  class TestClass
6
6
  include MismatchInspectable
@@ -24,9 +24,9 @@ RSpec.describe MismatchInspectable do
24
24
  let(:format) { :array }
25
25
  let(:recursive) { false }
26
26
 
27
- let(:name) { 'Tyler' }
27
+ let(:name) { "Tyler" }
28
28
  let(:age) { 29 }
29
- let(:address) { '123 Cool St' }
29
+ let(:address) { "123 Cool St" }
30
30
 
31
31
  before do
32
32
  object1.name = name
@@ -38,38 +38,38 @@ RSpec.describe MismatchInspectable do
38
38
  object2.address = address
39
39
  end
40
40
 
41
- describe '#inspect_mismatch' do
42
- context 'when objects are of different classes' do
41
+ describe "#inspect_mismatch" do
42
+ context "when objects are of different classes" do
43
43
  let(:object3) { Object.new }
44
44
 
45
- it 'returns nil' do
45
+ it "returns nil" do
46
46
  expect(object1.inspect_mismatch(object3)).to be_nil
47
47
  end
48
48
  end
49
49
 
50
- context 'when objects are of the same class' do
51
- context 'with top level attributes that match' do
52
- it 'returns an empty array' do
50
+ context "when objects are of the same class" do
51
+ context "with top level attributes that match" do
52
+ it "returns an empty array" do
53
53
  expect(object1.inspect_mismatch(object1)).to eq([])
54
54
  end
55
55
 
56
- context 'when format is set to :hash' do
56
+ context "when format is set to :hash" do
57
57
  let(:format) { :hash }
58
58
 
59
- it 'returns an empty hash' do
60
- expect(object1.inspect_mismatch(object1, format: format)).to eq({})
59
+ it "returns an empty hash" do
60
+ expect(object1.inspect_mismatch(object1, format:)).to eq({})
61
61
  end
62
62
  end
63
63
 
64
- context 'with nested inspectable attributes' do
64
+ context "with nested inspectable attributes" do
65
65
  let(:recursive) { true }
66
66
 
67
- context 'when objects have nested attributes with the same class' do
67
+ context "when objects have nested attributes with the same class" do
68
68
  let(:nested1) { NestedTestClass.new }
69
69
  let(:nested2) { NestedTestClass.new }
70
70
 
71
- let(:city) { 'ATX' }
72
- let(:country) { 'USA' }
71
+ let(:city) { "ATX" }
72
+ let(:country) { "USA" }
73
73
 
74
74
  before do
75
75
  nested1.city = city
@@ -82,42 +82,42 @@ RSpec.describe MismatchInspectable do
82
82
  object2.nested = nested2
83
83
  end
84
84
 
85
- context 'when nested attributes match' do
86
- it 'returns an empty array' do
87
- expect(object1.inspect_mismatch(object2, recursive: recursive)).to eq([])
85
+ context "when nested attributes match" do
86
+ it "returns an empty array" do
87
+ expect(object1.inspect_mismatch(object2, recursive:)).to eq([])
88
88
  end
89
89
 
90
- context 'when format is set to :hash' do
90
+ context "when format is set to :hash" do
91
91
  let(:format) { :hash }
92
- it 'returns an empty hash' do
93
- expect(object1.inspect_mismatch(object2, format: format, recursive: recursive)).to eq({})
92
+ it "returns an empty hash" do
93
+ expect(object1.inspect_mismatch(object2, format:, recursive:)).to eq({})
94
94
  end
95
95
  end
96
96
  end
97
97
 
98
- context 'when nested attributes have different values' do
99
- before { nested2.city = 'Phoenix' }
98
+ context "when nested attributes have different values" do
99
+ before { nested2.city = "Phoenix" }
100
100
 
101
- it 'returns an array of mismatched nested attributes with recursive flag enabled' do
101
+ it "returns an array of mismatched nested attributes with recursive flag enabled" do
102
102
  expected = [
103
- ['nested.NestedTestClass#city', 'ATX', 'Phoenix']
103
+ ["nested.NestedTestClass#city", "ATX", "Phoenix"]
104
104
  ]
105
- expect(object1.inspect_mismatch(object2, recursive: recursive)).to eq(expected)
105
+ expect(object1.inspect_mismatch(object2, recursive:)).to eq(expected)
106
106
  end
107
107
 
108
- context 'when format is set to :hash' do
108
+ context "when format is set to :hash" do
109
109
  let(:format) { :hash }
110
- it 'returns a hash of mismatched nested attributes with recursive flag enabled' do
110
+ it "returns a hash of mismatched nested attributes with recursive flag enabled" do
111
111
  expected = {
112
- 'nested.NestedTestClass#city' => %w[ATX Phoenix]
112
+ "nested.NestedTestClass#city" => %w[ATX Phoenix]
113
113
  }
114
- expect(object1.inspect_mismatch(object2, format: format, recursive: recursive)).to eq(expected)
114
+ expect(object1.inspect_mismatch(object2, format:, recursive:)).to eq(expected)
115
115
  end
116
116
  end
117
117
  end
118
118
  end
119
119
 
120
- context 'when nested attributes have different classes' do
120
+ context "when nested attributes have different classes" do
121
121
  let(:nested1) { NestedTestClass.new }
122
122
  let(:nested2) { TestClass.new }
123
123
 
@@ -126,8 +126,8 @@ RSpec.describe MismatchInspectable do
126
126
  object2.nested = nested2
127
127
  end
128
128
 
129
- it 'returns nil for mismatched nested attribute with recursive flag enabled' do
130
- expect(object1.inspect_mismatch(object2, recursive: recursive)).to eq([])
129
+ it "returns nil for mismatched nested attribute with recursive flag enabled" do
130
+ expect(object1.inspect_mismatch(object2, recursive:)).to eq([])
131
131
  end
132
132
  end
133
133
  end
@@ -136,117 +136,117 @@ RSpec.describe MismatchInspectable do
136
136
  context "with top level attributes that don't match" do
137
137
  before { object2.age = 30 }
138
138
 
139
- context 'when format is set to :array (default)' do
140
- it 'returns an array of mismatched attributes' do
139
+ context "when format is set to :array (default)" do
140
+ it "returns an array of mismatched attributes" do
141
141
  expected = [
142
- ['TestClass#age', 29, 30]
142
+ ["TestClass#age", 29, 30]
143
143
  ]
144
144
  expect(object1.inspect_mismatch(object2)).to eq(expected)
145
145
  end
146
146
  end
147
147
 
148
- context 'when format is set to :hash' do
148
+ context "when format is set to :hash" do
149
149
  let(:format) { :hash }
150
- it 'returns a hash of mismatched attributes' do
150
+ it "returns a hash of mismatched attributes" do
151
151
  expected = {
152
- 'TestClass#age' => [29, 30]
152
+ "TestClass#age" => [29, 30]
153
153
  }
154
- expect(object1.inspect_mismatch(object2, format: format)).to eq(expected)
154
+ expect(object1.inspect_mismatch(object2, format:)).to eq(expected)
155
155
  end
156
156
  end
157
157
 
158
- context 'when format is set to :object' do
158
+ context "when format is set to :object" do
159
159
  let(:format) { :object }
160
- it 'returns an object of mismatched attributes' do
160
+ it "returns an object of mismatched attributes" do
161
161
  expected = {
162
162
  TestClass: {
163
163
  age: [29, 30]
164
164
  }
165
165
  }
166
- expect(object1.inspect_mismatch(object2, format: format)).to eq(expected)
166
+ expect(object1.inspect_mismatch(object2, format:)).to eq(expected)
167
167
  end
168
168
  end
169
169
 
170
- context 'with nested inspectable attributes' do
170
+ context "with nested inspectable attributes" do
171
171
  let(:recursive) { true }
172
- context 'when objects have nested attributes with the same class' do
172
+ context "when objects have nested attributes with the same class" do
173
173
  let(:nested1) { NestedTestClass.new }
174
174
  let(:nested2) { NestedTestClass.new }
175
175
 
176
- let(:city) { 'ATX' }
177
- let(:country) { 'USA' }
176
+ let(:city) { "ATX" }
177
+ let(:country) { "USA" }
178
178
 
179
179
  before do
180
180
  nested1.city = city
181
181
  nested1.country = country
182
182
 
183
- nested2.city = 'Phoenix'
183
+ nested2.city = "Phoenix"
184
184
  nested2.country = country
185
185
 
186
186
  object1.nested = nested1
187
187
  object2.nested = nested1
188
188
  end
189
189
 
190
- context 'when nested attributes match' do
191
- context 'when format is set to :array (default)' do
192
- it 'returns the top-level mismatched attributes' do
190
+ context "when nested attributes match" do
191
+ context "when format is set to :array (default)" do
192
+ it "returns the top-level mismatched attributes" do
193
193
  expected = [
194
- ['TestClass#age', 29, 30]
194
+ ["TestClass#age", 29, 30]
195
195
  ]
196
196
  expect(object1.inspect_mismatch(object2)).to eq(expected)
197
197
  end
198
198
  end
199
199
 
200
- context 'when format is set to :hash' do
200
+ context "when format is set to :hash" do
201
201
  let(:format) { :hash }
202
- it 'returns the top-level mismatched attributes' do
202
+ it "returns the top-level mismatched attributes" do
203
203
  expected = {
204
- 'TestClass#age' => [29, 30]
204
+ "TestClass#age" => [29, 30]
205
205
  }
206
- expect(object1.inspect_mismatch(object2, format: format)).to eq(expected)
206
+ expect(object1.inspect_mismatch(object2, format:)).to eq(expected)
207
207
  end
208
208
  end
209
209
 
210
- context 'when format is set to :object' do
210
+ context "when format is set to :object" do
211
211
  let(:format) { :object }
212
- it 'returns the top-level mismatched attributes' do
212
+ it "returns the top-level mismatched attributes" do
213
213
  expected = {
214
214
  TestClass: {
215
215
  age: [29, 30]
216
216
  }
217
217
  }
218
- expect(object1.inspect_mismatch(object2, format: format)).to eq(expected)
218
+ expect(object1.inspect_mismatch(object2, format:)).to eq(expected)
219
219
  end
220
220
  end
221
221
  end
222
222
 
223
- context 'when nested attributes have different values' do
223
+ context "when nested attributes have different values" do
224
224
  before { object2.nested = nested2 }
225
225
 
226
- context 'when format is set to :array (default)' do
227
- it 'returns an array of mismatched nested attributes with recursive flag enabled' do
226
+ context "when format is set to :array (default)" do
227
+ it "returns an array of mismatched nested attributes with recursive flag enabled" do
228
228
  expected = [
229
- ['TestClass#age', 29, 30],
230
- ['TestClass#nested.NestedTestClass#city', 'ATX', 'Phoenix']
229
+ ["TestClass#age", 29, 30],
230
+ ["TestClass#nested.NestedTestClass#city", "ATX", "Phoenix"]
231
231
  ]
232
232
  expect(object1.inspect_mismatch(object2, recursive: true)).to eq(expected)
233
233
  end
234
234
  end
235
235
 
236
- context 'when format is set to :hash' do
236
+ context "when format is set to :hash" do
237
237
  let(:format) { :hash }
238
- it 'returns a hash of mismatched nested attributes with recursive flag enabled' do
238
+ it "returns a hash of mismatched nested attributes with recursive flag enabled" do
239
239
  expected = {
240
- 'TestClass#age' => [29, 30],
241
- 'TestClass#nested.NestedTestClass#city' => %w[ATX Phoenix]
240
+ "TestClass#age" => [29, 30],
241
+ "TestClass#nested.NestedTestClass#city" => %w[ATX Phoenix]
242
242
  }
243
- expect(object1.inspect_mismatch(object2, recursive: recursive, format: format)).to eq(expected)
243
+ expect(object1.inspect_mismatch(object2, recursive:, format:)).to eq(expected)
244
244
  end
245
245
  end
246
246
 
247
- context 'when format is set to :object' do
247
+ context "when format is set to :object" do
248
248
  let(:format) { :object }
249
- it 'returns an object of mismatched nested attributes with recursive flag enabled' do
249
+ it "returns an object of mismatched nested attributes with recursive flag enabled" do
250
250
  expected = {
251
251
  TestClass: {
252
252
  age: [29, 30],
@@ -257,13 +257,13 @@ RSpec.describe MismatchInspectable do
257
257
  }
258
258
  }
259
259
  }
260
- expect(object1.inspect_mismatch(object2, recursive: recursive, format: format)).to eq(expected)
260
+ expect(object1.inspect_mismatch(object2, recursive:, format:)).to eq(expected)
261
261
  end
262
262
  end
263
263
  end
264
264
  end
265
265
 
266
- context 'when nested attributes have different classes' do
266
+ context "when nested attributes have different classes" do
267
267
  let(:nested1) { NestedTestClass.new }
268
268
  let(:nested2) { TestClass.new }
269
269
 
@@ -272,31 +272,31 @@ RSpec.describe MismatchInspectable do
272
272
  object2.nested = nested2
273
273
  end
274
274
 
275
- context 'when format is set to :array (default)' do
276
- it 'returns nil for mismatched nested attribute with recursive flag enabled' do
277
- expect(object1.inspect_mismatch(object2, recursive: recursive)).to eq(
275
+ context "when format is set to :array (default)" do
276
+ it "returns nil for mismatched nested attribute with recursive flag enabled" do
277
+ expect(object1.inspect_mismatch(object2, recursive:)).to eq(
278
278
  [
279
- ['TestClass#age', 29, 30]
279
+ ["TestClass#age", 29, 30]
280
280
  ]
281
281
  )
282
282
  end
283
283
  end
284
284
 
285
- context 'when format is set to :hash' do
285
+ context "when format is set to :hash" do
286
286
  let(:format) { :hash }
287
- it 'returns nil for mismatched nested attribute with recursive flag enabled' do
288
- expect(object1.inspect_mismatch(object2, recursive: recursive, format: format)).to eq(
287
+ it "returns nil for mismatched nested attribute with recursive flag enabled" do
288
+ expect(object1.inspect_mismatch(object2, recursive:, format:)).to eq(
289
289
  {
290
- 'TestClass#age' => [29, 30]
290
+ "TestClass#age" => [29, 30]
291
291
  }
292
292
  )
293
293
  end
294
294
  end
295
295
 
296
- context 'when format is set to :object' do
296
+ context "when format is set to :object" do
297
297
  let(:format) { :object }
298
- it 'returns nil for mismatched nested attribute with recursive flag enabled' do
299
- expect(object1.inspect_mismatch(object2, recursive: recursive, format: format)).to eq(
298
+ it "returns nil for mismatched nested attribute with recursive flag enabled" do
299
+ expect(object1.inspect_mismatch(object2, recursive:, format:)).to eq(
300
300
  {
301
301
  TestClass: {
302
302
  age: [29, 30]
@@ -307,7 +307,8 @@ RSpec.describe MismatchInspectable do
307
307
  end
308
308
  end
309
309
 
310
- context 'with multiple levels of nested inspectable attributes' do
310
+ context "with multiple levels of nested inspectable attributes" do
311
+ # rubocop:disable Lint/ConstantDefinitionInBlock
311
312
  class Thing
312
313
  include MismatchInspectable
313
314
 
@@ -321,24 +322,25 @@ RSpec.describe MismatchInspectable do
321
322
  end
322
323
 
323
324
  def inspect
324
- '<Thing>'
325
+ "<Thing>"
325
326
  end
326
327
 
327
328
  attr_accessor :color, :shape, :is_cool, :nested_thing
328
329
  end
330
+ # rubocop:enable Lint/ConstantDefinitionInBlock
329
331
 
330
332
  let(:thing1) do
331
333
  Thing.new(
332
- color: 'blue',
333
- shape: 'square',
334
+ color: "blue",
335
+ shape: "square",
334
336
  is_cool: false,
335
337
  nested_thing: Thing.new(
336
- color: 'blue',
337
- shape: 'oval',
338
+ color: "blue",
339
+ shape: "oval",
338
340
  is_cool: true,
339
341
  nested_thing: Thing.new(
340
- color: 'silver',
341
- shape: 'oval',
342
+ color: "silver",
343
+ shape: "oval",
342
344
  is_cool: true
343
345
  )
344
346
  )
@@ -347,23 +349,23 @@ RSpec.describe MismatchInspectable do
347
349
 
348
350
  let(:thing2) do
349
351
  Thing.new(
350
- color: 'green',
351
- shape: 'oval',
352
+ color: "green",
353
+ shape: "oval",
352
354
  is_cool: false,
353
355
  nested_thing: Thing.new(
354
- color: 'red',
355
- shape: 'another shape',
356
+ color: "red",
357
+ shape: "another shape",
356
358
  is_cool: true,
357
359
  nested_thing: Thing.new(
358
- color: 'blue',
359
- shape: 'oval',
360
+ color: "blue",
361
+ shape: "oval",
360
362
  is_cool: false
361
363
  )
362
364
  )
363
365
  )
364
366
  end
365
- context 'with recursive flag disabled' do
366
- it 'returns the mismatched top-level attributes' do
367
+ context "with recursive flag disabled" do
368
+ it "returns the mismatched top-level attributes" do
367
369
  expect(thing1.inspect_mismatch(thing2, format: :object)).to eq(
368
370
  {
369
371
  Thing: {
@@ -376,10 +378,10 @@ RSpec.describe MismatchInspectable do
376
378
  end
377
379
  end
378
380
 
379
- context 'with recursive flag enabled' do
381
+ context "with recursive flag enabled" do
380
382
  let(:recursive) { true }
381
- it 'returns the mismatched attributes with the appropriate nesting' do
382
- expect(thing1.inspect_mismatch(thing2, recursive: recursive, format: :object)).to eq(
383
+ it "returns the mismatched attributes with the appropriate nesting" do
384
+ expect(thing1.inspect_mismatch(thing2, recursive:, format: :object)).to eq(
383
385
  {
384
386
  Thing: {
385
387
  color: %w[blue green],
@@ -389,7 +391,7 @@ RSpec.describe MismatchInspectable do
389
391
  nested_thing: {
390
392
  Thing: {
391
393
  color: %w[blue red],
392
- shape: ['oval', 'another shape'],
394
+ shape: ["oval", "another shape"],
393
395
  nested_thing: {
394
396
  Thing: {
395
397
  color: %w[silver blue],
data/spec/spec_helper.rb CHANGED
@@ -56,7 +56,7 @@ RSpec.configure do |config|
56
56
  # # Allows RSpec to persist some state between runs in order to support
57
57
  # # the `--only-failures` and `--next-failure` CLI options. We recommend
58
58
  # # you configure your source control system to ignore this file.
59
- config.example_status_persistence_file_path = 'spec/examples.txt'
59
+ config.example_status_persistence_file_path = "spec/examples.txt"
60
60
  #
61
61
  # # Limits the available syntax to the non-monkey patched syntax that is
62
62
  # # recommended. For more details, see:
metadata CHANGED
@@ -1,31 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mismatch-inspectable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Rhodes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-22 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rspec
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- description: A library that includes a module that can print mismatched values for
28
- any class that includes it. Supports recursive inspection of nested objects.
11
+ date: 2023-06-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |-
14
+ A library that includes a module that can print mismatched
15
+ values for any class that includes it. Supports recursive inspection of nested
16
+ objects.
29
17
  email:
30
18
  - tyler.rhodes@aya.yale.edu
31
19
  executables: []
@@ -47,27 +35,25 @@ files:
47
35
  homepage: https://github.com/tyleCaineRhodes/mismatch-inspectable
48
36
  licenses:
49
37
  - MIT
50
- metadata: {}
38
+ metadata:
39
+ rubygems_mfa_required: 'true'
51
40
  post_install_message:
52
41
  rdoc_options: []
53
42
  require_paths:
54
43
  - lib
55
44
  required_ruby_version: !ruby/object:Gem::Requirement
56
45
  requirements:
57
- - - ">="
46
+ - - '='
58
47
  - !ruby/object:Gem::Version
59
- version: '0'
48
+ version: 3.2.1
60
49
  required_rubygems_version: !ruby/object:Gem::Requirement
61
50
  requirements:
62
51
  - - ">="
63
52
  - !ruby/object:Gem::Version
64
53
  version: '0'
65
54
  requirements: []
66
- rubygems_version: 3.2.3
55
+ rubygems_version: 3.4.6
67
56
  signing_key:
68
57
  specification_version: 4
69
58
  summary: A library for easily printing and debugging mismatched values
70
- test_files:
71
- - spec/examples.txt
72
- - spec/lib/mismatch_inspectable_spec.rb
73
- - spec/spec_helper.rb
59
+ test_files: []