lib/sinclair/matchers/change_class_method.rb in sinclair-1.9.0 vs lib/sinclair/matchers/change_class_method.rb in sinclair-1.10.0
- old
+ new
@@ -5,19 +5,34 @@
# @api private
# @author darthjee
#
# AddInstanceMethod is able to build an instance of
# {Sinclair::Matchers::ChangeClassMethodOn}
- class ChangeClassMethod < Base
- include AddMethod
-
- # @api public
+ class ChangeClassMethod < AddMethod
+ # @example Checking if a class method has changed
+ # RSpec.configure do |config|
+ # config.include Sinclair::Matchers
+ # end
#
- # Builds final matcher
+ # class MyModel
+ # end
#
- # @return [Sinclair::Matchers::ChangeClassMethodOn]
- alias on to
+ # RSpec.describe 'my test' do
+ # let(:builder) { Sinclair.new(klass) }
+ # let(:klass) { Class.new(MyModel) }
+ #
+ # before do
+ # builder.add_class_method(:the_method) { 10 }
+ # builder.build
+ # builder.add_class_method(:the_method) { 20 }
+ # end
+ #
+ # it do
+ # expect{ builder.build }.to change_class_method(:the_method).on(klass)
+ # end
+ # end
+ with_final_matcher :on, ChangeClassMethodOn
private
# @private
#
@@ -25,18 +40,9 @@
#
# @return String
def matcher_error
'You should specify which class the method is being changed on' \
"change_class_method(:#{method_name}).on(klass)"
- end
-
- # @private
- #
- # Class of the real matcher
- #
- # @return [Class<ChangeClassMethodOn>]
- def add_method_to_class
- ChangeClassMethodOn
end
end
end
end