class DuckPond::MethodClause
Public Instance Methods
legal_assesment(subject)
click to toggle source
# File lib/duckpond/clause/method_clause.rb, line 20 def legal_assesment(subject) Lawyer.new do |lawyer| unless subject.respond_to? method lawyer.unsatisfied! "Expected subject to respond to method '#{method}'" end if @block || expected_response response_when_called(subject, method, args).tap do |response_when_called| if @block unless @block.call(response_when_called) lawyer.unsatisfied! "Block did not respond with 'true' for method #{method}" end end if expected_response unless response_when_called == expected_response lawyer.unsatisfied! "Expected method #{method} to return #{expected_response} but got #{response_when_called}" end end end end end end
Private Instance Methods
args()
click to toggle source
# File lib/duckpond/clause/method_clause.rb, line 57 def args @options[:given_args] end
expected_response()
click to toggle source
# File lib/duckpond/clause/method_clause.rb, line 53 def expected_response @options[:responds_with] end
method()
click to toggle source
# File lib/duckpond/clause/method_clause.rb, line 49 def method @options[:method_name] end
response_when_called(subject, method, args = [])
click to toggle source
# File lib/duckpond/clause/method_clause.rb, line 45 def response_when_called(subject, method, args = []) subject.send(method, *args) end