Sha256: d5529caec565c5e4a6699e5758bcbc152f8c7f9335345fa8195f05d15b512691
Contents?: true
Size: 1.6 KB
Versions: 5
Compression:
Stored size: 1.6 KB
Contents
require File.expand_path('../acceptance_test_helper', __FILE__) require 'mocha/setup' class StatesTest < Mocha::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')) begin mock.first rescue StandardError nil end mock.second end assert_passed(test_result) end end
Version data entries
5 entries across 5 versions & 2 rubygems