Sha256: 33dc34b22e2dcdfaa5d5a7d0f48343dd4085dab18755dcbe7997a5c503c9034c

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../../../spec_helper")

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

        before do
          @times = 0
          @matcher = TimesCalledMatchers::IntegerMatcher.new(times)
          @expectation = TimesCalledExpectation.new(double, matcher)
        end

        describe "#attempt!" do
          it "raises error that includes the double" do
            lambda {expectation.attempt}.should raise_error(
              Errors::TimesCalledError,
              "#{double.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)
            lambda {expectation.verify!}.should raise_error(
              Errors::TimesCalledError,
              "#{double.formatted_name}\n#{matcher.error_message(1)}"
            )
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rr-0.6.0 spec/rr/expectations/times_called_expectation/times_called_expectation_spec.rb