Sha256: d7561fc5755cb3887d8ff6297665e8b5517ff1a614e632ff85a0e15fb0cb3c31

Contents?: true

Size: 1.42 KB

Versions: 6

Compression:

Stored size: 1.42 KB

Contents

module RSpec::Matchers

  describe BaseMatcher do
    describe "#match_unless_raises" do
      let(:matcher) do
        Class.new do
          include BaseMatcher
        end.new
      end

      it "returns true if there are no errors" do
        matcher.match_unless_raises {}.should be_true
      end

      it "returns false if there is an error" do
        matcher.match_unless_raises { raise }.should be_false
      end

      it "returns false if the submitted error is raised" do
        matcher.match_unless_raises(RuntimeError){ raise "foo" }.should be_false
      end

      it "re-raises any error other than the one specified" do
        expect do
          matcher.match_unless_raises(ArgumentError){ raise "foo" }
        end.to raise_error
      end

      it "stores the rescued exception for use in messages" do
        matcher.match_unless_raises(RuntimeError){ raise "foo" }
        matcher.rescued_exception.should be_a(RuntimeError)
        matcher.rescued_exception.message.should eq("foo")
      end

    end

    describe "#==" do
      it "responds the same way as matches?" do
        matcher = Class.new do
          include BaseMatcher
          def matches?(actual)
            actual == expected
          end
        end
        matcher.new(3).matches?(3).should be_true
        matcher.new(3).should eq(3)

        matcher.new(3).matches?(4).should be_false
        matcher.new(3).should_not eq(4)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/rspec-expectations-2.8.0/spec/rspec/matchers/base_matcher_spec.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/rspec-expectations-2.8.0/spec/rspec/matchers/base_matcher_spec.rb
horseman-0.0.4 vendor/ruby/1.9.1/gems/rspec-expectations-2.8.0/spec/rspec/matchers/base_matcher_spec.rb
horseman-0.0.3 vendor/ruby/1.9.1/gems/rspec-expectations-2.8.0/spec/rspec/matchers/base_matcher_spec.rb
rspec-expectations-2.8.0 spec/rspec/matchers/base_matcher_spec.rb
rspec-expectations-2.8.0.rc2 spec/rspec/matchers/base_matcher_spec.rb