Sha256: 1130da432fd5b3df1373db6c403c9d2602b0227c44ada9d6734fd0a30f36c53d

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require "spec/spec_helper"

module RR
  module Expectations
    describe TimesCalledExpectation, " with failure" do
      it_should_behave_like "RR::Expectations::TimesCalledExpectation"
      attr_reader :times, :matcher

      before do
        @times = 0
        @matcher = TimesCalledMatchers::IntegerMatcher.new(times)
        @expectation = TimesCalledExpectation.new(scenario, matcher)
      end
      
      describe "#attempt!" do
        it "raises error that includes the scenario" do
          proc do
            expectation.attempt!
          end.should raise_error(
          Errors::TimesCalledError,
          "#{scenario.formatted_name}\n#{matcher.error_message(1)}"
          )
        end
      end

      describe "#verify!" do
        it "raises error with passed in message prepended" do
          expectation.instance_variable_set(:@times_called, 1)
          proc do
            expectation.verify!
          end.should raise_error(
          Errors::TimesCalledError,
          "#{scenario.formatted_name}\n#{matcher.error_message(1)}"
          )
        end
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rr-0.4.0 spec/rr/expectations/times_called_expectation/times_called_expectation_spec.rb
rr-0.4.1 spec/rr/expectations/times_called_expectation/times_called_expectation_spec.rb
rr-0.4.2 spec/rr/expectations/times_called_expectation/times_called_expectation_spec.rb