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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +3 -3
- data/.rubocop.yml +33 -1
- data/.rubocop_todo.yml +13 -1
- data/Dockerfile +2 -3
- data/Gemfile +17 -0
- data/Makefile +6 -0
- data/README.md +3 -3
- data/lib/sinclair/caster/class_methods.rb +6 -6
- data/lib/sinclair/chain_settable.rb +1 -1
- data/lib/sinclair/class_methods.rb +7 -6
- data/lib/sinclair/config_builder.rb +7 -7
- data/lib/sinclair/config_class.rb +3 -3
- data/lib/sinclair/config_factory.rb +7 -6
- data/lib/sinclair/configurable.rb +5 -5
- data/lib/sinclair/env_settable.rb +1 -1
- data/lib/sinclair/equals_checker.rb +1 -3
- data/lib/sinclair/exception.rb +1 -0
- data/lib/sinclair/input_hash.rb +3 -2
- data/lib/sinclair/matchers/add_class_method_to.rb +1 -1
- data/lib/sinclair/matchers/add_instance_method_to.rb +1 -1
- data/lib/sinclair/matchers/base.rb +2 -1
- data/lib/sinclair/matchers/change_class_method_on.rb +1 -1
- data/lib/sinclair/matchers/change_instance_method_on.rb +1 -1
- data/lib/sinclair/method_builder/base.rb +2 -1
- data/lib/sinclair/method_definition/block_helper.rb +4 -4
- data/lib/sinclair/method_definition/parameter_builder.rb +2 -2
- data/lib/sinclair/method_definition/parameter_helper.rb +2 -2
- data/lib/sinclair/method_definition.rb +21 -16
- data/lib/sinclair/method_definitions.rb +2 -2
- data/lib/sinclair/model/builder.rb +2 -2
- data/lib/sinclair/model.rb +4 -4
- data/lib/sinclair/options/class_methods.rb +0 -2
- data/lib/sinclair/options.rb +0 -2
- data/lib/sinclair/settable/builder.rb +12 -6
- data/lib/sinclair/settable/caster.rb +2 -0
- data/lib/sinclair/settable.rb +10 -1
- data/lib/sinclair/version.rb +1 -1
- data/lib/sinclair.rb +30 -18
- data/sinclair.gemspec +3 -20
- data/spec/integration/readme/my_class_spec.rb +2 -2
- data/spec/integration/readme/sinclair/model_spec.rb +2 -2
- data/spec/integration/readme/sinclair/options_spec.rb +1 -1
- data/spec/integration/yard/sinclair/add_class_method_spec.rb +2 -2
- data/spec/integration/yard/sinclair/caster/cast_spec.rb +2 -2
- data/spec/integration/yard/sinclair/caster/cast_with_spec.rb +1 -1
- data/spec/integration/yard/sinclair/config_factory_spec.rb +4 -4
- data/spec/integration/yard/sinclair/core_ext/object_spec.rb +2 -2
- data/spec/lib/sinclair/chain_settable_spec.rb +10 -2
- data/spec/lib/sinclair/config_factory_spec.rb +1 -1
- data/spec/lib/sinclair/env_settable_spec.rb +4 -0
- data/spec/lib/sinclair/equals_checker/reader_spec.rb +1 -1
- data/spec/lib/sinclair/matchers/add_class_method_spec.rb +1 -1
- data/spec/lib/sinclair/matchers/add_class_method_to_spec.rb +1 -1
- data/spec/lib/sinclair/matchers/add_instance_method_spec.rb +1 -1
- data/spec/lib/sinclair/matchers/add_instance_method_to_spec.rb +1 -1
- data/spec/lib/sinclair/matchers/change_class_method_on_spec.rb +1 -1
- data/spec/lib/sinclair/matchers/change_class_method_spec.rb +1 -1
- data/spec/lib/sinclair/matchers/change_instance_method_on_spec.rb +1 -1
- data/spec/lib/sinclair/matchers/change_instance_method_spec.rb +1 -1
- data/spec/lib/sinclair/method_builder/base_spec.rb +1 -1
- data/spec/lib/sinclair/method_builder/block_method_builder_spec.rb +1 -1
- data/spec/lib/sinclair/method_builder/call_method_builder_spec.rb +1 -1
- data/spec/lib/sinclair/method_builder/string_method_builder_spec.rb +1 -1
- data/spec/lib/sinclair/method_definition_spec.rb +1 -0
- data/spec/lib/sinclair/method_definitions_spec.rb +9 -9
- data/spec/lib/sinclair/model_spec.rb +3 -3
- data/spec/lib/sinclair/options/class_methods_spec.rb +1 -1
- data/spec/lib/sinclair/options_spec.rb +3 -3
- data/spec/lib/sinclair/settable/builder_spec.rb +5 -1
- data/spec/lib/sinclair/settable/caster_spec.rb +79 -0
- data/spec/lib/sinclair/settable_spec.rb +6 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/models/app_client.rb +2 -0
- data/spec/support/models/default_valueable.rb +1 -1
- data/spec/support/models/env_settings.rb +1 -1
- data/spec/support/models/hash_app_client.rb +2 -0
- data/spec/support/models/my_app_client.rb +2 -0
- data/spec/support/models/non_default_app_client.rb +2 -0
- data/spec/support/models/random_generator.rb +1 -1
- data/spec/support/shared_examples/model.rb +2 -2
- data/spec/support/shared_examples/settable.rb +139 -12
- metadata +12 -233
- /data/spec/integration/readme/{sinclair/types_of_definition_spec.rb → sinclair_types_of_definition_spec.rb} +0 -0
- /data/spec/integration/yard/sinclair/{class_methods/build_spec.rb → class_methods_build_spec.rb} +0 -0
data/lib/sinclair/model.rb
CHANGED
@@ -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, **
|
54
|
+
def for(*attributes, **)
|
55
55
|
Class.new(self) do |klass|
|
56
|
-
Builder.new(klass, *attributes, **
|
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, **
|
104
|
-
Builder.new(self, *attributes, **
|
103
|
+
def initialize_with(*attributes, **)
|
104
|
+
Builder.new(self, *attributes, **).build
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
data/lib/sinclair/options.rb
CHANGED
@@ -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
|
-
|
92
|
-
block
|
93
|
-
caster
|
94
|
-
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:
|
97
|
-
value = instance_exec(name, **
|
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
|
data/lib/sinclair/settable.rb
CHANGED
@@ -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:
|
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)
|
data/lib/sinclair/version.rb
CHANGED
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
|
209
|
-
#
|
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
|
233
|
-
#
|
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
|
258
|
-
#
|
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(
|
298
|
-
definitions.add(
|
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
|
309
|
-
#
|
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
|
329
|
-
#
|
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
|
350
|
-
#
|
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(
|
383
|
-
class_definitions.add(
|
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, &
|
457
|
-
add_method(name, instance_eval(&
|
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 = '>=
|
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.
|
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
|
@@ -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
|
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
|
21
|
+
expect(tv1 == tv2).to be(false)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
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
|
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
|
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:
|
19
|
-
exp = MathCaster.cast(log, :exp, 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:
|
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
|
10
|
-
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:
|
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:
|
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
|
11
|
-
expect(object.is_any?(Hash, Array)).to
|
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,
|
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:
|
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:
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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:
|
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::CallMethodBuilder do
|
6
6
|
describe '#build' do
|
7
7
|
subject(:builder) do
|
8
|
-
described_class.new(klass, definition, type:
|
8
|
+
described_class.new(klass, definition, type:)
|
9
9
|
end
|
10
10
|
|
11
11
|
let(:call_name) { "attr_#{accessor_type}" }
|