Sha256: 441437ece31597989375886749adf589fd016961faf5b8e1a75eb7572a68c0d3
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
require "spec_helper" scope Callable do spec "creates a callable object" do @obj = :not_callable @c = Callable(@obj) @c.call == @obj end spec "leaves a callable object intact" do @obj = -> { :callable } @c = Callable(@obj) @c == @obj end scope "#callable" do spec "creates a callable object" do @obj = :not_callable @c = @obj.callable @c.call == @obj end spec "leaves a callable object intact" do @obj = -> { :callable } @c = @obj.callable @c == @obj end end scope "#callable?" do spec "returns true if the object responds to #call" do @obj = -> { :callable } @obj.callable? end spec "returns false if the object doesn't respond to #call" do @obj = :not_callable ! @obj.callable? end end scope "arguments" do spec "accepts arguments arguments" do @obj = :not_callable @c = Callable(@obj) @c.call(1, 2, 3) == @obj end spec "passes the arguments on" do @obj = -> (a, b) { a + " " + b } @c = Callable(@obj) @c.call("Call", "me") == "Call me" end spec "can pass any number of arguments to a proc" do @obj = proc { |a, b| a + " " + b } @c = Callable(@obj) @c.call("Call", "me", "now") == "Call me" end spec "passes the arguments on" do @obj = -> (*args) { args.join(" ") } @c = Callable(@obj) @c.call("Call", "me", "now") == "Call me now" end end scope "default value" do spec "returns the default value when passing nil" do @c = Callable(nil, default: "DEFAULT VALUE") @c.call == "DEFAULT VALUE" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
callable-0.0.4 | spec/callable_spec.rb |