Sha256: 6985b09351f92f171b6fdf3a11ecace8d3a2d5a84a617461dbf60396164e870d
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
require 'spec_helper' describe DiviningRod::Definition do it "should work with no children not match" do definition = DiviningRod::Definition.new(:format => :iphone, :tags => [:overpriced, :easy_to_break]) { |request| request == 'iphone' } definition.evaluate('foo').should be_nil end it "should work with no children and match" do definition = DiviningRod::Definition.new(:format => :iphone, :tags => [:overpriced, :easy_to_break]) { |request| request == 'iphone' } definition.evaluate('iphone').should eql(definition) end describe "with children" do it "should work with children that match" do definition = DiviningRod::Definition.new(:format => :iphone, :tags => [:overpriced, :easy_to_break]) { |request| request.match(/iphone/) } definition.children << DiviningRod::Definition.new(:format => :ipod, :tags => [:big, :lacks_a_camera]) { |request| request.match(/ipod/) } definition.children << DiviningRod::Definition.new(:format => :ipad, :tags => [:big, :lacks_a_camera]) { |request| request.match(/ipad/) } result = definition.evaluate('iphone ipad') result.should_not eql(definition) result.format.should eql(:ipad) result.tags.should include(:overpriced) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
divining_rod-0.5.0 | spec/definition_spec.rb |
divining_rod-0.4.0 | spec/definition_spec.rb |