Sha256: 8f44bc7a6fc48e21874a050b6a7b8d802c9303a6d7bcea5b6d9de0e9ffa0fce8

Contents?: true

Size: 1.62 KB

Versions: 15

Compression:

Stored size: 1.62 KB

Contents

require File.join(File.dirname(__FILE__), "acceptance_test_helper")
require 'mocha'

class StatesTest < Test::Unit::TestCase
  
  include AcceptanceTest
  
  def setup
    setup_acceptance_test
  end
  
  def teardown
    teardown_acceptance_test
  end
  
  def test_should_constrain_expectations_to_occur_within_a_given_state
    test_result = run_as_test do
      mock = mock()
      readiness = states('readiness')
      
      mock.stubs(:first).when(readiness.is('ready'))
      mock.stubs(:second).then(readiness.is('ready'))
      
      mock.first
    end
    assert_failed(test_result)
  end
  
  def test_should_allow_expectations_to_occur_in_correct_state
    test_result = run_as_test do
      mock = mock()
      readiness = states('readiness')
      
      mock.stubs(:first).when(readiness.is('ready'))
      mock.stubs(:second).then(readiness.is('ready'))
      
      mock.second
      mock.first
    end
    assert_passed(test_result)
  end
  
  def test_should_be_able_to_start_in_a_specific_state
    test_result = run_as_test do
      mock = mock()
      readiness = states('readiness')
      
      mock.stubs(:first).when(readiness.is('ready'))
      
      readiness.starts_as('ready')
      mock.first
    end
    assert_passed(test_result)
  end
  
  def test_should_switch_state_when_method_raises_an_exception
    test_result = run_as_test do
      mock = mock()
      readiness = states('readiness')
      
      mock.expects(:first).raises().then(readiness.is('ready'))
      mock.expects(:second).when(readiness.is('ready'))
      
      mock.first rescue nil
      mock.second
    end
    assert_passed(test_result)
  end
    
end

Version data entries

15 entries across 15 versions & 5 rubygems

Version Path
floehopper-mocha-0.9.6.20090629164857 test/acceptance/states_test.rb
floehopper-mocha-0.9.6.20090629165308 test/acceptance/states_test.rb
floehopper-mocha-0.9.6.20090701111305 test/acceptance/states_test.rb
floehopper-mocha-0.9.7.20090701124354 test/acceptance/states_test.rb
jferris-mocha-0.9.5.0.1240002286 test/acceptance/states_test.rb
jferris-mocha-0.9.5.0.1240351621 test/acceptance/states_test.rb
jferris-mocha-0.9.5.0.1241126838 test/acceptance/states_test.rb
jferris-mocha-0.9.7.0.1247796736 test/acceptance/states_test.rb
jferris-mocha-0.9.7.20090701124354 test/acceptance/states_test.rb
jferris-mocha-0.9.7.20090911190113 test/acceptance/states_test.rb
mocha-macruby-0.9.8.20100129120100 test/acceptance/states_test.rb
mcmire-mocha-0.9.8 test/acceptance/states_test.rb
mocha-0.9.8 test/acceptance/states_test.rb
mocha-0.9.6 test/acceptance/states_test.rb
mocha-0.9.7 test/acceptance/states_test.rb