Sha256: d6d6c0e452aa4c1a4d6c4e6a2d45204b7adac552dfa7c69c4d39521efe404e06

Contents?: true

Size: 731 Bytes

Versions: 1

Compression:

Stored size: 731 Bytes

Contents

module BaconExpect
  class Expectation
    module BaconContext
      def expect(subject = nil, &block)
        Expectation.new(subject, &block)
      end
    end

    def initialize(subject, &subject_block)
      @subject = subject
      @subject_block = subject_block
    end

    def to(matcher)
      fail(matcher) unless matcher_passes(matcher)
      assert
    end

    def not_to(matcher)
      fail(matcher) if matcher_passes(matcher)
      assert
    end
    alias_method :to_not, :not_to

    def matcher_passes(matcher)
      matcher.matches?(@subject, &@subject_block)
    end

    def fail(matcher)
      raise matcher.fail!(@subject, &@subject_block)
    end

    def assert
      true.should == true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bacon-expect-1.0.2 lib/bacon-expect/expectation.rb