public
Last active

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
# 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.