Create a gist now

Instantly share code, notes, and snippets.

# it "has the following type signature" do
# TypeSignature.new(@widget, :foo).
# returns_nil.and.
# has_argument(String, "Hello").and.
# has_argument(Fixnum, 123).and
# accepts_block
# end
# I like the following better. Description can be modified,
# I just like the describe to explain the spec
it "receives a String or a Fixnum and an optional block. Returns nil" do
@widget.method(:foo).should take.
arg(String).
or(Fixnum).
optional.accepts_block.
returns(nil)
end
#or means that the first arg can take string or fixnum
#optional means that the following clause is optional
it "receives a String and a Fixnum and returns a Fixnum" do
@widget.method(:bar).should take.
.arg(String).
.arg(Fixnum)
.returns(Fixnum)
end
#arg should have a second optional
#arg that allows something that responds to to_a
#which lets you specify valid inputs (or invalid for should_not)
#probably need a .throws clause to specify that certain inputs
#will cause an exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment