Sha256: 73c521328a93fe3ca0d1f4442ead00c6114a4fcf7dd38b9ced56278e1e9d9e9e
Contents?: true
Size: 1.03 KB
Versions: 39
Compression:
Stored size: 1.03 KB
Contents
require 'awestruct/handler_chain' require 'hashery' describe Awestruct::HandlerChain do class BaseMockHandler attr_reader :site, :arg def initialize(site, arg) @site, @arg = site, arg end end class HandlerOne < BaseMockHandler; end class HandlerTwo < BaseMockHandler; end class HandlerThree < BaseMockHandler; end before :all do @site = Hashery::OpenCascade[ { :encoding => false } ] end it "should use a regexp to match" do chain = Awestruct::HandlerChain.new( /foo/ ) chain.should be_matches( "foot" ) chain.should_not be_matches( "hand" ) end it "should nest handlers in order, first being deepest" do chain = Awestruct::HandlerChain.new( /foo/ ) chain.handler_classes << HandlerOne chain.handler_classes << HandlerTwo chain.handler_classes << HandlerThree result = chain.create( @site, "foot" ) result.should be_a HandlerThree result.arg.should be_a HandlerTwo result.arg.arg.should be_a HandlerOne result.arg.arg.arg.should == "foot" end end
Version data entries
39 entries across 39 versions & 1 rubygems