Sha256: eff83d499df9a274c56fc1499f2363ca345975be93abdc276f69a609d5fe84b2

Contents?: true

Size: 1.27 KB

Versions: 9

Compression:

Stored size: 1.27 KB

Contents

require "helper"

class ShouldaExpectsTest < Test::Unit::TestCase
  context ".expects" do
    setup do
      @object = mock
    end
    
    context "with met expectation" do
      execute do
        @object.call_me
      end
      
      expects "call_me to be called" do
        @object.expects(:call_me)
      end
      
      expects "call_me to be called second time" do
        @object.expects(:call_me)
      end
    end
    
    context "execution order" do
      setup do
        @last_step = :setup
      end
      
      context "with 'expects'" do
        execute do
          assert_equal :expects, @last_step
          @last_step = :execute
        end

        expects "to be called before execute" do
          assert_equal :setup, @last_step
          @last_step = :expects
        end
      end
      
      context "with 'expects' and 'should'" do
        setup do
          @expects_called = false
        end
        
        execute do
          assert_equal :setup, @last_step
          @last_step = :execute
        end
        
        expects do
          @expects_called = true
        end
        
        should "not call 'expects' for 'should'" do
          assert_equal :execute, @last_step
          assert !@expects_called
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
always_execute-0.2.3 test/shoulda_expects_test.rb
always_execute-0.2.2 test/shoulda_expects_test.rb
always_execute-0.2.1 test/shoulda_expects_test.rb
always_execute-0.2.0 test/shoulda_expects_test.rb
always_execute-0.1.3 test/shoulda_expects_test.rb
always_execute-0.1.2 test/shoulda_expects_test.rb
always_execute-0.1.1 test/shoulda_expects_test.rb
always_execute-0.1.0 test/shoulda_expects_test.rb
always_execute-0.0.2 test/shoulda_expects_test.rb