Sha256: bef2c286ece4fbf89e35490f26352fb4dc153ed22f33f5520b52558b3510cd94

Contents?: true

Size: 1.99 KB

Versions: 17

Compression:

Stored size: 1.99 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper.rb'

module Spec
  module Matchers
    describe ThrowSymbol, "(constructed with no Symbol)" do
      before(:each) { @matcher = ThrowSymbol.new }

      it "should match if any Symbol is thrown" do
        @matcher.matches?(lambda{ throw :sym }).should be_true
      end
      it "should not match if no Symbol is thrown" do
        @matcher.matches?(lambda{ }).should be_false
      end
      it "should provide a failure message" do
        @matcher.matches?(lambda{})
        @matcher.failure_message.should == "expected a Symbol but nothing was thrown"
      end
      it "should provide a negative failure message" do
        @matcher.matches?(lambda{ throw :sym})
        @matcher.negative_failure_message.should == "expected no Symbol, got :sym"
      end
    end
    
    describe ThrowSymbol, "(constructed with a Symbol)" do
      before(:each) { @matcher = ThrowSymbol.new(:sym) }
      
      it "should match if correct Symbol is thrown" do
        @matcher.matches?(lambda{ throw :sym }).should be_true
      end
      it "should not match no Symbol is thrown" do
        @matcher.matches?(lambda{ }).should be_false
      end
      it "should not match if correct Symbol is thrown" do
        @matcher.matches?(lambda{ throw :other_sym }).should be_false
        @matcher.failure_message.should == "expected :sym, got :other_sym"
      end
      it "should provide a failure message when no Symbol is thrown" do
        @matcher.matches?(lambda{})
        @matcher.failure_message.should == "expected :sym but nothing was thrown"
      end
      it "should provide a failure message when wrong Symbol is thrown" do
        @matcher.matches?(lambda{ throw :other_sym })
        @matcher.failure_message.should == "expected :sym, got :other_sym"
      end
      it "should provide a negative failure message" do
        @matcher.matches?(lambda{ throw :sym })
        @matcher.negative_failure_message.should == "expected :sym not to be thrown"
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
has_finder-0.1.1 spec/rails/vendor/plugins/rspec/spec/spec/matchers/throw_symbol_spec.rb
has_finder-0.1.2 spec/rails/vendor/plugins/rspec/spec/spec/matchers/throw_symbol_spec.rb
has_finder-0.1.3 spec/rails/vendor/plugins/rspec/spec/spec/matchers/throw_symbol_spec.rb
rspec-1.0.3 spec/spec/matchers/throw_symbol_spec.rb
rspec-0.9.0 spec/spec/matchers/throw_symbol_spec.rb
rspec-0.9.1 spec/spec/matchers/throw_symbol_spec.rb
rspec-0.9.2 spec/spec/matchers/throw_symbol_spec.rb
rspec-0.9.3 spec/spec/matchers/throw_symbol_spec.rb
rspec-0.9.4 spec/spec/matchers/throw_symbol_spec.rb
rspec-1.0.0 spec/spec/matchers/throw_symbol_spec.rb
rspec-1.0.1 spec/spec/matchers/throw_symbol_spec.rb
rspec-1.0.2 spec/spec/matchers/throw_symbol_spec.rb
rspec-1.0.4 spec/spec/matchers/throw_symbol_spec.rb
rspec-1.0.5 spec/spec/matchers/throw_symbol_spec.rb
rspec-1.0.6 spec/spec/matchers/throw_symbol_spec.rb
rspec-1.0.7 spec/spec/matchers/throw_symbol_spec.rb
rspec-1.0.8 spec/spec/matchers/throw_symbol_spec.rb