module Contractinator::ContractHelpers
Public Instance Methods
agree(obj, method, *args)
click to toggle source
# File lib/contractinator/contract_helpers.rb, line 38 def agree(obj, method, *args) FulfillmentAdapter.new(self, obj, method, args) end
assign_contract(where, name, object)
click to toggle source
# File lib/contractinator/contract_helpers.rb, line 23 def assign_contract(where, name, object) Contractinator::Contract.require("#{where} assign @#{name}") assign(name, object) end
contract(string)
click to toggle source
# File lib/contractinator/contract_helpers.rb, line 11 def contract(string) Contractinator::Contract.require(string) end
flash_contract(where, key, value)
click to toggle source
# File lib/contractinator/contract_helpers.rb, line 28 def flash_contract(where, key, value) Contractinator::Contract.require("#{where} flash[#{key.inspect}]") flash[key] = value end
fmt_dbl(dbl)
click to toggle source
# File lib/contractinator/contract_helpers.rb, line 3 def fmt_dbl(dbl) dbl.contract_inspect end
fulfill(*args, &block)
click to toggle source
# File lib/contractinator/contract_helpers.rb, line 42 def fulfill(*args, &block) Contractinator::Contract.fulfill(*args, &block) RSpec::Matchers.define "fulfill_#{args.first}" do match { true } description do "fulfill #{args.first.inspect}" end end expect(true).to send("fulfill_#{args.first}") end
Also aliased as: fulfills
inject_contract(controller, name, dbl)
click to toggle source
# File lib/contractinator/contract_helpers.rb, line 15 def inject_contract(controller, name, dbl) dbl_name = fmt_dbl(dbl).to_s.classify Contractinator::Contract.require( "#{controller.controller_name}_controller.#{name} injected #{dbl_name}" ) controller.send("#{name}=", dbl) end
render_contract(who)
click to toggle source
# File lib/contractinator/contract_helpers.rb, line 33 def render_contract(who) Contractinator::Contract.require("#{who} render template") render end
stipulate(dbl)
click to toggle source
# File lib/contractinator/contract_helpers.rb, line 7 def stipulate(dbl) ContractAdapter.new(dbl, self) end
xfulfills(*args, &block)
click to toggle source
# File lib/contractinator/contract_helpers.rb, line 54 def xfulfills(*args, &block) # noop end