sinclair 1.8.0 → 1.10.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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +20 -6
  3. data/.rubocop.yml +5 -2
  4. data/Dockerfile +1 -1
  5. data/README.md +25 -1
  6. data/config/check_specs.yml +1 -0
  7. data/config/yardstick.yml +9 -1
  8. data/lib/sinclair/comparable/class_methods.rb +33 -0
  9. data/lib/sinclair/comparable.rb +47 -0
  10. data/lib/sinclair/config_builder.rb +4 -2
  11. data/lib/sinclair/configurable.rb +2 -0
  12. data/lib/sinclair/equals_checker.rb +110 -0
  13. data/lib/sinclair/matchers/add_class_method.rb +27 -36
  14. data/lib/sinclair/matchers/add_instance_method.rb +59 -59
  15. data/lib/sinclair/matchers/add_method.rb +33 -35
  16. data/lib/sinclair/matchers/change_class_method.rb +22 -16
  17. data/lib/sinclair/matchers/change_instance_method.rb +46 -16
  18. data/lib/sinclair/matchers.rb +2 -8
  19. data/lib/sinclair/method_builder/call_method_builder.rb +49 -0
  20. data/lib/sinclair/method_builder.rb +4 -1
  21. data/lib/sinclair/method_definition/call_definition.rb +52 -0
  22. data/lib/sinclair/method_definition/string_definition.rb +0 -2
  23. data/lib/sinclair/method_definition.rb +40 -24
  24. data/lib/sinclair/method_definitions.rb +21 -1
  25. data/lib/sinclair/options/builder.rb +8 -0
  26. data/lib/sinclair/options.rb +1 -13
  27. data/lib/sinclair/version.rb +1 -1
  28. data/lib/sinclair.rb +2 -0
  29. data/sinclair.gemspec +1 -1
  30. data/spec/integration/readme/sinclair/comparable_spec.rb +24 -0
  31. data/spec/integration/yard/sinclair/comparable_spec.rb +24 -0
  32. data/spec/integration/yard/sinclair/equals_checker_spec.rb +51 -0
  33. data/spec/integration/yard/sinclair/matchers/change_class_method_spec.rb +24 -0
  34. data/spec/integration/yard/sinclair/matchers/change_instance_method_spec.rb +40 -0
  35. data/spec/lib/sinclair/comparable_spec.rb +202 -0
  36. data/spec/lib/sinclair/equals_checker_spec.rb +148 -0
  37. data/spec/lib/sinclair/method_builder/call_method_builder_spec.rb +76 -0
  38. data/spec/lib/sinclair/method_builder_spec.rb +63 -20
  39. data/spec/lib/sinclair/method_definition/call_definition_spec.rb +36 -0
  40. data/spec/lib/sinclair/method_definition_spec.rb +64 -0
  41. data/spec/lib/sinclair/method_definitions_spec.rb +79 -0
  42. data/spec/lib/sinclair/options/builder_spec.rb +13 -0
  43. data/spec/lib/sinclair/options/class_methods_spec.rb +23 -8
  44. data/spec/support/sample_model.rb +19 -0
  45. data/spec/support/shared_examples/attribute_accessor.rb +103 -0
  46. metadata +21 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c06e4b7038a22a311b6ee13f1b8fd2df24211d8953982035df626dba8fb66c5
4
- data.tar.gz: b19227562faa97bca59e76d997998917068ccb2d230a0b90dfa76140f2032209
3
+ metadata.gz: 4a3575c54efcf82ce477b70a6a34b6f6d37d6242b2c272454b141942ee90e381
4
+ data.tar.gz: fdae2230f95d50d239537f01dace6b278b7930cef96115667b424910d7106c78
5
5
  SHA512:
6
- metadata.gz: 87daf64f9e084ef37bb47efee4fb6ff174e70cfdf5005e506acdff45647fd4ad502b348b23c6a3bbb1cce09676c14d7be52cc816b493fdbb4c92d23b94b33ecf
7
- data.tar.gz: 3d02e09271942cd50dc21eb9e9578b63db0374196e084b3ce9b54e3d816206731a88f8cb470581d791ecaf5a0f7a5435d2489ecf7465fa446b56d8f8c8b6dd24
6
+ metadata.gz: 424c2bd3b847482b32b45da5f3778c724c967fff11a14fdb5664e1d9b61fd0c484dc00e5f938739ffa46d3f04fcce7614ee9ed55b2fa3c3151af24a543b9d20e
7
+ data.tar.gz: 5094b1a51ae631f01163015b97131f7aaf78b349ca959f326823939de6b4205da8d64d750fad32837bdb28e74b76888644cf1518d9d51cdd2baba5318f61e595
data/.circleci/config.yml CHANGED
@@ -7,8 +7,12 @@ workflows:
7
7
  filters:
8
8
  tags:
9
9
  only: /.*/
10
+ - checks:
11
+ filters:
12
+ tags:
13
+ only: /.*/
10
14
  - build-and-release:
11
- requires: [test]
15
+ requires: [test, checks]
12
16
  filters:
13
17
  tags:
14
18
  only: /\d+\.\d+\.\d+/
@@ -18,7 +22,7 @@ workflows:
18
22
  jobs:
19
23
  test:
20
24
  docker:
21
- - image: darthjee/circleci_ruby_270:1.1.0
25
+ - image: darthjee/circleci_ruby_270:1.2.0
22
26
  environment:
23
27
  PROJECT: sinclair
24
28
  steps:
@@ -32,12 +36,22 @@ jobs:
32
36
  - run:
33
37
  name: RSpec
34
38
  command: bundle exec rspec
35
- - run:
36
- name: Rubocop
37
- command: rubocop
38
39
  - run:
39
40
  name: Coverage Test Report
40
41
  command: cc-test-reporter after-build --exit-code $?
42
+ checks:
43
+ docker:
44
+ - image: darthjee/circleci_ruby_270:1.2.0
45
+ environment:
46
+ PROJECT: sinclair
47
+ steps:
48
+ - checkout
49
+ - run:
50
+ name: Bundle Install
51
+ command: bundle install
52
+ - run:
53
+ name: Rubocop
54
+ command: rubocop
41
55
  - run:
42
56
  name: Yardstick coverage check
43
57
  command: bundle exec rake verify_measurements
@@ -52,7 +66,7 @@ jobs:
52
66
  command: check_specs
53
67
  build-and-release:
54
68
  docker:
55
- - image: darthjee/circleci_ruby_270:1.1.0
69
+ - image: darthjee/circleci_ruby_270:1.2.0
56
70
  environment:
57
71
  PROJECT: sinclair
58
72
  steps:
data/.rubocop.yml CHANGED
@@ -10,7 +10,7 @@ Metrics/BlockLength:
10
10
  - 'spec/support/**/*.rb'
11
11
  - '*.gemspec'
12
12
 
13
- Metrics/LineLength:
13
+ Layout/LineLength:
14
14
  Max: 100
15
15
 
16
16
  Lint/AmbiguousBlockAssociation:
@@ -20,6 +20,9 @@ Lint/AmbiguousBlockAssociation:
20
20
  RSpec/AlignLeftLetBrace:
21
21
  Enabled: true
22
22
 
23
+ RSpec/PredicateMatcher:
24
+ Exclude:
25
+ - 'spec/integration/yard/**/*_spec.rb'
23
26
 
24
27
  RSpec/DescribedClass:
25
28
  Exclude:
@@ -37,7 +40,7 @@ RSpec/MultipleExpectations:
37
40
  - spec/lib/sinclair_spec.rb
38
41
 
39
42
  RSpec/NestedGroups:
40
- Max: 4
43
+ Max: 5
41
44
  Exclude:
42
45
  - spec/integration/yard/**/*.rb
43
46
 
data/Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
1
  FROM darthjee/scripts:0.3.1 as scripts
2
2
 
3
- FROM darthjee/ruby_270:1.1.0 as base
3
+ FROM darthjee/ruby_270:1.2.0 as base
4
4
 
5
5
  COPY --chown=app:app ./ /home/app/app/
6
6
 
data/README.md CHANGED
@@ -13,9 +13,11 @@ This gem helps the creation of complex gems/concerns
13
13
  that enables creation of methods on the fly through class
14
14
  methods
15
15
 
16
+ Next release: [1.11.0](https://github.com/darthjee/sinclair/compare/1.10.0...master)
17
+
16
18
  Yard Documentation
17
19
  -------------------
18
- [https://www.rubydoc.info/gems/sinclair/1.8.0](https://www.rubydoc.info/gems/sinclair/1.8.0)
20
+ [https://www.rubydoc.info/gems/sinclair/1.10.0](https://www.rubydoc.info/gems/sinclair/1.10.0)
19
21
 
20
22
  Installation
21
23
  ---------------
@@ -475,6 +477,28 @@ Options allows projects to have an easy to configure option object
475
477
  ConnectionOptions.new(invalid: 10) # raises Sinclair::Exception::InvalidOptions
476
478
  ```
477
479
 
480
+ ### Sinclair::Comparable
481
+ Comparable allows a class to implement quickly a `==` method comparing given attributes
482
+
483
+ ```ruby
484
+ class SampleModel
485
+ include Sinclair::Comparable
486
+
487
+ comparable_by :name
488
+ attr_reader :name, :age
489
+
490
+ def initialize(name: nil, age: nil)
491
+ @name = name
492
+ @age = age
493
+ end
494
+ end
495
+
496
+ model1 = model_class.new(name: 'jack', age: 21)
497
+ model2 = model_class.new(name: 'jack', age: 23)
498
+
499
+ model1 == model2 # returns true
500
+ ```
501
+
478
502
  RSspec matcher
479
503
  ---------------
480
504
 
@@ -1,4 +1,5 @@
1
1
  ignore:
2
+ - lib/sinclair/comparable/class_methods.rb
2
3
  - lib/sinclair/matchers/add_method_to.rb
3
4
  - lib/sinclair/matchers/add_method.rb
4
5
  - lib/sinclair/version.rb
data/config/yardstick.yml CHANGED
@@ -1,4 +1,4 @@
1
- threshold: 99.8
1
+ threshold: 100
2
2
  require_exact_threshold: false
3
3
  rules:
4
4
  ApiTag::Presence:
@@ -19,9 +19,14 @@ rules:
19
19
  - Sinclair::Configurable#config
20
20
  - Sinclair::Configurable#reset_config
21
21
  - Sinclair::Configurable#configure
22
+ - Sinclair::EqualsChecker#initialize
22
23
  - Sinclair::Options#==
23
24
  - Sinclair::OptionsParser#options
24
25
  - Sinclair::OptionsParser#options_object
26
+ - Sinclair::Matchers#add_method
27
+ - Sinclair::Matchers#add_class_method
28
+ - Sinclair::Matchers#change_method
29
+ - Sinclair::Matchers#change_class_method
25
30
  ReturnTag:
26
31
  enabled: true
27
32
  exclude:
@@ -37,6 +42,7 @@ rules:
37
42
  - Sinclair::ConfigFactory#initialize
38
43
  - Sinclair::EnvSettable::Builder#initialize
39
44
  - Sinclair::Exception::InvalidOptions#initialize
45
+ - Sinclair::EqualsChecker#initialize
40
46
  - Sinclair::InputHash#initialize
41
47
  - Sinclair::Matchers::AddInstanceMethodTo#initialize
42
48
  - Sinclair::Matchers::AddClassMethodTo#initialize
@@ -48,7 +54,9 @@ rules:
48
54
  - Sinclair::Matchers::ChangeInstanceMethodOn#initialize
49
55
  - Sinclair::MethodBuilder
50
56
  - Sinclair::MethodBuilder::Base#initialize
57
+ - Sinclair::MethodBuilder::Accessor#initialize
51
58
  - Sinclair::MethodDefinition#initialize
59
+ - Sinclair::MethodDefinition::CallDefinition#initialize
52
60
  - Sinclair::MethodDefinition::BlockDefinition#initialize
53
61
  - Sinclair::MethodDefinition::StringDefinition#initialize
54
62
  - Sinclair::Options#initialize
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Sinclair
4
+ module Comparable
5
+ # @api public
6
+ # @author darthjee
7
+ #
8
+ # Class methods of {Sinclair::Comparable}
9
+ #
10
+ # @example (see Sinclair::Comparable)
11
+ module ClassMethods
12
+ # Adds fields to the comparison algorythim
13
+ #
14
+ # @param attributes [Array<Symbol>] attributes to be added to comparison
15
+ #
16
+ # @see Sinclair::EqualsChecker
17
+ # @return (see Sinclair::EqualsChecker#add)
18
+ # @example (see Sinclair::Comparable)
19
+ def comparable_by(*attributes)
20
+ equals_checker.add(*attributes)
21
+ end
22
+
23
+ # @api private
24
+ #
25
+ # Returns a comparable configured for the class
26
+ #
27
+ # @return [Sinclair::EqualsChecker]
28
+ def equals_checker
29
+ @equals_checker ||= Sinclair::EqualsChecker.new
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'sinclair/comparable/class_methods'
4
+
5
+ class Sinclair
6
+ # @api public
7
+ # @author darthjee
8
+ #
9
+ # Concern to be added on classes for easy +==+ comparison
10
+ #
11
+ # @example
12
+ # class SampleModel
13
+ # include Sinclair::Comparable
14
+ #
15
+ # comparable_by :name
16
+ # attr_reader :name, :age
17
+ #
18
+ # def initialize(name: nil, age: nil)
19
+ # @name = name
20
+ # @age = age
21
+ # end
22
+ # end
23
+ #
24
+ # model1 = model_class.new(name: 'jack', age: 21)
25
+ # model2 = model_class.new(name: 'jack', age: 23)
26
+ #
27
+ # model1 == model2 # returns true
28
+ module Comparable
29
+ extend ActiveSupport::Concern
30
+
31
+ # Checks if an instance of a comparable is equals another
32
+ #
33
+ # @param other [Object] an object that should be equal to comparable
34
+ #
35
+ # @return [Boolean]
36
+ # @example (see Sinclair::Comparable)
37
+ def ==(other)
38
+ klass = self.class
39
+ superklass = klass.superclass
40
+
41
+ return false unless klass.equals_checker.match?(self, other)
42
+ return true unless superklass.include?(Sinclair::Comparable)
43
+
44
+ superklass.equals_checker.match?(self, other)
45
+ end
46
+ end
47
+ end
@@ -75,9 +75,11 @@ class Sinclair
75
75
  # @todo get rid of @config_attributes when only
76
76
  # Sinclair::ConfigClass are accepted
77
77
  def method_included?(method_name)
78
+ klass = @config.class
79
+
78
80
  @config_attributes.include?(method_name) ||
79
- @config.class.is_a?(Sinclair::ConfigClass) &&
80
- @config.class.config_attributes.include?(method_name)
81
+ klass.is_a?(Sinclair::ConfigClass) &&
82
+ klass.config_attributes.include?(method_name)
81
83
  end
82
84
  end
83
85
  end
@@ -81,6 +81,8 @@ class Sinclair
81
81
  # @method as_options(options_hash = {})
82
82
  # @api public
83
83
  #
84
+ # Returns options with configurated values
85
+ #
84
86
  # @param (see Sinclair::Config#as_options)
85
87
  # @return (see Sinclair::Config#as_options)
86
88
  # @example (see Sinclair::Config#as_options)
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'set'
4
+
5
+ class Sinclair
6
+ # @api public
7
+ # @author darthjee
8
+ #
9
+ # Class responsible for checking if two instances of a class are the equals
10
+ #
11
+ # @example regular usage
12
+ # class SampleModel
13
+ # def initialize(name: nil, age: nil)
14
+ # @name = name
15
+ # @age = age
16
+ # end
17
+ #
18
+ # protected
19
+ #
20
+ # attr_reader :name
21
+ #
22
+ # private
23
+ #
24
+ # attr_reader :age
25
+ # end
26
+ #
27
+ # class OtherModel < SampleModel
28
+ # end
29
+ #
30
+ # checker = Sinclair::EqualsChecker.new(:name, :age)
31
+ #
32
+ # model1 = SampleModel.new(name: 'jack', age: 21)
33
+ # model2 = SampleModel.new(name: 'rose', age: 23)
34
+ #
35
+ # checker.match?(model1, model2) # returns false
36
+ #
37
+ # @example similar models
38
+ # checker = Sinclair::EqualsChecker.new(:name, :age)
39
+ #
40
+ # model1 = SampleModel.new(name: 'jack', age: 21)
41
+ # model2 = SampleModel.new(name: 'jack', age: 21)
42
+ #
43
+ # checker.match?(model1, model2) # returns true
44
+ #
45
+ # @example different classes
46
+ # checker = Sinclair::EqualsChecker.new(:name, :age)
47
+ #
48
+ # model1 = SampleModel.new(name: 'jack', age: 21)
49
+ # model2 = OtherModel.new(name: 'jack', age: 21)
50
+ #
51
+ # checker.match?(model1, model2) # returns false
52
+ class EqualsChecker
53
+ # @param attributes [Array<Symbol,String>] list of relevant attributes
54
+ def initialize(*attributes)
55
+ @attributes = Set.new(attributes.flatten)
56
+ end
57
+
58
+ # Adds new fields to equals checker
59
+ #
60
+ # @param attributes [Array<Symbol,String>] list of relevant attributes
61
+ #
62
+ # @return [Set<Symbol,String>]
63
+ #
64
+ # @example adding fields to equal checker
65
+ # checker = Sinclair::EqualsChecker.new(:name)
66
+ #
67
+ # model1 = SampleModel.new(name: 'jack', age: 21)
68
+ # model2 = SampleModel.new(name: 'jack', age: 22)
69
+ #
70
+ # checker.match?(model1, model2) # returns true
71
+ #
72
+ # checker.add(:age)
73
+ #
74
+ # checker.match?(model1, model2) # returns false
75
+ def add(*attributes)
76
+ @attributes += Set.new(attributes.flatten)
77
+ end
78
+
79
+ # Returns if 2 objects are equals
80
+ #
81
+ # The check takes into consideration:
82
+ # - They should be instances of the same class
83
+ # - Their attributes (method calls) should return the same value,
84
+ # for the configured attributes
85
+ # - Public and private attributes are checked
86
+ #
87
+ # @example (see Sinclair::EqualsChecker)
88
+ #
89
+ # @return [TrueClass,FalseClass]
90
+ def match?(model, other)
91
+ return false unless model.class == other.class
92
+
93
+ attributes.all? do |attr|
94
+ model.send(attr) == other.send(attr)
95
+ end
96
+ end
97
+
98
+ private
99
+
100
+ attr_reader :attributes
101
+
102
+ # @private
103
+ # @api private
104
+ # @method attributes
105
+ #
106
+ # attributes relevant for checking difference
107
+ #
108
+ # @return [Set<Symbol,String>]
109
+ end
110
+ end
@@ -6,33 +6,33 @@ class Sinclair
6
6
  # @author darthjee
7
7
  #
8
8
  # AddClassMethod is able to build an instance of {Sinclair::Matchers::AddClassMethodTo}
9
- #
10
- # @example
11
- # RSpec.configure do |config|
12
- # config.include Sinclair::Matchers
13
- # end
14
- #
15
- # class MyModel
16
- # end
17
- #
18
- # RSpec.describe 'MyBuilder' do
19
- # let(:clazz) { Class.new(MyModel) }
20
- #
21
- # let(:block) do
22
- # proc do
23
- # clazz.define_singleton_method(:new_method) { 2 }
24
- # end
25
- # end
26
- #
27
- # it do
28
- # expect(&block).to add_class_method(:new_method).to(clazz)
29
- # end
30
- # end
31
- #
32
- # # outputs
33
- # # should add method class_method 'new_method' to #<Class:0x000055b4d0a25c80>
34
- class AddClassMethod < Base
35
- include AddMethod
9
+ class AddClassMethod < AddMethod
10
+ # @method #to(target = nil)
11
+ # @example Checking if a class had a class method added
12
+ # RSpec.configure do |config|
13
+ # config.include Sinclair::Matchers
14
+ # end
15
+ #
16
+ # class MyModel
17
+ # end
18
+ #
19
+ # RSpec.describe 'MyBuilder' do
20
+ # let(:clazz) { Class.new(MyModel) }
21
+ #
22
+ # let(:block) do
23
+ # proc do
24
+ # clazz.define_singleton_method(:new_method) { 2 }
25
+ # end
26
+ # end
27
+ #
28
+ # it do
29
+ # expect(&block).to add_class_method(:new_method).to(clazz)
30
+ # end
31
+ # end
32
+ #
33
+ # # outputs
34
+ # # should add method class_method 'new_method' to #<Class:0x000055b4d0a25c80>
35
+ with_final_matcher :to, AddClassMethodTo
36
36
 
37
37
  private
38
38
 
@@ -45,15 +45,6 @@ class Sinclair
45
45
  'You should specify which class the method is being added to' \
46
46
  "add_class_method(:#{method_name}).to(klass)"
47
47
  end
48
-
49
- # @private
50
- #
51
- # Class of the real matcher
52
- #
53
- # @return [Class<Sinclair::Matchers::Base>]
54
- def add_method_to_class
55
- AddClassMethodTo
56
- end
57
48
  end
58
49
  end
59
50
  end
@@ -7,56 +7,65 @@ class Sinclair
7
7
  #
8
8
  # AddInstanceMethod is able to build an instance of {Sinclair::Matchers::AddInstanceMethodTo}
9
9
  #
10
- # @example Using inside RSpec and checking Class
11
- # RSpec.configure do |config|
12
- # config.include Sinclair::Matchers
13
- # end
14
- #
15
- # class MyModel
16
- # end
17
- #
18
- # RSpec.describe "MyBuilder" do
19
- # let(:clazz) { Class.new(MyModel) }
20
- # let(:builder) { Sinclair.new(clazz) }
21
- #
22
- # before do
23
- # builder.add_method(:new_method, "2")
24
- # end
25
- #
26
- # it do
27
- # expect { builder.build }.to add_method(:new_method).to(clazz)
28
- # end
29
- # end
30
- #
31
- # # Outputs
32
- # # 'should add method 'new_method' to #<Class:0x000056441bf46608> instances'
33
- #
34
- # @example Using inside RSpec and checking instance
35
- # RSpec.configure do |config|
36
- # config.include Sinclair::Matchers
37
- # end
38
- #
39
- # class MyModel
40
- # end
41
- #
42
- # RSpec.describe "MyBuilder" do
43
- # let(:clazz) { Class.new(MyModel) }
44
- # let(:builder) { Sinclair.new(clazz) }
45
- # let(:instance) { clazz.new }
46
- #
47
- # before do
48
- # builder.add_method(:the_method, "true")
49
- # end
50
- #
51
- # it do
52
- # expect { builder.build }.to add_method(:the_method).to(instance)
53
- # end
54
- # end
55
- #
56
- # # Outputs
57
- # # 'should add method 'the_method' to #<Class:0x000056441bf46608> instances'
58
- class AddInstanceMethod < Base
59
- include AddMethod
10
+ class AddInstanceMethod < AddMethod
11
+ # @example Using inside RSpec and checking an instance method being added
12
+ # RSpec.configure do |config|
13
+ # config.include Sinclair::Matchers
14
+ # end
15
+ #
16
+ # class MyModel
17
+ # end
18
+ #
19
+ # RSpec.describe "MyBuilder" do
20
+ # let(:clazz) { Class.new(MyModel) }
21
+ # let(:builder) { Sinclair.new(clazz) }
22
+ #
23
+ # before do
24
+ # builder.add_method(:new_method, "2")
25
+ # end
26
+ #
27
+ # it do
28
+ # expect { builder.build }.to add_method(:new_method).to(clazz)
29
+ # end
30
+ # end
31
+ #
32
+ # # Outputs
33
+ # # 'should add method 'new_method' to #<Class:0x000056441bf46608> instances'
34
+ #
35
+ # @example Using inside RSpec and checking instance
36
+ # RSpec.configure do |config|
37
+ # config.include Sinclair::Matchers
38
+ # end
39
+ #
40
+ # class MyModel
41
+ # end
42
+ #
43
+ # RSpec.describe "MyBuilder" do
44
+ # let(:clazz) { Class.new(MyModel) }
45
+ # let(:builder) { Sinclair.new(clazz) }
46
+ # let(:instance) { clazz.new }
47
+ #
48
+ # before do
49
+ # builder.add_method(:the_method, "true")
50
+ # end
51
+ #
52
+ # it do
53
+ # expect { builder.build }.to add_method(:the_method).to(instance)
54
+ # end
55
+ # end
56
+ #
57
+ # # Outputs
58
+ # # 'should add method 'the_method' to #<Class:0x000056441bf46608> instances'
59
+ with_final_matcher :to, AddInstanceMethodTo
60
+
61
+ # @method to(target = nil)
62
+ # @api public
63
+ #
64
+ # The matcher checks if an instance method was added to a class
65
+ #
66
+ # @param (see AddMethod#to)
67
+ #
68
+ # @return [AddClassMethodTo]
60
69
 
61
70
  private
62
71
 
@@ -69,15 +78,6 @@ class Sinclair
69
78
  'You should specify which instance the method is being added to' \
70
79
  "add_method(:#{method_name}).to(instance)"
71
80
  end
72
-
73
- # @private
74
- #
75
- # Class of the real matcher
76
- #
77
- # @return [Class<Sinclair::Matchers::Base>]
78
- def add_method_to_class
79
- AddInstanceMethodTo
80
- end
81
81
  end
82
82
  end
83
83
  end