Sha256: 834fc44e89e88dea074907218e719ace82ddf6f243526bd532cb6e61aa65faa8
Contents?: true
Size: 827 Bytes
Versions: 2
Compression:
Stored size: 827 Bytes
Contents
require 'rext/module' describe Module do describe "helpers" do describe "#chain" do it "should allow chaining via super" do class Foo def method_missing meth if meth.to_s =~ /^say_(\w+)/ "said #{$1}" else super end end end class Foo chain { def method_missing meth if meth.to_s =~ /^ask_for_(\w+)/ "asked for #{$1}" else super end end } end Foo.new.ask_for_array.should == 'asked for array' Foo.new.say_hello.should == 'said hello' lambda { Foo.new.does_not_exist }.should raise_error(NoMethodError) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
visionmedia-rext-0.0.2 | spec/module_spec.rb |
visionmedia-rext-0.0.3 | spec/module_spec.rb |