Sha256: fc9d83d96bef2ff02e80d8b000966a5afc86510d2bea177074303146bf61555e

Contents?: true

Size: 1.49 KB

Versions: 16

Compression:

Stored size: 1.49 KB

Contents

module Fakes
  describe Matches do
    context "when creating matchers" do
      it "should be able to create a matcher that matches anything" do
        (1..10).each{|item| Matches.any.matches?(item).should be_true}
      end
      it "should be able to create a numeric greater than matcher" do
        match = Matches.greater_than(5)
        match.matches?(4).should be_false
        match.matches?(5).should be_false
        match.matches?(6).should be_true
        
      end
      it "should be able to create a range matcher" do
        match = Matches.in_range((1..10))
        match.matches?(4).should be_true
        match.matches?(10).should be_true
        match.matches?(11).should be_false
      end
      it "should be able to create a nil matcher" do
        match = Matches.nil
        match.matches?(nil).should be_true
        match.matches?(10).should be_false
      end
      it "should be able to create a not nil matcher" do
        match = Matches.not_nil
        match.matches?(10).should be_true
        match.matches?(nil).should be_false
      end
      it "should be able to create a regex string matcher" do
        match = Matches.regex(/a|e|i|o|u/)
        match.matches?("awwef").should be_true
        match.matches?("rwwgf").should be_false
      end

      it "should be able to create a lambda based matcher" do
        match = Matches.condition{|item| item > 3}
        match.matches?(2).should be_false
        match.matches?(7).should be_true
      end
    end
    
    
  end
  
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fakes-1.0.31 spec/specs/matches_spec.rb
fakes-1.0.30 spec/specs/matches_spec.rb
fakes-1.0.25 spec/specs/matches_spec.rb
fakes-1.1.1 spec/specs/matches_spec.rb
fakes-1.0.24 spec/specs/matches_spec.rb
fakes-1.0.22 spec/specs/matches_spec.rb
fakes-1.1.0 spec/specs/matches_spec.rb
fakes-1.0.9 spec/specs/matches_spec.rb
fakes-1.0.8 spec/specs/matches_spec.rb
fakes-1.0.7 spec/specs/matches_spec.rb
fakes-1.0.6 spec/specs/matches_spec.rb
fakes-1.0.5 spec/specs/matches_spec.rb
fakes-1.0.2 spec/specs/matches_spec.rb
fakes-1.0.1 spec/specs/matches_spec.rb
fakes-1.0.0 spec/specs/matches_spec.rb
fakes-0.4.1 spec/specs/matches_spec.rb