Remove warnings that fail the build
This commit is contained in:
parent
412ea1f936
commit
6a0e436290
|
@ -1,5 +1,4 @@
|
|||
require 'shoulda/matchers/independent/delegate_method_matcher'
|
||||
require 'shoulda/matchers/independent/delegate_method_matcher/stubbed_target'
|
||||
require 'shoulda/matchers/independent/delegate_method_matcher/target_not_defined_error'
|
||||
|
||||
module Shoulda
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
module Shoulda
|
||||
module Matchers
|
||||
module Independent
|
||||
class DelegateMethodMatcher
|
||||
# @private
|
||||
class StubbedTarget
|
||||
def initialize(method)
|
||||
@received_method = false
|
||||
@received_arguments = []
|
||||
stub_method(method)
|
||||
end
|
||||
|
||||
def has_received_method?
|
||||
received_method
|
||||
end
|
||||
|
||||
def has_received_arguments?(*args)
|
||||
args == received_arguments
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def stub_method(method)
|
||||
class_eval do
|
||||
define_method method do |*args|
|
||||
@received_method = true
|
||||
@received_arguments = args
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
attr_reader :received_method, :received_arguments
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -233,6 +233,7 @@ module Shoulda::Matchers::Doublespeak
|
|||
doubles[0].activate
|
||||
|
||||
was_called = false
|
||||
klass.__send__(:remove_method, method_name)
|
||||
klass.__send__(:define_method, method_name) do
|
||||
was_called = true
|
||||
end
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
require 'unit_spec_helper'
|
||||
|
||||
describe Shoulda::Matchers::Independent::DelegateMethodMatcher::StubbedTarget do
|
||||
subject(:target) { described_class.new(:stubbed_method) }
|
||||
|
||||
describe '#has_received_method?' do
|
||||
it 'returns true when the method has been called on the target' do
|
||||
target.stubbed_method
|
||||
|
||||
expect(target).to have_received_method
|
||||
end
|
||||
|
||||
it 'returns false when the method has not been called on the target' do
|
||||
expect(target).not_to have_received_method
|
||||
end
|
||||
end
|
||||
|
||||
describe '#has_received_arguments?' do
|
||||
context 'method is called with specified arguments' do
|
||||
it 'returns true' do
|
||||
target.stubbed_method(:arg1, :arg2)
|
||||
|
||||
expect(target).to have_received_arguments(:arg1, :arg2)
|
||||
end
|
||||
end
|
||||
|
||||
context 'method is not called with specified arguments' do
|
||||
it 'returns false' do
|
||||
target.stubbed_method
|
||||
|
||||
expect(target).not_to have_received_arguments(:arg1)
|
||||
end
|
||||
end
|
||||
|
||||
context 'method is called with arguments in incorrect order' do
|
||||
it 'returns false' do
|
||||
target.stubbed_method(:arg2, :arg1)
|
||||
|
||||
expect(target).not_to have_received_arguments(:arg1, :arg2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -418,7 +418,7 @@ describe Shoulda::Matchers::Independent::DelegateMethodMatcher do
|
|||
person = Person.new
|
||||
|
||||
expect {
|
||||
expect(person).to delegate_method(:hello). to(:country).with_prefix
|
||||
expect(person).to delegate_method(:hello).to(:country).with_prefix
|
||||
}.to fail_with_message(message)
|
||||
end
|
||||
end
|
||||
|
@ -592,7 +592,9 @@ to account for when #country *was* nil.
|
|||
MESSAGE
|
||||
|
||||
expectation = lambda do
|
||||
expect(person).to delegate_method(:hello).to(:country).allow_nil
|
||||
silence_warnings do
|
||||
expect(person).to delegate_method(:hello).to(:country).allow_nil
|
||||
end
|
||||
end
|
||||
|
||||
expect(&expectation).to fail_with_message(message)
|
||||
|
|
Loading…
Reference in New Issue