Skip to content

Instantly share code, notes, and snippets.

@reactormonk
Created January 9, 2010 10:50
Show Gist options
  • Save reactormonk/272847 to your computer and use it in GitHub Desktop.
Save reactormonk/272847 to your computer and use it in GitHub Desktop.
setup :method, "#member" do
@method = :member
end
setup :method, "#collection" do
@method = :collection
end
setup :stem, "stem" do
@stem = Stem.allocate
@params = {foo: :bar, type: @method}
mock(@stem).leaf(@params)
end
assert ":method" do
@stem.send(@method, @params)
end
# Methods to test:
# Creates a new leaf with type member. See Leaf.
def member(params)
leaf(params.merge({type: :member}))
end
# Creates a new leaf with type collection. See Leaf.
def collection(params)
leaf(params.merge({type: :collection}))
end
# Outcome:
extended leafs (1 test)
Error #member
member({:foo=>:bar, :type=>:member})
Called 0 times.
Expected 1 times.
Error #collection
member({:foo=>:bar, :type=>:collection})
Called 0 times.
Expected 1 times.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment