sinclair 2.1.1 → 3.0.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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +3 -3
  3. data/.rubocop.yml +33 -1
  4. data/.rubocop_todo.yml +13 -1
  5. data/Dockerfile +2 -3
  6. data/Gemfile +17 -0
  7. data/Makefile +6 -0
  8. data/README.md +3 -3
  9. data/lib/sinclair/caster/class_methods.rb +6 -6
  10. data/lib/sinclair/chain_settable.rb +1 -1
  11. data/lib/sinclair/class_methods.rb +3 -3
  12. data/lib/sinclair/config_builder.rb +4 -4
  13. data/lib/sinclair/config_class.rb +3 -3
  14. data/lib/sinclair/config_factory.rb +7 -6
  15. data/lib/sinclair/configurable.rb +5 -5
  16. data/lib/sinclair/env_settable.rb +1 -1
  17. data/lib/sinclair/equals_checker.rb +1 -3
  18. data/lib/sinclair/exception.rb +1 -0
  19. data/lib/sinclair/input_hash.rb +3 -2
  20. data/lib/sinclair/matchers/add_class_method_to.rb +1 -1
  21. data/lib/sinclair/matchers/add_instance_method_to.rb +1 -1
  22. data/lib/sinclair/matchers/base.rb +2 -1
  23. data/lib/sinclair/matchers/change_class_method_on.rb +1 -1
  24. data/lib/sinclair/matchers/change_instance_method_on.rb +1 -1
  25. data/lib/sinclair/method_builder/base.rb +2 -1
  26. data/lib/sinclair/method_definition/block_helper.rb +4 -4
  27. data/lib/sinclair/method_definition/parameter_builder.rb +2 -2
  28. data/lib/sinclair/method_definition/parameter_helper.rb +2 -2
  29. data/lib/sinclair/method_definition.rb +8 -8
  30. data/lib/sinclair/method_definitions.rb +2 -2
  31. data/lib/sinclair/model/builder.rb +2 -2
  32. data/lib/sinclair/model.rb +4 -4
  33. data/lib/sinclair/options/class_methods.rb +0 -2
  34. data/lib/sinclair/options.rb +0 -2
  35. data/lib/sinclair/settable/builder.rb +1 -0
  36. data/lib/sinclair/settable.rb +1 -1
  37. data/lib/sinclair/version.rb +1 -1
  38. data/lib/sinclair.rb +6 -6
  39. data/sinclair.gemspec +3 -20
  40. data/spec/integration/readme/my_class_spec.rb +2 -2
  41. data/spec/integration/readme/sinclair/model_spec.rb +2 -2
  42. data/spec/integration/readme/sinclair/options_spec.rb +1 -1
  43. data/spec/integration/yard/sinclair/add_class_method_spec.rb +2 -2
  44. data/spec/integration/yard/sinclair/caster/cast_spec.rb +2 -2
  45. data/spec/integration/yard/sinclair/caster/cast_with_spec.rb +1 -1
  46. data/spec/integration/yard/sinclair/config_factory_spec.rb +4 -4
  47. data/spec/integration/yard/sinclair/core_ext/object_spec.rb +2 -2
  48. data/spec/lib/sinclair/chain_settable_spec.rb +1 -1
  49. data/spec/lib/sinclair/config_factory_spec.rb +1 -1
  50. data/spec/lib/sinclair/equals_checker/reader_spec.rb +1 -1
  51. data/spec/lib/sinclair/matchers/add_class_method_spec.rb +1 -1
  52. data/spec/lib/sinclair/matchers/add_class_method_to_spec.rb +1 -1
  53. data/spec/lib/sinclair/matchers/add_instance_method_spec.rb +1 -1
  54. data/spec/lib/sinclair/matchers/add_instance_method_to_spec.rb +1 -1
  55. data/spec/lib/sinclair/matchers/change_class_method_on_spec.rb +1 -1
  56. data/spec/lib/sinclair/matchers/change_class_method_spec.rb +1 -1
  57. data/spec/lib/sinclair/matchers/change_instance_method_on_spec.rb +1 -1
  58. data/spec/lib/sinclair/matchers/change_instance_method_spec.rb +1 -1
  59. data/spec/lib/sinclair/method_builder/base_spec.rb +1 -1
  60. data/spec/lib/sinclair/method_builder/block_method_builder_spec.rb +1 -1
  61. data/spec/lib/sinclair/method_builder/call_method_builder_spec.rb +1 -1
  62. data/spec/lib/sinclair/method_builder/string_method_builder_spec.rb +1 -1
  63. data/spec/lib/sinclair/method_definition_spec.rb +1 -0
  64. data/spec/lib/sinclair/method_definitions_spec.rb +9 -9
  65. data/spec/lib/sinclair/model_spec.rb +3 -3
  66. data/spec/lib/sinclair/options/class_methods_spec.rb +1 -1
  67. data/spec/lib/sinclair/options_spec.rb +3 -3
  68. data/spec/lib/sinclair/settable/builder_spec.rb +1 -1
  69. data/spec/spec_helper.rb +1 -1
  70. data/spec/support/models/default_valueable.rb +1 -1
  71. data/spec/support/models/env_settings.rb +1 -1
  72. data/spec/support/models/random_generator.rb +1 -1
  73. data/spec/support/shared_examples/model.rb +2 -2
  74. data/spec/support/shared_examples/settable.rb +2 -2
  75. metadata +11 -233
  76. /data/spec/integration/readme/{sinclair/types_of_definition_spec.rb → sinclair_types_of_definition_spec.rb} +0 -0
  77. /data/spec/integration/yard/sinclair/{class_methods/build_spec.rb → class_methods_build_spec.rb} +0 -0
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Sinclair
4
- VERSION = '2.1.1'
4
+ VERSION = '3.0.0'
5
5
  end
data/lib/sinclair.rb CHANGED
@@ -294,8 +294,8 @@ class Sinclair
294
294
  # person.bond_name # returns 'Bond, James Bond'
295
295
  #
296
296
  # @return [Array<MethodDefinition>] the list of all currently defined instance methods
297
- def add_method(*args, type: nil, **options, &block)
298
- definitions.add(*args, type: type, **options, &block)
297
+ def add_method(*, type: nil, **, &)
298
+ definitions.add(*, type:, **, &)
299
299
  end
300
300
 
301
301
  # Add a method to the method list to be created on klass
@@ -379,8 +379,8 @@ class Sinclair
379
379
  # env_fetcher.timeout # returns '10'
380
380
  #
381
381
  # @return [Array<MethodDefinition>] the list of all currently defined class methods
382
- def add_class_method(*args, type: nil, **options, &block)
383
- class_definitions.add(*args, type: type, **options, &block)
382
+ def add_class_method(*, type: nil, **, &)
383
+ class_definitions.add(*, type:, **, &)
384
384
  end
385
385
 
386
386
  # Evaluetes a block which will result in a String, the method code
@@ -453,8 +453,8 @@ class Sinclair
453
453
  #
454
454
  # Purchase.new(2.3, 5).total_price # returns 11.5
455
455
  # @return [Array<MethodDefinition>] the list of all currently defined instance methods
456
- def eval_and_add_method(name, &block)
457
- add_method(name, instance_eval(&block))
456
+ def eval_and_add_method(name, &)
457
+ add_method(name, instance_eval(&))
458
458
  end
459
459
 
460
460
  private
data/sinclair.gemspec CHANGED
@@ -12,29 +12,12 @@ Gem::Specification.new do |gem|
12
12
  gem.homepage = 'https://github.com/darthjee/sinclair'
13
13
  gem.description = 'Gem for easy concern creation'
14
14
  gem.summary = gem.description
15
- gem.required_ruby_version = '>= 2.5.0'
15
+ gem.required_ruby_version = '>= 3.3.1'
16
16
 
17
17
  gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
18
  gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- gem.test_files = gem.files.grep(%r{^(test|gem|features)/})
20
19
  gem.require_paths = ['lib']
20
+ gem.metadata['rubygems_mfa_required'] = 'false'
21
21
 
22
- gem.add_runtime_dependency 'activesupport', '~> 7.0.4'
23
-
24
- gem.add_development_dependency 'bundler', '>= 2.3.25'
25
- gem.add_development_dependency 'pry', '0.14.1'
26
- gem.add_development_dependency 'pry-nav', '1.0.0'
27
- gem.add_development_dependency 'rake', '13.0.1'
28
- gem.add_development_dependency 'reek', '6.0.3'
29
- gem.add_development_dependency 'rspec', '3.11.0'
30
- gem.add_development_dependency 'rspec-core', '3.11.0'
31
- gem.add_development_dependency 'rspec-expectations', '3.11.0'
32
- gem.add_development_dependency 'rspec-mocks', '3.11.1'
33
- gem.add_development_dependency 'rspec-support', '3.11.0'
34
- gem.add_development_dependency 'rubocop', '0.80.1'
35
- gem.add_development_dependency 'rubocop-rspec', '1.38.1'
36
- gem.add_development_dependency 'rubycritic', '4.7.0'
37
- gem.add_development_dependency 'simplecov', '0.21.2'
38
- gem.add_development_dependency 'yard', '0.9.27'
39
- gem.add_development_dependency 'yardstick', '0.9.9'
22
+ gem.add_dependency 'activesupport', '~> 7.2.x'
40
23
  end
@@ -10,9 +10,9 @@ describe MyClass do
10
10
  let(:age) { 20 }
11
11
  let(:attributes) do
12
12
  {
13
- name: name,
13
+ name:,
14
14
  surname: 'surname',
15
- age: age,
15
+ age:,
16
16
  legs: 2
17
17
  }
18
18
  end
@@ -11,14 +11,14 @@ describe Sinclair::Model do
11
11
  expect(human1.name).to eq('John Doe')
12
12
  expect(human1.age).to eq(22)
13
13
  expect(human1.gender).to eq(:undefined)
14
- expect(human1 == human2).to eq(true)
14
+ expect(human1 == human2).to be(true)
15
15
  end
16
16
 
17
17
  it 'Without comparable' do
18
18
  tv1 = Tv.new(model: 'Sans Sunga Xt')
19
19
  tv2 = Tv.new(model: 'Sans Sunga Xt')
20
20
 
21
- expect(tv1 == tv2).to eq(false)
21
+ expect(tv1 == tv2).to be(false)
22
22
  end
23
23
  end
24
24
  end
@@ -11,7 +11,7 @@ describe Sinclair::Options do
11
11
  )
12
12
 
13
13
  expect(options.timeout).to eq(10)
14
- expect(options.retries).to eq(nil)
14
+ expect(options.retries).to be_nil
15
15
  expect(options.protocol).to eq('http')
16
16
  expect(options.port).to eq(443)
17
17
  end
@@ -19,7 +19,7 @@ describe 'yard Sinclair#add_class_method' do
19
19
  describe 'Adding a method by Block' do
20
20
  it 'returns the timeout' do
21
21
  builder = Sinclair.new(klass)
22
- builder.add_class_method(:timeout) { ENV['TIMEOUT'] }
22
+ builder.add_class_method(:timeout) { ENV.fetch('TIMEOUT', nil) }
23
23
  builder.build
24
24
  ENV['TIMEOUT'] = '300'
25
25
 
@@ -30,7 +30,7 @@ describe 'yard Sinclair#add_class_method' do
30
30
  describe 'Passing type block' do
31
31
  it 'creates new method' do
32
32
  builder = Sinclair.new(klass)
33
- builder.add_class_method(:timeout, type: :block) { ENV['TIMEOUT'] }
33
+ builder.add_class_method(:timeout, type: :block) { ENV.fetch('TIMEOUT', nil) }
34
34
  builder.build
35
35
  ENV['TIMEOUT'] = '300'
36
36
 
@@ -15,8 +15,8 @@ describe 'yard Sinclair::Caster' do
15
15
  it 'Casts passing parameter' do
16
16
  base = Random.rand(3..6)
17
17
  initial = Random.rand(10..20)
18
- log = MathCaster.cast(initial, :log, base: base)
19
- exp = MathCaster.cast(log, :exp, base: base)
18
+ log = MathCaster.cast(initial, :log, base:)
19
+ exp = MathCaster.cast(log, :exp, base:)
20
20
 
21
21
  expect(exp).to be_between(initial - 0.0001, initial + 0.0001)
22
22
  end
@@ -45,7 +45,7 @@ describe 'yard Sinclair::Caster.cast_with' do
45
45
  values.map! do |config|
46
46
  value = config[:value]
47
47
  klass = config[:klass]
48
- my_caster.cast(value, klass, klass: klass)
48
+ my_caster.cast(value, klass, klass:)
49
49
  end
50
50
 
51
51
  expect(values[0]).to eq('{"name":"john","age":20,"country":"BR"}')
@@ -6,8 +6,8 @@ describe Sinclair::ConfigFactory do
6
6
  describe '#yard' do
7
7
  subject(:factory) do
8
8
  described_class.new(
9
- config_class: config_class,
10
- config_attributes: config_attributes
9
+ config_class:,
10
+ config_attributes:
11
11
  )
12
12
  end
13
13
 
@@ -74,13 +74,13 @@ describe Sinclair::ConfigFactory do
74
74
 
75
75
  describe 'Setting name with hash and block' do
76
76
  it 'sets name on config' do
77
- expect { factory.configure(email: email) { name 'John' } }
77
+ expect { factory.configure(email:) { name 'John' } }
78
78
  .to change(config, :name)
79
79
  .from(nil).to('John')
80
80
  end
81
81
 
82
82
  it 'sets email on config' do
83
- expect { factory.configure(email: email) { name 'John' } }
83
+ expect { factory.configure(email:) { name 'John' } }
84
84
  .to change(config, :email)
85
85
  .from(nil).to(email)
86
86
  end
@@ -7,8 +7,8 @@ describe Object do
7
7
  it do
8
8
  object = [1, 2, 3]
9
9
 
10
- expect(object.is_any?(Hash, Class)).to eq(false)
11
- expect(object.is_any?(Hash, Array)).to eq(true)
10
+ expect(object.is_any?(Hash, Class)).to be(false)
11
+ expect(object.is_any?(Hash, Array)).to be(true)
12
12
  end
13
13
  end
14
14
  end
@@ -69,7 +69,7 @@ describe Sinclair::ChainSettable do
69
69
 
70
70
  context 'when none has value' do
71
71
  let(:default) { 'some_default_username' }
72
- let(:options_hash) { { default: default } }
72
+ let(:options_hash) { { default: } }
73
73
 
74
74
  it 'returns the first value' do
75
75
  expect(settable.username).to eq(default)
@@ -153,7 +153,7 @@ describe Sinclair::ConfigFactory do
153
153
  end
154
154
 
155
155
  context 'when config class was set from common class' do
156
- subject(:factory) { described_class.new(config_class: config_class) }
156
+ subject(:factory) { described_class.new(config_class:) }
157
157
 
158
158
  let(:config_class) { Class.new }
159
159
 
@@ -6,7 +6,7 @@ describe Sinclair::EqualsChecker::Reader do
6
6
  subject(:reader) { described_class.new(attribute) }
7
7
 
8
8
  let(:attribute) { :information }
9
- let(:model) { SampleModel.new(name: name, age: age) }
9
+ let(:model) { SampleModel.new(name:, age:) }
10
10
  let(:name) { 'The Name' }
11
11
  let(:age) { 25 }
12
12
 
@@ -23,7 +23,7 @@ describe Sinclair::Matchers::AddClassMethod do
23
23
  expect { matcher.matches?(proc {}) }
24
24
  .to raise_error(
25
25
  SyntaxError, 'You should specify which class the method is being added to' \
26
- "add_class_method(:#{method}).to(klass)"
26
+ "add_class_method(:#{method}).to(klass)"
27
27
  )
28
28
  end
29
29
  end
@@ -60,7 +60,7 @@ describe Sinclair::Matchers::AddClassMethodTo do
60
60
  expect { matcher.matches?(event_proc) { 1 } }
61
61
  .to raise_error(
62
62
  SyntaxError, 'Block not received by the `add_class_method_to` matcher. ' \
63
- 'Perhaps you want to use `{ ... }` instead of do/end?'
63
+ 'Perhaps you want to use `{ ... }` instead of do/end?'
64
64
  )
65
65
  end
66
66
  end
@@ -25,7 +25,7 @@ describe Sinclair::Matchers::AddInstanceMethod do
25
25
  expect { matcher.matches?(proc {}) }
26
26
  .to raise_error(
27
27
  SyntaxError, 'You should specify which instance the method is being added to' \
28
- "add_method(:#{method}).to(instance)"
28
+ "add_method(:#{method}).to(instance)"
29
29
  )
30
30
  end
31
31
  end
@@ -69,7 +69,7 @@ describe Sinclair::Matchers::AddInstanceMethodTo do
69
69
  expect { matcher.matches?(event_proc) { 1 } }
70
70
  .to raise_error(
71
71
  SyntaxError, 'Block not received by the `add_instance_method_to` matcher. ' \
72
- 'Perhaps you want to use `{ ... }` instead of do/end?'
72
+ 'Perhaps you want to use `{ ... }` instead of do/end?'
73
73
  )
74
74
  end
75
75
  end
@@ -54,7 +54,7 @@ describe Sinclair::Matchers::ChangeClassMethodOn do
54
54
  expect { matcher.matches?(event_proc) { 1 } }
55
55
  .to raise_error(
56
56
  SyntaxError, 'Block not received by the `change_class_method_on` matcher. ' \
57
- 'Perhaps you want to use `{ ... }` instead of do/end?'
57
+ 'Perhaps you want to use `{ ... }` instead of do/end?'
58
58
  )
59
59
  end
60
60
  end
@@ -25,7 +25,7 @@ describe Sinclair::Matchers::ChangeClassMethod do
25
25
  expect { matcher.matches?(proc {}) }
26
26
  .to raise_error(
27
27
  SyntaxError, 'You should specify which class the method is being changed on' \
28
- "change_class_method(:#{method}).on(klass)"
28
+ "change_class_method(:#{method}).on(klass)"
29
29
  )
30
30
  end
31
31
  end
@@ -65,7 +65,7 @@ describe Sinclair::Matchers::ChangeInstanceMethodOn do
65
65
  expect { matcher.matches?(event_proc) { 1 } }
66
66
  .to raise_error(
67
67
  SyntaxError, 'Block not received by the `change_instance_method_on` matcher. ' \
68
- 'Perhaps you want to use `{ ... }` instead of do/end?'
68
+ 'Perhaps you want to use `{ ... }` instead of do/end?'
69
69
  )
70
70
  end
71
71
  end
@@ -25,7 +25,7 @@ describe Sinclair::Matchers::ChangeInstanceMethod do
25
25
  expect { matcher.matches?(proc {}) }
26
26
  .to raise_error(
27
27
  SyntaxError, 'You should specify which instance the method is being changed on' \
28
- "change_method(:#{method}).on(instance)"
28
+ "change_method(:#{method}).on(instance)"
29
29
  )
30
30
  end
31
31
  end
@@ -8,7 +8,7 @@ describe Sinclair::MethodBuilder::Base do
8
8
  let(:type) { Sinclair::MethodBuilder::CLASS_METHOD }
9
9
 
10
10
  it do
11
- expect { described_class.build(klass, instance_of(described_class), type: type) }
11
+ expect { described_class.build(klass, instance_of(described_class), type:) }
12
12
  .to raise_error(NotImplementedError)
13
13
  end
14
14
  end
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Sinclair::MethodBuilder::BlockMethodBuilder do
6
6
  describe '#build' do
7
7
  subject(:builder) do
8
- described_class.new(klass, definition, type: type)
8
+ described_class.new(klass, definition, type:)
9
9
  end
10
10
 
11
11
  let(:klass) { Class.new }
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Sinclair::MethodBuilder::CallMethodBuilder do
6
6
  describe '#build' do
7
7
  subject(:builder) do
8
- described_class.new(klass, definition, type: type)
8
+ described_class.new(klass, definition, type:)
9
9
  end
10
10
 
11
11
  let(:call_name) { "attr_#{accessor_type}" }
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Sinclair::MethodBuilder::StringMethodBuilder do
6
6
  describe '#build' do
7
7
  subject(:builder) do
8
- described_class.new(klass, definition, type: type)
8
+ described_class.new(klass, definition, type:)
9
9
  end
10
10
 
11
11
  let(:klass) { Class.new }
@@ -28,6 +28,7 @@ describe Sinclair::MethodDefinition do
28
28
  attr_reader :name
29
29
 
30
30
  def initialize(name)
31
+ super
31
32
  @name = name
32
33
  end
33
34
 
@@ -48,22 +48,22 @@ describe Sinclair::MethodDefinitions do
48
48
  let(:arguments) { %i[attr_reader some_attribute other_attribute] }
49
49
 
50
50
  it do
51
- expect(definitions.add(*arguments, type: type))
51
+ expect(definitions.add(*arguments, type:))
52
52
  .to be_a(Array)
53
53
  end
54
54
 
55
55
  it 'creates a new definition' do
56
- expect(definitions.add(*arguments, type: type).last)
56
+ expect(definitions.add(*arguments, type:).last)
57
57
  .to be_a(Sinclair::MethodDefinition)
58
58
  end
59
59
 
60
60
  it 'creates a new definition of the chosen type' do
61
- expect(definitions.add(*arguments, type: type).last)
61
+ expect(definitions.add(*arguments, type:).last)
62
62
  .to be_a(Sinclair::MethodDefinition::CallDefinition)
63
63
  end
64
64
 
65
65
  it 'initializes it correctly' do
66
- expect { klass.module_eval(&definitions.add(*arguments, type: type).last.code_block) }
66
+ expect { klass.module_eval(&definitions.add(*arguments, type:).last.code_block) }
67
67
  .to add_method(:some_attribute).to(klass)
68
68
  end
69
69
  end
@@ -89,7 +89,7 @@ describe Sinclair::MethodDefinitions do
89
89
  end
90
90
 
91
91
  it 'initializes it correctly' do
92
- expect(definitions.add(method_name, type: type, &block).last.name)
92
+ expect(definitions.add(method_name, type:, &block).last.name)
93
93
  .to eq(method_name)
94
94
  end
95
95
  end
@@ -100,22 +100,22 @@ describe Sinclair::MethodDefinitions do
100
100
  let(:code) { '10' }
101
101
 
102
102
  it do
103
- expect(definitions.add(method_name, code, type: type))
103
+ expect(definitions.add(method_name, code, type:))
104
104
  .to be_a(Array)
105
105
  end
106
106
 
107
107
  it 'creates a new definition' do
108
- expect(definitions.add(method_name, code, type: type).last)
108
+ expect(definitions.add(method_name, code, type:).last)
109
109
  .to be_a(Sinclair::MethodDefinition)
110
110
  end
111
111
 
112
112
  it 'creates a new definition of the chosen type' do
113
- expect(definitions.add(method_name, code, type: type).last)
113
+ expect(definitions.add(method_name, code, type:).last)
114
114
  .to be_a(Sinclair::MethodDefinition::StringDefinition)
115
115
  end
116
116
 
117
117
  it 'initializes it correctly' do
118
- expect(definitions.add(method_name, code, type: type).last.name)
118
+ expect(definitions.add(method_name, code, type:).last.name)
119
119
  .to eq(method_name)
120
120
  end
121
121
  end
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Sinclair::Model do
6
- subject(:model) { klass.new(name: name) }
6
+ subject(:model) { klass.new(name:) }
7
7
 
8
8
  let(:name) { SecureRandom.hex(10) }
9
9
  let(:attributes) { %i[name] }
@@ -55,7 +55,7 @@ describe Sinclair::Model do
55
55
  end
56
56
 
57
57
  context 'when class is subclass of another model' do
58
- subject(:model) { klass.new(name: name, age: age) }
58
+ subject(:model) { klass.new(name:, age:) }
59
59
 
60
60
  let(:age) { Random.rand(10..20) }
61
61
 
@@ -72,7 +72,7 @@ describe Sinclair::Model do
72
72
  end
73
73
 
74
74
  it 'is initialized with both attributes' do
75
- expect { klass.new(name: name, age: age) }
75
+ expect { klass.new(name:, age:) }
76
76
  .not_to raise_error
77
77
  end
78
78
 
@@ -107,7 +107,7 @@ describe Sinclair::Options::ClassMethods do
107
107
  .to change {
108
108
  klass.invalid_options_in(test_keys)
109
109
  }.from(%i[protocol port invalid])
110
- .to([:invalid])
110
+ .to([:invalid])
111
111
  end
112
112
 
113
113
  it do
@@ -20,7 +20,7 @@ describe Sinclair::Options do
20
20
 
21
21
  context 'when initializing with valid args' do
22
22
  subject(:options) do
23
- klass.new(timeout: timeout, protocol: 'http')
23
+ klass.new(timeout:, protocol: 'http')
24
24
  end
25
25
 
26
26
  let(:timeout) { Random.rand(10..19) }
@@ -44,7 +44,7 @@ describe Sinclair::Options do
44
44
 
45
45
  context 'when initializing subclass with valid args' do
46
46
  subject(:options) do
47
- klass.new(timeout: timeout, protocol: 'http')
47
+ klass.new(timeout:, protocol: 'http')
48
48
  end
49
49
 
50
50
  let(:klass) { Class.new(ConnectionOptions) }
@@ -142,7 +142,7 @@ describe Sinclair::Options do
142
142
  context 'when overriding values with false' do
143
143
  let(:options) { klass.new(protocol: false) }
144
144
 
145
- it { expect(options.protocol).to eq(false) }
145
+ it { expect(options.protocol).to be(false) }
146
146
  end
147
147
  end
148
148
 
@@ -16,7 +16,7 @@ describe Sinclair::Settable::Builder do
16
16
  let(:username) { 'my_login' }
17
17
  let(:password) { Random.rand(10_000).to_s }
18
18
  let(:settings) { %i[username password] }
19
- let(:options) { { prefix: prefix } }
19
+ let(:options) { { prefix: } }
20
20
 
21
21
  let(:builder) do
22
22
  described_class.new(settable, *settings, **options)
data/spec/spec_helper.rb CHANGED
@@ -14,7 +14,7 @@ require 'pry-nav'
14
14
 
15
15
  support_files = File.expand_path('spec/support/**/*.rb')
16
16
 
17
- Dir[support_files].sort.each { |file| require file }
17
+ Dir[support_files].each { |file| require file }
18
18
 
19
19
  RSpec.configure do |config|
20
20
  config.run_all_when_everything_filtered = true
@@ -5,7 +5,7 @@ require './spec/support/models/default_value_builder'
5
5
  module DefaultValueable
6
6
  def default_reader(*methods, value:, accept_nil: false)
7
7
  DefaultValueBuilder.new(
8
- self, value: value, accept_nil: accept_nil
8
+ self, value:, accept_nil:
9
9
  ).add_default_values(*methods)
10
10
  end
11
11
  end
@@ -13,7 +13,7 @@ module EnvSettings
13
13
  env_key = [env_prefix, method_name].compact.join('_').upcase
14
14
 
15
15
  builder.add_class_method(method_name, cached: true) do
16
- ENV[env_key]
16
+ ENV.fetch(env_key, nil)
17
17
  end
18
18
 
19
19
  builder.build
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RandomGenerator
4
- KAPA = 3.9 + Random.rand / 10.0
4
+ KAPA = 3.9 + (Random.rand / 10.0)
5
5
 
6
6
  class << self
7
7
  def rand
@@ -18,7 +18,7 @@ shared_examples 'sinclair model building' do
18
18
  end
19
19
 
20
20
  it 'returns a new class with a comparable that finds matches' do
21
- expect(model).to eq(klass.new(name: name))
21
+ expect(model).to eq(klass.new(name:))
22
22
  end
23
23
 
24
24
  it 'returns a new class with a comparable that find misses' do
@@ -48,7 +48,7 @@ shared_examples 'sinclair model building' do
48
48
  let(:options) { { comparable: false } }
49
49
 
50
50
  it 'returns a new class without comparable' do
51
- expect(model).not_to eq(klass.new(name: name))
51
+ expect(model).not_to eq(klass.new(name:))
52
52
  end
53
53
  end
54
54
 
@@ -35,7 +35,7 @@ shared_examples 'settings reading' do
35
35
 
36
36
  context 'when defining defaults' do
37
37
  let(:settings) { %i[host] }
38
- let(:options) { { prefix: prefix, default: 'my-host.com' } }
38
+ let(:options) { { prefix:, default: 'my-host.com' } }
39
39
 
40
40
  it 'returns default value' do
41
41
  expect(settable.host).to eq('my-host.com')
@@ -60,7 +60,7 @@ shared_examples 'settings reading' do
60
60
 
61
61
  context 'when defining a type' do
62
62
  let(:settings) { %i[port] }
63
- let(:options) { { prefix: prefix, type: :integer } }
63
+ let(:options) { { prefix:, type: :integer } }
64
64
  let(:port) { Random.rand(10..100) }
65
65
 
66
66
  context 'when the key is not set' do