sinclair 2.1.1 → 3.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.
Files changed (85) 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 +7 -6
  12. data/lib/sinclair/config_builder.rb +7 -7
  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 +21 -16
  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 +12 -6
  36. data/lib/sinclair/settable/caster.rb +2 -0
  37. data/lib/sinclair/settable.rb +10 -1
  38. data/lib/sinclair/version.rb +1 -1
  39. data/lib/sinclair.rb +30 -18
  40. data/sinclair.gemspec +3 -20
  41. data/spec/integration/readme/my_class_spec.rb +2 -2
  42. data/spec/integration/readme/sinclair/model_spec.rb +2 -2
  43. data/spec/integration/readme/sinclair/options_spec.rb +1 -1
  44. data/spec/integration/yard/sinclair/add_class_method_spec.rb +2 -2
  45. data/spec/integration/yard/sinclair/caster/cast_spec.rb +2 -2
  46. data/spec/integration/yard/sinclair/caster/cast_with_spec.rb +1 -1
  47. data/spec/integration/yard/sinclair/config_factory_spec.rb +4 -4
  48. data/spec/integration/yard/sinclair/core_ext/object_spec.rb +2 -2
  49. data/spec/lib/sinclair/chain_settable_spec.rb +10 -2
  50. data/spec/lib/sinclair/config_factory_spec.rb +1 -1
  51. data/spec/lib/sinclair/env_settable_spec.rb +4 -0
  52. data/spec/lib/sinclair/equals_checker/reader_spec.rb +1 -1
  53. data/spec/lib/sinclair/matchers/add_class_method_spec.rb +1 -1
  54. data/spec/lib/sinclair/matchers/add_class_method_to_spec.rb +1 -1
  55. data/spec/lib/sinclair/matchers/add_instance_method_spec.rb +1 -1
  56. data/spec/lib/sinclair/matchers/add_instance_method_to_spec.rb +1 -1
  57. data/spec/lib/sinclair/matchers/change_class_method_on_spec.rb +1 -1
  58. data/spec/lib/sinclair/matchers/change_class_method_spec.rb +1 -1
  59. data/spec/lib/sinclair/matchers/change_instance_method_on_spec.rb +1 -1
  60. data/spec/lib/sinclair/matchers/change_instance_method_spec.rb +1 -1
  61. data/spec/lib/sinclair/method_builder/base_spec.rb +1 -1
  62. data/spec/lib/sinclair/method_builder/block_method_builder_spec.rb +1 -1
  63. data/spec/lib/sinclair/method_builder/call_method_builder_spec.rb +1 -1
  64. data/spec/lib/sinclair/method_builder/string_method_builder_spec.rb +1 -1
  65. data/spec/lib/sinclair/method_definition_spec.rb +1 -0
  66. data/spec/lib/sinclair/method_definitions_spec.rb +9 -9
  67. data/spec/lib/sinclair/model_spec.rb +3 -3
  68. data/spec/lib/sinclair/options/class_methods_spec.rb +1 -1
  69. data/spec/lib/sinclair/options_spec.rb +3 -3
  70. data/spec/lib/sinclair/settable/builder_spec.rb +5 -1
  71. data/spec/lib/sinclair/settable/caster_spec.rb +79 -0
  72. data/spec/lib/sinclair/settable_spec.rb +6 -0
  73. data/spec/spec_helper.rb +1 -1
  74. data/spec/support/models/app_client.rb +2 -0
  75. data/spec/support/models/default_valueable.rb +1 -1
  76. data/spec/support/models/env_settings.rb +1 -1
  77. data/spec/support/models/hash_app_client.rb +2 -0
  78. data/spec/support/models/my_app_client.rb +2 -0
  79. data/spec/support/models/non_default_app_client.rb +2 -0
  80. data/spec/support/models/random_generator.rb +1 -1
  81. data/spec/support/shared_examples/model.rb +2 -2
  82. data/spec/support/shared_examples/settable.rb +139 -12
  83. metadata +12 -233
  84. /data/spec/integration/readme/{sinclair/types_of_definition_spec.rb → sinclair_types_of_definition_spec.rb} +0 -0
  85. /data/spec/integration/yard/sinclair/{class_methods/build_spec.rb → class_methods_build_spec.rb} +0 -0
@@ -51,9 +51,9 @@ class Sinclair
51
51
  # job.state # returns :done
52
52
  #
53
53
  # @return [Class<Model>] a new class with the chosen attributes
54
- def for(*attributes, **options)
54
+ def for(*attributes, **)
55
55
  Class.new(self) do |klass|
56
- Builder.new(klass, *attributes, **options).build
56
+ Builder.new(klass, *attributes, **).build
57
57
  end
58
58
  end
59
59
 
@@ -100,8 +100,8 @@ class Sinclair
100
100
  # job.state # returns :done
101
101
  #
102
102
  # @return [Array<MethodDefinition>]
103
- def initialize_with(*attributes, **options)
104
- Builder.new(self, *attributes, **options).build
103
+ def initialize_with(*attributes, **)
104
+ Builder.new(self, *attributes, **).build
105
105
  end
106
106
  end
107
107
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'set'
4
-
5
3
  class Sinclair
6
4
  class Options
7
5
  # Class Methods for {Sinclair::Options}
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'set'
4
-
5
3
  class Sinclair
6
4
  # @api public
7
5
  # @author Darthjee
@@ -21,6 +21,10 @@ class Sinclair
21
21
  #
22
22
  # @option options type [Symbol] type to cast the value fetched
23
23
  # @option options default [Object] Default value
24
+ # @option options cached [Boolean, Symbol] Flag informing if value
25
+ # is cached or not.
26
+ # If +true+ the value is cached unless it is +nil+ or +false+.
27
+ # If +:full+ the value is cached even if it is +nil+ or +false+.
24
28
  def initialize(klass, *settings_name, **options)
25
29
  super(klass, **options)
26
30
 
@@ -62,6 +66,7 @@ class Sinclair
62
66
  alias read_block read_with
63
67
 
64
68
  attr_reader :settings
69
+
65
70
  # @method settings
66
71
  # @private
67
72
  # @api private
@@ -88,13 +93,14 @@ class Sinclair
88
93
  #
89
94
  # @return (see Sinclair#add_class_method)
90
95
  def add_setting_method(name)
91
- options = call_options
92
- block = read_block
93
- caster = caster_class.caster_for(type)
94
- default = options_object.default
96
+ read_options = call_options
97
+ block = read_block
98
+ caster = caster_class.caster_for(type)
99
+ default = options_object.default
100
+ cached = options.key?(:cached) ? options[:cached] : :full
95
101
 
96
- add_class_method(name, cached: :full) do
97
- value = instance_exec(name, **options, &block)
102
+ add_class_method(name, cached:) do
103
+ value = instance_exec(name, **read_options, &block)
98
104
 
99
105
  value ? caster.cast(value) : default
100
106
  end
@@ -56,6 +56,8 @@ class Sinclair
56
56
  cast_with(:integer, &:to_i)
57
57
  cast_with(:string, &:to_s)
58
58
  cast_with(:float, &:to_f)
59
+ cast_with(:seconds) { |value| value.to_i.seconds }
60
+ cast_with(:boolean) { |value| value.to_s.downcase == 'true' }
59
61
  end
60
62
  end
61
63
  end
@@ -78,7 +78,7 @@ class Sinclair
78
78
  setting_with_options(*settings_name)
79
79
 
80
80
  defaults.each do |key, default|
81
- setting_with_options(key, default: default)
81
+ setting_with_options(key, default:)
82
82
  end
83
83
  end
84
84
 
@@ -92,7 +92,16 @@ class Sinclair
92
92
  # to be added
93
93
  # @param options [Hash<Symbol, Object>] setting exposition options
94
94
  # @option options type [Symbol] type to cast the value fetched
95
+ # - integer: converts to Integer
96
+ # - string: converts to String
97
+ # - float: converts to Float
98
+ # - seconds: converts to ActiveSupport::Duration in seconds
99
+ # - boolean: converts to Boolean (true/false)
95
100
  # @option options default [Object] Default value
101
+ # @option options cached [Boolean, Symbol] Flag informing if value
102
+ # is cached or not.
103
+ # If +true+ the value is cached unless it is +nil+ or +false+.
104
+ # If +:full+ the value is cached even if it is +nil+ or +false+.
96
105
  #
97
106
  # @see with_settings
98
107
  # @return (see Sinclair#build)
@@ -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.1'
5
5
  end
data/lib/sinclair.rb CHANGED
@@ -205,8 +205,10 @@ class Sinclair
205
205
  # @param name [String,Symbol] name of the method to be added
206
206
  # @param code [String] code to be evaluated when the method is ran
207
207
  # @param options [Hash] Options of construction
208
- # @option options cached [Boolean] Flag telling to create
209
- # a method with cache
208
+ # @option options cached [Boolean, Symbol] Flag informing if value
209
+ # is cached or not.
210
+ # If +true+ the value is cached unless it is +nil+ or +false+.
211
+ # If +:full+ the value is cached even if it is +nil+ or +false+
210
212
  # @see MethodDefinition::StringDefinition
211
213
  #
212
214
  # @example Using string code to add a string defined method
@@ -229,8 +231,10 @@ class Sinclair
229
231
  # @param name [String,Symbol] name of the method to be added
230
232
  # @param block [Proc] block to be ran as method
231
233
  # @param options [Hash] Options of construction
232
- # @option options cached [Boolean] Flag telling to create
233
- # a method with cache
234
+ # @option options cached [Boolean, Symbol] Flag informing if value
235
+ # is cached or not.
236
+ # If +true+ the value is cached unless it is +nil+ or +false+.
237
+ # If +:full+ the value is cached even if it is +nil+ or +false+
234
238
  # @see MethodDefinition::BlockDefinition
235
239
  #
236
240
  # @example Using block to add a block method
@@ -254,8 +258,10 @@ class Sinclair
254
258
  # @param type [Symbol] type of method definition
255
259
  # @param block [Proc] block to be ran as method when type is block
256
260
  # @param options [Hash] Options of construction
257
- # @option options cached [Boolean] Flag telling to create
258
- # a method with cache
261
+ # @option options cached [Boolean, Symbol] Flag informing if value
262
+ # is cached or not.
263
+ # If +true+ the value is cached unless it is +nil+ or +false+.
264
+ # If +:full+ the value is cached even if it is +nil+ or +false+
259
265
  # @see MethodDefinition::BlockDefinition
260
266
  # @see MethodDefinition::StringDefinition
261
267
  # @see MethodDefinition::CallDefinition
@@ -294,8 +300,8 @@ class Sinclair
294
300
  # person.bond_name # returns 'Bond, James Bond'
295
301
  #
296
302
  # @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)
303
+ def add_method(*, type: nil, **, &)
304
+ definitions.add(*, type:, **, &)
299
305
  end
300
306
 
301
307
  # Add a method to the method list to be created on klass
@@ -305,8 +311,10 @@ class Sinclair
305
311
  # @param name [String,Symbol] name of the method to be added
306
312
  # @param code [String] code to be evaluated when the method is ran
307
313
  # @param options [Hash] Options of construction
308
- # @option options cached [Boolean] Flag telling to create
309
- # a method with cache
314
+ # @option options cached [Boolean, Symbol] Flag informing if value
315
+ # is cached or not.
316
+ # If +true+ the value is cached unless it is +nil+ or +false+.
317
+ # If +:full+ the value is cached even if it is +nil+ or +false+
310
318
  #
311
319
  # @example Adding a method by String
312
320
  # class EnvFetcher
@@ -325,8 +333,10 @@ class Sinclair
325
333
  # @param name [String,Symbol] name of the method to be added
326
334
  # @param block [Proc] block to be ran as method
327
335
  # @param options [Hash] Options of construction
328
- # @option options cached [Boolean] Flag telling to create
329
- # a method with cache
336
+ # @option options cached [Boolean, Symbol] Flag informing if value
337
+ # is cached or not.
338
+ # If +true+ the value is cached unless it is +nil+ or +false+.
339
+ # If +:full+ the value is cached even if it is +nil+ or +false+
330
340
  #
331
341
  # @example Adding a method by Block
332
342
  # class EnvFetcher
@@ -346,8 +356,10 @@ class Sinclair
346
356
  # @param type [Symbol] type of method definition
347
357
  # @param block [Proc] block to be ran as method when type is block
348
358
  # @param options [Hash] Options of construction
349
- # @option options cached [Boolean] Flag telling to create
350
- # a method with cache
359
+ # @option options cached [Boolean, Symbol] Flag informing if value
360
+ # is cached or not.
361
+ # If +true+ the value is cached unless it is +nil+ or +false+.
362
+ # If +:full+ the value is cached even if it is +nil+ or +false+
351
363
  # @see MethodDefinition::BlockDefinition
352
364
  # @see MethodDefinition::StringDefinition
353
365
  # @see MethodDefinition::CallDefinition
@@ -379,8 +391,8 @@ class Sinclair
379
391
  # env_fetcher.timeout # returns '10'
380
392
  #
381
393
  # @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)
394
+ def add_class_method(*, type: nil, **, &)
395
+ class_definitions.add(*, type:, **, &)
384
396
  end
385
397
 
386
398
  # Evaluetes a block which will result in a String, the method code
@@ -453,8 +465,8 @@ class Sinclair
453
465
  #
454
466
  # Purchase.new(2.3, 5).total_price # returns 11.5
455
467
  # @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))
468
+ def eval_and_add_method(name, &)
469
+ add_method(name, instance_eval(&))
458
470
  end
459
471
 
460
472
  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
@@ -13,7 +13,9 @@ describe Sinclair::ChainSettable do
13
13
  source :app_client, env_setting
14
14
  source :my_app_client, Class.new(MyAppClient)
15
15
 
16
- setting_with_options :username, :password, :host, :port, **options
16
+ setting_with_options :username, :password,
17
+ :host, :port, :domain,
18
+ :secret, **options
17
19
  end
18
20
  end
19
21
 
@@ -21,12 +23,15 @@ describe Sinclair::ChainSettable do
21
23
  let(:options_hash) { {} }
22
24
  let(:username) { 'my_login' }
23
25
  let(:password) { Random.rand(10_000).to_s }
26
+ let(:prefix) { '' }
24
27
 
25
28
  context 'when the first setting finds the data' do
26
29
  let(:username_key) { 'USERNAME' }
27
30
  let(:password_key) { 'PASSWORD' }
28
31
  let(:host_key) { 'HOST' }
29
32
  let(:port_key) { 'PORT' }
33
+ let(:domain_key) { 'DOMAIN' }
34
+ let(:secret_key) { 'SECRET' }
30
35
 
31
36
  it_behaves_like 'settings reading'
32
37
  end
@@ -36,6 +41,9 @@ describe Sinclair::ChainSettable do
36
41
  let(:password_key) { 'MY_APP_PASSWORD' }
37
42
  let(:host_key) { 'MY_APP_HOST' }
38
43
  let(:port_key) { 'MY_APP_PORT' }
44
+ let(:domain_key) { 'MY_APP_DOMAIN' }
45
+ let(:secret_key) { 'MY_APP_SECRET' }
46
+ let(:prefix) { 'MY_APP_' }
39
47
 
40
48
  it_behaves_like 'settings reading'
41
49
  end
@@ -69,7 +77,7 @@ describe Sinclair::ChainSettable do
69
77
 
70
78
  context 'when none has value' do
71
79
  let(:default) { 'some_default_username' }
72
- let(:options_hash) { { default: default } }
80
+ let(:options_hash) { { default: } }
73
81
 
74
82
  it 'returns the first value' do
75
83
  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
 
@@ -12,6 +12,8 @@ describe Sinclair::EnvSettable do
12
12
  let(:password_key) { 'PASSWORD' }
13
13
  let(:host_key) { 'HOST' }
14
14
  let(:port_key) { 'PORT' }
15
+ let(:domain_key) { 'DOMAIN' }
16
+ let(:secret_key) { 'SECRET' }
15
17
 
16
18
  it_behaves_like 'settings reading'
17
19
 
@@ -22,6 +24,8 @@ describe Sinclair::EnvSettable do
22
24
  let(:password_key) { 'MY_APP_PASSWORD' }
23
25
  let(:host_key) { 'MY_APP_HOST' }
24
26
  let(:port_key) { 'MY_APP_PORT' }
27
+ let(:domain_key) { 'MY_APP_DOMAIN' }
28
+ let(:secret_key) { 'MY_APP_SECRET' }
25
29
 
26
30
  it_behaves_like 'settings reading'
27
31
  end
@@ -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