ceedling 0.13.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +18 -14
- data/README.md +6 -4
- data/assets/project_as_gem.yml +1 -1
- data/assets/rakefile_as_gem.rb +2 -0
- data/assets/rakefile_with_guts.rb +3 -1
- data/ceedling.gemspec +1 -0
- data/examples/blinky/rakefile.rb +2 -2
- data/examples/temp_sensor/rakefile.rb +1 -1
- data/examples/temp_sensor/src/TemperatureFilter.c +1 -2
- data/examples/temp_sensor/test/TestTemperatureCalculator.c +1 -1
- data/examples/temp_sensor/test/TestTemperatureFilter.c +12 -2
- data/lib/ceedling.rb +94 -22
- data/lib/{build_invoker_utils.rb → ceedling/build_invoker_utils.rb} +27 -27
- data/lib/{cacheinator.rb → ceedling/cacheinator.rb} +42 -42
- data/lib/{cacheinator_helper.rb → ceedling/cacheinator_helper.rb} +12 -12
- data/lib/{cmock_builder.rb → ceedling/cmock_builder.rb} +15 -15
- data/lib/{configurator.rb → ceedling/configurator.rb} +333 -329
- data/lib/{configurator_builder.rb → ceedling/configurator_builder.rb} +437 -437
- data/lib/{configurator_plugins.rb → ceedling/configurator_plugins.rb} +124 -124
- data/lib/{configurator_setup.rb → ceedling/configurator_setup.rb} +124 -124
- data/lib/{configurator_validator.rb → ceedling/configurator_validator.rb} +184 -184
- data/lib/{constants.rb → ceedling/constants.rb} +20 -17
- data/lib/{defaults.rb → ceedling/defaults.rb} +19 -18
- data/lib/{dependinator.rb → ceedling/dependinator.rb} +92 -92
- data/lib/{erb_wrapper.rb → ceedling/erb_wrapper.rb} +8 -8
- data/lib/{file_finder.rb → ceedling/file_finder.rb} +132 -132
- data/lib/{file_finder_helper.rb → ceedling/file_finder_helper.rb} +54 -54
- data/lib/{file_path_utils.rb → ceedling/file_path_utils.rb} +189 -189
- data/lib/{file_system_utils.rb → ceedling/file_system_utils.rb} +69 -69
- data/lib/{file_system_wrapper.rb → ceedling/file_system_wrapper.rb} +9 -9
- data/lib/{file_wrapper.rb → ceedling/file_wrapper.rb} +79 -79
- data/lib/{flaginator.rb → ceedling/flaginator.rb} +54 -54
- data/lib/{generator.rb → ceedling/generator.rb} +164 -164
- data/lib/{generator_helper.rb → ceedling/generator_helper.rb} +40 -40
- data/lib/{generator_test_results.rb → ceedling/generator_test_results.rb} +86 -89
- data/lib/{generator_test_results_sanity_checker.rb → ceedling/generator_test_results_sanity_checker.rb} +64 -62
- data/lib/{generator_test_runner.rb → ceedling/generator_test_runner.rb} +63 -63
- data/lib/{loginator.rb → ceedling/loginator.rb} +31 -31
- data/lib/{makefile.rb → ceedling/makefile.rb} +0 -0
- data/lib/{objects.yml → ceedling/objects.yml} +0 -0
- data/lib/{par_map.rb → ceedling/par_map.rb} +0 -0
- data/lib/{plugin.rb → ceedling/plugin.rb} +80 -80
- data/lib/{plugin_builder.rb → ceedling/plugin_builder.rb} +52 -52
- data/lib/{plugin_manager.rb → ceedling/plugin_manager.rb} +107 -107
- data/lib/{plugin_manager_helper.rb → ceedling/plugin_manager_helper.rb} +19 -19
- data/lib/{plugin_reportinator.rb → ceedling/plugin_reportinator.rb} +2 -2
- data/lib/{plugin_reportinator_helper.rb → ceedling/plugin_reportinator_helper.rb} +1 -1
- data/lib/{preprocessinator.rb → ceedling/preprocessinator.rb} +43 -43
- data/lib/{preprocessinator_extractor.rb → ceedling/preprocessinator_extractor.rb} +30 -30
- data/lib/{preprocessinator_file_handler.rb → ceedling/preprocessinator_file_handler.rb} +21 -21
- data/lib/{preprocessinator_helper.rb → ceedling/preprocessinator_helper.rb} +46 -46
- data/lib/ceedling/preprocessinator_includes_handler.rb +82 -0
- data/lib/{project_config_manager.rb → ceedling/project_config_manager.rb} +38 -38
- data/lib/{project_file_loader.rb → ceedling/project_file_loader.rb} +64 -64
- data/lib/{rake_utils.rb → ceedling/rake_utils.rb} +17 -17
- data/lib/{rake_wrapper.rb → ceedling/rake_wrapper.rb} +33 -33
- data/lib/{rakefile.rb → ceedling/rakefile.rb} +78 -74
- data/lib/{release_invoker.rb → ceedling/release_invoker.rb} +58 -58
- data/lib/{release_invoker_helper.rb → ceedling/release_invoker_helper.rb} +16 -16
- data/lib/{reportinator.rb → ceedling/reportinator.rb} +9 -9
- data/lib/{rules_cmock.rake → ceedling/rules_cmock.rake} +9 -9
- data/lib/{rules_preprocess.rake → ceedling/rules_preprocess.rake} +26 -26
- data/lib/{rules_release.rake → ceedling/rules_release.rake} +79 -79
- data/lib/{rules_release_deep_dependencies.rake → ceedling/rules_release_deep_dependencies.rake} +15 -15
- data/lib/{rules_tests.rake → ceedling/rules_tests.rake} +59 -59
- data/lib/{rules_tests_deep_dependencies.rake → ceedling/rules_tests_deep_dependencies.rake} +15 -15
- data/lib/{setupinator.rb → ceedling/setupinator.rb} +51 -51
- data/lib/{stream_wrapper.rb → ceedling/stream_wrapper.rb} +20 -20
- data/lib/{streaminator.rb → ceedling/streaminator.rb} +40 -41
- data/lib/{streaminator_helper.rb → ceedling/streaminator_helper.rb} +15 -15
- data/lib/{system_utils.rb → ceedling/system_utils.rb} +0 -0
- data/lib/{system_wrapper.rb → ceedling/system_wrapper.rb} +76 -76
- data/lib/{target_loader.rb → ceedling/target_loader.rb} +0 -0
- data/lib/{task_invoker.rb → ceedling/task_invoker.rb} +89 -89
- data/lib/{tasks_base.rake → ceedling/tasks_base.rake} +104 -104
- data/lib/{tasks_filesystem.rake → ceedling/tasks_filesystem.rake} +91 -91
- data/lib/{tasks_release.rake → ceedling/tasks_release.rake} +28 -28
- data/lib/{tasks_release_deep_dependencies.rake → ceedling/tasks_release_deep_dependencies.rake} +9 -9
- data/lib/{tasks_tests.rake → ceedling/tasks_tests.rake} +52 -52
- data/lib/{tasks_tests_deep_dependencies.rake → ceedling/tasks_tests_deep_dependencies.rake} +9 -9
- data/lib/{tasks_vendor.rake → ceedling/tasks_vendor.rake} +36 -36
- data/lib/{test_includes_extractor.rb → ceedling/test_includes_extractor.rb} +81 -81
- data/lib/{test_invoker.rb → ceedling/test_invoker.rb} +97 -97
- data/lib/{test_invoker_helper.rb → ceedling/test_invoker_helper.rb} +28 -28
- data/lib/{tool_executor.rb → ceedling/tool_executor.rb} +215 -212
- data/lib/{tool_executor_helper.rb → ceedling/tool_executor_helper.rb} +115 -115
- data/lib/{verbosinator.rb → ceedling/verbosinator.rb} +10 -10
- data/lib/ceedling/version.rb +1 -1
- data/lib/{yaml_wrapper.rb → ceedling/yaml_wrapper.rb} +17 -16
- data/license.txt +31 -0
- data/plugins/bullseye/lib/bullseye.rb +2 -2
- data/plugins/gcov/gcov.rb +2 -2
- data/plugins/module_generator/lib/module_generator.rb +4 -3
- data/plugins/stdout_ide_tests_report/lib/stdout_ide_tests_report.rb +8 -8
- data/plugins/stdout_pretty_tests_report/lib/stdout_pretty_tests_report.rb +3 -3
- data/plugins/teamcity_tests_report/config/teamcity_tests_report.yml +4 -0
- data/plugins/teamcity_tests_report/lib/teamcity_tests_report.rb +57 -0
- data/plugins/xml_tests_report/xml_tests_report.rb +4 -4
- data/release/version.info +1 -1
- data/spec/ceedling_spec.rb +154 -0
- data/spec/par_map_spec.rb +1 -1
- data/spec/preprocessinator_extractor_spec.rb +26 -27
- data/spec/preprocessinator_includes_handler_spec.rb +175 -0
- data/spec/spec_helper.rb +8 -27
- data/test_graveyard/integration/paths_test.rb +2 -2
- data/test_graveyard/unit/busted/configurator_builder_test.rb +2 -2
- data/test_graveyard/unit/busted/configurator_test.rb +1 -1
- data/test_graveyard/unit/busted/configurator_validator_test.rb +1 -1
- data/test_graveyard/unit/busted/dependinator_test.rb +1 -1
- data/test_graveyard/unit/busted/file_finder_helper_test.rb +1 -1
- data/test_graveyard/unit/busted/file_finder_test.rb +1 -1
- data/test_graveyard/unit/busted/file_path_utils_test.rb +1 -1
- data/test_graveyard/unit/busted/file_system_utils_test.rb +1 -1
- data/test_graveyard/unit/busted/generator_test.rb +1 -1
- data/test_graveyard/unit/busted/generator_test_results_test.rb +1 -1
- data/test_graveyard/unit/busted/generator_test_runner_test.rb +1 -1
- data/test_graveyard/unit/busted/preprocessinator_file_handler_test.rb +1 -1
- data/test_graveyard/unit/busted/preprocessinator_helper_test.rb +1 -1
- data/test_graveyard/unit/busted/preprocessinator_includes_handler_test.rb +1 -1
- data/test_graveyard/unit/busted/preprocessinator_test.rb +1 -1
- data/test_graveyard/unit/busted/project_file_loader_test.rb +1 -1
- data/test_graveyard/unit/busted/setupinator_test.rb +1 -1
- data/test_graveyard/unit/busted/streaminator_test.rb +2 -2
- data/test_graveyard/unit/busted/task_invoker_test.rb +1 -1
- data/test_graveyard/unit/busted/test_includes_extractor_test.rb +1 -1
- data/test_graveyard/unit/busted/test_invoker_helper_test.rb +1 -1
- data/test_graveyard/unit/busted/test_invoker_test.rb +1 -1
- data/test_graveyard/unit/busted/tool_executor_helper_test.rb +1 -1
- data/test_graveyard/unit/busted/tool_executor_test.rb +1 -1
- data/test_graveyard/unit/busted/verbosinator_test.rb +1 -1
- data/test_graveyard/unit/preprocessinator_extractor_test.rb +1 -1
- data/vendor/c_exception/Gemfile +4 -0
- data/vendor/c_exception/lib/CException.h +1 -1
- data/vendor/c_exception/test/TestException.c +25 -14
- data/vendor/c_exception/test/TestException_Runner.c +74 -57
- data/vendor/cmock/Gemfile +11 -0
- data/vendor/cmock/lib/cmock_generator.rb +13 -12
- data/vendor/cmock/lib/cmock_generator_plugin_ignore_arg.rb +44 -0
- data/vendor/cmock/lib/cmock_generator_plugin_return_thru_ptr.rb +74 -0
- data/vendor/cmock/lib/cmock_generator_utils.rb +67 -42
- data/vendor/cmock/src/cmock.c +20 -30
- data/vendor/cmock/src/cmock.h +1 -0
- data/vendor/cmock/src/cmock_internals.h +43 -0
- data/vendor/cmock/test/c/TestCMockC.c +79 -36
- data/vendor/cmock/test/c/TestCMockC_Runner.c +2 -0
- data/vendor/cmock/test/spec/cmock_file_writer_spec.rb +21 -1
- data/vendor/cmock/test/spec/cmock_generator_plugin_array_spec.rb +52 -0
- data/vendor/cmock/test/system/test_interactions/all_plugins_coexist.yml +2 -0
- data/vendor/cmock/test/system/test_interactions/return_thru_ptr_ignore_arg.yml +235 -0
- data/vendor/cmock/test/test_helper.rb +10 -5
- data/vendor/cmock/test/unit/cmock_generator_main_test.rb +38 -0
- data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_arg_test.rb +116 -0
- data/vendor/cmock/test/unit/cmock_generator_plugin_return_thru_ptr_test.rb +134 -0
- data/vendor/cmock/test/unit/cmock_generator_utils_test.rb +58 -33
- data/vendor/cmock/vendor/c_exception/docs/CExceptionSummary.odt +0 -0
- data/vendor/cmock/vendor/c_exception/docs/CExceptionSummary.pdf +0 -0
- data/vendor/cmock/vendor/c_exception/docs/license.txt +30 -0
- data/vendor/cmock/vendor/c_exception/docs/readme.txt +236 -0
- data/vendor/cmock/vendor/c_exception/lib/CException.c +39 -0
- data/vendor/cmock/vendor/c_exception/lib/CException.h +70 -0
- data/vendor/cmock/vendor/c_exception/makefile +24 -0
- data/vendor/cmock/vendor/c_exception/rakefile.rb +41 -0
- data/vendor/cmock/vendor/c_exception/release/build.info +2 -0
- data/vendor/cmock/vendor/c_exception/release/version.info +2 -0
- data/vendor/cmock/vendor/c_exception/test/CExceptionConfig.h +27 -0
- data/vendor/cmock/vendor/c_exception/test/TestException.c +291 -0
- data/vendor/cmock/vendor/c_exception/test/TestException_Runner.c +62 -0
- data/vendor/cmock/vendor/unity/auto/colour_prompt.rb +94 -0
- data/vendor/cmock/vendor/unity/auto/colour_reporter.rb +39 -0
- data/vendor/cmock/vendor/unity/auto/generate_config.yml +36 -0
- data/vendor/cmock/vendor/unity/auto/generate_module.rb +202 -0
- data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +313 -0
- data/vendor/cmock/vendor/unity/auto/test_file_filter.rb +23 -0
- data/vendor/cmock/vendor/unity/auto/unity_test_summary.rb +139 -0
- data/vendor/cmock/vendor/unity/docs/Unity Summary.odt +0 -0
- data/vendor/cmock/vendor/unity/docs/Unity Summary.pdf +0 -0
- data/vendor/cmock/vendor/unity/docs/Unity Summary.txt +217 -0
- data/vendor/cmock/vendor/unity/docs/license.txt +31 -0
- data/vendor/cmock/vendor/unity/examples/helper/UnityHelper.c +10 -0
- data/vendor/cmock/vendor/unity/examples/helper/UnityHelper.h +12 -0
- data/vendor/cmock/vendor/unity/examples/makefile +40 -0
- data/vendor/cmock/vendor/unity/examples/rakefile.rb +32 -0
- data/vendor/cmock/vendor/unity/examples/rakefile_helper.rb +256 -0
- data/vendor/cmock/vendor/unity/examples/readme.txt +18 -0
- data/vendor/cmock/vendor/unity/examples/src/ProductionCode.c +24 -0
- data/vendor/cmock/vendor/unity/examples/src/ProductionCode.h +3 -0
- data/vendor/cmock/vendor/unity/examples/src/ProductionCode2.c +9 -0
- data/vendor/cmock/vendor/unity/examples/src/ProductionCode2.h +2 -0
- data/vendor/cmock/vendor/unity/examples/test/TestProductionCode.c +62 -0
- data/vendor/cmock/vendor/unity/examples/test/TestProductionCode2.c +31 -0
- data/vendor/cmock/vendor/unity/examples/test/no_ruby/TestProductionCode2_Runner.c +46 -0
- data/vendor/cmock/vendor/unity/examples/test/no_ruby/TestProductionCode_Runner.c +50 -0
- data/vendor/{unity → cmock/vendor/unity}/extras/fixture/build/MakefileWorker.mk +0 -0
- data/vendor/{unity → cmock/vendor/unity}/extras/fixture/build/filterGcov.sh +0 -0
- data/vendor/cmock/vendor/unity/extras/fixture/rakefile.rb +37 -0
- data/vendor/cmock/vendor/unity/extras/fixture/rakefile_helper.rb +178 -0
- data/vendor/cmock/vendor/unity/extras/fixture/readme.txt +9 -0
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.c +381 -0
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.h +81 -0
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_internals.h +44 -0
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +16 -0
- data/vendor/cmock/vendor/unity/extras/fixture/test/main/AllTests.c +21 -0
- data/vendor/cmock/vendor/unity/extras/fixture/test/testunity_fixture.c +39 -0
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_Test.c +321 -0
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +40 -0
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_output_Spy.c +56 -0
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_output_Spy.h +17 -0
- data/vendor/cmock/vendor/unity/makefile +35 -0
- data/vendor/cmock/vendor/unity/rakefile.rb +48 -0
- data/vendor/cmock/vendor/unity/rakefile_helper.rb +240 -0
- data/vendor/cmock/vendor/unity/release/build.info +2 -0
- data/vendor/cmock/vendor/unity/release/version.info +2 -0
- data/vendor/cmock/vendor/unity/src/unity.c +979 -0
- data/vendor/cmock/vendor/unity/src/unity.h +232 -0
- data/vendor/cmock/vendor/unity/src/unity_internals.h +424 -0
- data/vendor/cmock/vendor/unity/targets/gcc.yml +43 -0
- data/vendor/cmock/vendor/unity/targets/gcc_64.yml +44 -0
- data/vendor/cmock/vendor/unity/targets/hitech_picc18.yml +101 -0
- data/vendor/cmock/vendor/unity/targets/iar_arm_v4.yml +89 -0
- data/vendor/cmock/vendor/unity/targets/iar_arm_v5.yml +79 -0
- data/vendor/cmock/vendor/unity/targets/iar_arm_v5_3.yml +79 -0
- data/vendor/cmock/vendor/unity/targets/iar_armcortex_LM3S9B92_v5_4.yml +93 -0
- data/vendor/cmock/vendor/unity/targets/iar_cortexm3_v5.yml +83 -0
- data/vendor/cmock/vendor/unity/targets/iar_msp430.yml +94 -0
- data/vendor/cmock/vendor/unity/targets/iar_sh2a_v6.yml +85 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_cmd.c +54 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_def.c +50 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_cmd.c +76 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_def.c +72 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_new1.c +85 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_new2.c +85 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_param.c +73 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_run1.c +85 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_run2.c +85 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_yaml.c +86 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_new1.c +60 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_new2.c +63 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_param.c +51 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_run1.c +60 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_run2.c +63 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_yaml.c +64 -0
- data/vendor/cmock/vendor/unity/test/test_generate_test_runner.rb +94 -0
- data/vendor/cmock/vendor/unity/test/testdata/mocksample.c +51 -0
- data/vendor/cmock/vendor/unity/test/testdata/sample.yml +9 -0
- data/vendor/cmock/vendor/unity/test/testdata/testsample.c +51 -0
- data/vendor/cmock/vendor/unity/test/testparameterized.c +101 -0
- data/vendor/cmock/vendor/unity/test/testunity.c +2024 -0
- data/vendor/unity/Gemfile +4 -0
- data/vendor/unity/auto/generate_test_runner.rb +6 -3
- data/vendor/unity/examples/makefile +2 -2
- data/vendor/unity/examples/rakefile.rb +13 -2
- data/vendor/unity/extras/fixture/rakefile.rb +1 -1
- data/vendor/unity/extras/fixture/rakefile_helper.rb +4 -3
- data/vendor/unity/extras/fixture/src/unity_fixture.c +15 -12
- data/vendor/unity/extras/fixture/src/unity_fixture.h +5 -5
- data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +1 -1
- data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +6 -3
- data/vendor/unity/makefile +2 -2
- data/vendor/unity/src/unity.c +183 -16
- data/vendor/unity/src/unity.h +18 -5
- data/vendor/unity/src/unity_internals.h +57 -23
- data/vendor/unity/targets/gcc_64.yml +45 -0
- data/vendor/unity/test/testunity.c +436 -28
- metadata +200 -137
- data/ceedling-0.13.0.rc4.gem +0 -0
- data/ceedling.sublime-project +0 -8
- data/ceedling.sublime-workspace +0 -365
- data/lib/preprocessinator_includes_handler.rb +0 -55
- data/tags +0 -977
- data/vendor/cmock/vendor/hardmock/CHANGES +0 -78
- data/vendor/cmock/vendor/hardmock/LICENSE +0 -7
- data/vendor/cmock/vendor/hardmock/README +0 -70
- data/vendor/cmock/vendor/hardmock/Rakefile +0 -8
- data/vendor/cmock/vendor/hardmock/config/environment.rb +0 -12
- data/vendor/cmock/vendor/hardmock/lib/assert_error.rb +0 -23
- data/vendor/cmock/vendor/hardmock/lib/extend_test_unit.rb +0 -14
- data/vendor/cmock/vendor/hardmock/lib/hardmock.rb +0 -86
- data/vendor/cmock/vendor/hardmock/lib/hardmock/errors.rb +0 -22
- data/vendor/cmock/vendor/hardmock/lib/hardmock/expectation.rb +0 -229
- data/vendor/cmock/vendor/hardmock/lib/hardmock/expectation_builder.rb +0 -9
- data/vendor/cmock/vendor/hardmock/lib/hardmock/expector.rb +0 -26
- data/vendor/cmock/vendor/hardmock/lib/hardmock/method_cleanout.rb +0 -33
- data/vendor/cmock/vendor/hardmock/lib/hardmock/mock.rb +0 -180
- data/vendor/cmock/vendor/hardmock/lib/hardmock/mock_control.rb +0 -53
- data/vendor/cmock/vendor/hardmock/lib/hardmock/stubbing.rb +0 -210
- data/vendor/cmock/vendor/hardmock/lib/hardmock/trapper.rb +0 -31
- data/vendor/cmock/vendor/hardmock/lib/hardmock/utils.rb +0 -9
- data/vendor/cmock/vendor/hardmock/lib/test_unit_before_after.rb +0 -169
- data/vendor/cmock/vendor/hardmock/rake_tasks/rdoc.rake +0 -19
- data/vendor/cmock/vendor/hardmock/rake_tasks/rdoc_options.rb +0 -4
- data/vendor/cmock/vendor/hardmock/rake_tasks/test.rake +0 -22
- data/vendor/cmock/vendor/hardmock/test/functional/assert_error_test.rb +0 -52
- data/vendor/cmock/vendor/hardmock/test/functional/auto_verify_test.rb +0 -178
- data/vendor/cmock/vendor/hardmock/test/functional/direct_mock_usage_test.rb +0 -396
- data/vendor/cmock/vendor/hardmock/test/functional/hardmock_test.rb +0 -434
- data/vendor/cmock/vendor/hardmock/test/functional/stubbing_test.rb +0 -479
- data/vendor/cmock/vendor/hardmock/test/test_helper.rb +0 -43
- data/vendor/cmock/vendor/hardmock/test/unit/expectation_builder_test.rb +0 -19
- data/vendor/cmock/vendor/hardmock/test/unit/expectation_test.rb +0 -372
- data/vendor/cmock/vendor/hardmock/test/unit/expector_test.rb +0 -57
- data/vendor/cmock/vendor/hardmock/test/unit/method_cleanout_test.rb +0 -36
- data/vendor/cmock/vendor/hardmock/test/unit/mock_control_test.rb +0 -175
- data/vendor/cmock/vendor/hardmock/test/unit/mock_test.rb +0 -279
- data/vendor/cmock/vendor/hardmock/test/unit/test_unit_before_after_test.rb +0 -452
- data/vendor/cmock/vendor/hardmock/test/unit/trapper_test.rb +0 -62
- data/vendor/cmock/vendor/hardmock/test/unit/verify_error_test.rb +0 -40
@@ -1,78 +0,0 @@
|
|
1
|
-
Hardmock 1.3.7
|
2
|
-
|
3
|
-
* BUG FIX: expects! could not setup expectations for more than one concrete method on an object, since the method aliasing and rewriting was only taking place when the background mock instance was first created. This logic has been updated and now you can do all the things you'd expect.
|
4
|
-
|
5
|
-
Hardmock 1.3.6
|
6
|
-
|
7
|
-
* BUG FIX: In Rails apps (and others) Hardmock and Fixtures battled viciously over "setup" and "teardown" and "method_added" (and any other clever test enhancement tool, namely Mocha) causing unpredictable results, notably failure to auto-verify mocks after teardown (leading to false positive tests).
|
8
|
-
* The newly-added TestUnitBeforeAfter provides TestCase.before_setup and TestCase.after_teardown -- formal test wrapping hooks -- lets Hardmock provide its preparation and auto-verify behavior without contending for setup/teardown supremacy.
|
9
|
-
|
10
|
-
Hardmock 1.3.5
|
11
|
-
|
12
|
-
* Aliased should_receive => expects and and_return => returns for easier transition from rspec mock and flexmock users.
|
13
|
-
|
14
|
-
Hardmock 1.3.4
|
15
|
-
|
16
|
-
* Prevents accidental stubbing and mocking on NilClasses
|
17
|
-
|
18
|
-
Hardmock 1.3.3
|
19
|
-
|
20
|
-
* stubs! and expects! no longer require that their target methods exist in reality (this used to prevent you from stubbing methods that "exist" by virtue of "method_missing"
|
21
|
-
* Tweaked inner metaclass code to avoid collisions with rspec's "metaid" stuff
|
22
|
-
* Moved this project's Rake tasks into rake_tasks... otherwise Rails will load them, if Hardmock is installed as a Rails plugin
|
23
|
-
* Alias added: 'verify_hardmocks' is now an alias for 'verify_mocks' (some internal projects were using this modified method name as a means of cooexisting with mocha)
|
24
|
-
|
25
|
-
Hardmock 1.3.2
|
26
|
-
|
27
|
-
November 2007
|
28
|
-
|
29
|
-
* adds 'with' as an alternate syntax for specifying argument expectations.
|
30
|
-
|
31
|
-
Hardmock 1.3.1
|
32
|
-
|
33
|
-
October 2007
|
34
|
-
|
35
|
-
* Can use stubs! on a mock object
|
36
|
-
* expects! now generates mocked methods that can safely transfer runtime blocks to the mock instance itself
|
37
|
-
* No longer need to call "prepare_hardmock_control" when using stubs in the absence of mocks
|
38
|
-
* Stubs of concrete class or instance methods are restored to original state in teardown
|
39
|
-
|
40
|
-
Hardmock 1.3.0
|
41
|
-
|
42
|
-
October 2007
|
43
|
-
|
44
|
-
* Adds stubs! and expects! method to all objects and classes to support concrete stubbing/mocking.
|
45
|
-
|
46
|
-
Hardmock 1.2.3
|
47
|
-
|
48
|
-
Sat Apr 28 01:16:15 EDT 2007
|
49
|
-
|
50
|
-
* Re-release of 1.2.2 (which was canceled)... tasks moved to lib/tasks
|
51
|
-
|
52
|
-
Hardmock 1.2.2
|
53
|
-
|
54
|
-
Sat Apr 28 00:41:30 EDT 2007
|
55
|
-
|
56
|
-
* assert_error has been broken out into its own lib file
|
57
|
-
* Gem package can now run all tests successfully
|
58
|
-
* Internal code refactoring; a number of classes that were defined in hardmock.rb are now in their own files
|
59
|
-
|
60
|
-
Hardmock 1.2.1
|
61
|
-
|
62
|
-
Sat Apr 28 00:41:30 EDT 2007
|
63
|
-
|
64
|
-
* (botched release, see 1.2.2)
|
65
|
-
|
66
|
-
Hardmock 1.2.0
|
67
|
-
|
68
|
-
* You can now use "expect" in place of "expects" if you must.
|
69
|
-
* "inspect" has been added to the list of methods NOT erased by MethodCleanout.
|
70
|
-
|
71
|
-
Hardmock 1.1.0
|
72
|
-
|
73
|
-
* "expects" replaces "expect" ("expect" now raises Hardmock::DeprecationError)
|
74
|
-
* "verify_mocks" is now implicit in teardown, you needn't call it anymore
|
75
|
-
* Mocking methods that Mock would otherwise inherit from Object (eg, to_s) is now possible
|
76
|
-
* require 'hardmock' is all that's required to use the library now; no need to include in TestCase
|
77
|
-
|
78
|
-
(previously called CMock, translated to Hardmock on 2006-12-10)
|
@@ -1,7 +0,0 @@
|
|
1
|
-
Copyright (c) 2006,2007 David Crosby at Atomic Object, LLC
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
-
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
-
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,70 +0,0 @@
|
|
1
|
-
== Hardmock
|
2
|
-
|
3
|
-
Strict, ordered mock objects using very lightweight syntax in your tests.
|
4
|
-
|
5
|
-
== How
|
6
|
-
|
7
|
-
The basic procedure for using Hardmock in your tests is:
|
8
|
-
|
9
|
-
* require 'hardmock' (this happens automatically when being used as a Rails plugin)
|
10
|
-
* Create some mocks
|
11
|
-
* Setup some expectations
|
12
|
-
* Execute the target code
|
13
|
-
* Verification of calls is automatic in =teardown=
|
14
|
-
|
15
|
-
The expectations you set when using mocks are <b>strict</b> and <b>ordered</b>.
|
16
|
-
Expectations you declare by creating and using mocks are all considered together.
|
17
|
-
|
18
|
-
* Hardmock::Mock#expects will show you more examples
|
19
|
-
* Hardmock::SimpleExpectation will teach you more about expectation methods
|
20
|
-
|
21
|
-
== Example
|
22
|
-
|
23
|
-
create_mocks :garage, :car
|
24
|
-
|
25
|
-
# Set some expectations
|
26
|
-
@garage.expects.open_door
|
27
|
-
@car.expects.start(:choke)
|
28
|
-
@car.expects.drive(:reverse, 5.mph)
|
29
|
-
|
30
|
-
# Execute the code (this code is usually, obviously, in your class under test)
|
31
|
-
@garage.open_door
|
32
|
-
@car.start :choke
|
33
|
-
@car.drive :reverse, 5.mph
|
34
|
-
|
35
|
-
verify_mocks # OPTIONAL, teardown will do this for you
|
36
|
-
|
37
|
-
Expects <tt>@garage.open_door</tt>, <tt>@car.start(:choke)</tt> and <tt>@car.drive(:reverse, 5.mph)</tt> to be called in that order, with those specific arguments.
|
38
|
-
* Violations of expectations, such as mis-ordered calls, calls on wrong objects, or incorrect methods result in Hardmock::ExpectationError
|
39
|
-
* <tt>verify_mocks</tt> will raise VerifyError if not all expectations have been met.
|
40
|
-
|
41
|
-
== Download and Install
|
42
|
-
|
43
|
-
* Homepage: http://hardmock.rubyforge.org
|
44
|
-
* GEM or TGZ or ZIP: http://rubyforge.org/frs/?group_id=2742
|
45
|
-
* Rails plugin: script/plugin install
|
46
|
-
* SVN access: svn co svn://rubyforge.org/var/svn/hardmock/trunk
|
47
|
-
* Developer SVN access: svn co svn://developername@rubyforge.org/var/svn/hardmock/trunk
|
48
|
-
|
49
|
-
== Setup for Test::Unit
|
50
|
-
|
51
|
-
require 'hardmock'
|
52
|
-
require 'assert_error' # OPTIONAL: this adds the TestUnit extension 'assert_error'
|
53
|
-
|
54
|
-
NOTE: If installed as a Rails plugin, init.rb does this for you... nothing else is needed.
|
55
|
-
|
56
|
-
== Setup for RSpec
|
57
|
-
|
58
|
-
Get this into your spec helper or environment or Rakefile or wherever you prefer:
|
59
|
-
|
60
|
-
Spec::Runner.configure do |configuration|
|
61
|
-
configuration.include Hardmock
|
62
|
-
configuration.after(:each) {verify_mocks}
|
63
|
-
end
|
64
|
-
|
65
|
-
This puts the implicit conveniences into your spec context, like "create_mocks" etc, and also provides for automatic
|
66
|
-
"verify_mocks" after each Example is run.
|
67
|
-
|
68
|
-
== Author
|
69
|
-
* David Crosby crosby at http://atomicobject.com
|
70
|
-
* (c) 2006,2007 Atomic Object LLC
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# The path to the root directory of your application.
|
2
|
-
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
3
|
-
|
4
|
-
ADDITIONAL_LOAD_PATHS = []
|
5
|
-
ADDITIONAL_LOAD_PATHS.concat %w(
|
6
|
-
lib
|
7
|
-
).map { |dir| "#{APP_ROOT}/#{dir}" }.select { |dir| File.directory?(dir) }
|
8
|
-
|
9
|
-
# Prepend to $LOAD_PATH
|
10
|
-
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
|
11
|
-
|
12
|
-
# Require any additional libraries needed
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'test/unit/assertions'
|
2
|
-
|
3
|
-
module Test::Unit #:nodoc:#
|
4
|
-
module Assertions #:nodoc:#
|
5
|
-
# A better 'assert_raise'. +patterns+ can be one or more Regexps, or a literal String that
|
6
|
-
# must match the entire error message.
|
7
|
-
def assert_error(err_type,*patterns,&block)
|
8
|
-
assert_not_nil block, "assert_error requires a block"
|
9
|
-
assert((err_type and err_type.kind_of?(Class)), "First argument to assert_error has to be an error type")
|
10
|
-
err = assert_raise(err_type) do
|
11
|
-
block.call
|
12
|
-
end
|
13
|
-
patterns.each do |pattern|
|
14
|
-
case pattern
|
15
|
-
when Regexp
|
16
|
-
assert_match(pattern, err.message)
|
17
|
-
else
|
18
|
-
assert_equal pattern, err.message
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'test/unit/testcase'
|
3
|
-
class Test::Unit::TestCase
|
4
|
-
include Hardmock
|
5
|
-
end
|
6
|
-
|
7
|
-
require 'test_unit_before_after'
|
8
|
-
Test::Unit::TestCase.before_setup do |test|
|
9
|
-
test.prepare_hardmock_control
|
10
|
-
end
|
11
|
-
|
12
|
-
Test::Unit::TestCase.after_teardown do |test|
|
13
|
-
test.verify_mocks
|
14
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require 'hardmock/method_cleanout'
|
2
|
-
require 'hardmock/mock'
|
3
|
-
require 'hardmock/mock_control'
|
4
|
-
require 'hardmock/utils'
|
5
|
-
require 'hardmock/errors'
|
6
|
-
require 'hardmock/trapper'
|
7
|
-
require 'hardmock/expector'
|
8
|
-
require 'hardmock/expectation'
|
9
|
-
require 'hardmock/expectation_builder'
|
10
|
-
require 'hardmock/stubbing'
|
11
|
-
|
12
|
-
module Hardmock
|
13
|
-
|
14
|
-
# Create one or more new Mock instances in your test suite.
|
15
|
-
# Once created, the Mocks are accessible as instance variables in your test.
|
16
|
-
# Newly built Mocks are added to the full set of Mocks for this test, which will
|
17
|
-
# be verified when you call verify_mocks.
|
18
|
-
#
|
19
|
-
# create_mocks :donkey, :cat # Your test now has @donkey and @cat
|
20
|
-
# create_mock :dog # Test now has @donkey, @cat and @dog
|
21
|
-
#
|
22
|
-
# The first call returned a hash { :donkey => @donkey, :cat => @cat }
|
23
|
-
# and the second call returned { :dog => @dog }
|
24
|
-
#
|
25
|
-
# For more info on how to use your mocks, see Mock and Expectation
|
26
|
-
#
|
27
|
-
def create_mocks(*mock_names)
|
28
|
-
prepare_hardmock_control unless @main_mock_control
|
29
|
-
|
30
|
-
mocks = {}
|
31
|
-
mock_names.each do |mock_name|
|
32
|
-
raise ArgumentError, "'nil' is not a valid name for a mock" if mock_name.nil?
|
33
|
-
mock_name = mock_name.to_s
|
34
|
-
mock_object = Mock.new(mock_name, @main_mock_control)
|
35
|
-
mocks[mock_name.to_sym] = mock_object
|
36
|
-
self.instance_variable_set "@#{mock_name}", mock_object
|
37
|
-
end
|
38
|
-
@all_mocks ||= {}
|
39
|
-
@all_mocks.merge! mocks
|
40
|
-
|
41
|
-
return mocks.clone
|
42
|
-
end
|
43
|
-
|
44
|
-
def prepare_hardmock_control
|
45
|
-
if @main_mock_control.nil?
|
46
|
-
@main_mock_control = MockControl.new
|
47
|
-
$main_mock_control = @main_mock_control
|
48
|
-
else
|
49
|
-
raise "@main_mock_control is already setup for this test!"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
alias :create_mock :create_mocks
|
54
|
-
|
55
|
-
# Ensures that all expectations have been met. If not, VerifyException is
|
56
|
-
# raised.
|
57
|
-
#
|
58
|
-
# <b>You normally won't need to call this yourself.</b> Within Test::Unit::TestCase, this will be done automatically at teardown time.
|
59
|
-
#
|
60
|
-
# * +force+ -- if +false+, and a VerifyError or ExpectationError has already occurred, this method will not raise. This is to help you suppress repeated errors when if you're calling #verify_mocks in the teardown method of your test suite. BE WARNED - only use this if you're sure you aren't obscuring useful information. Eg, if your code handles exceptions internally, and an ExpectationError gets gobbled up by your +rescue+ block, the cause of failure for your test may be hidden from you. For this reason, #verify_mocks defaults to force=true as of Hardmock 1.0.1
|
61
|
-
def verify_mocks(force=true)
|
62
|
-
return unless @main_mock_control
|
63
|
-
return if @main_mock_control.disappointed? and !force
|
64
|
-
@main_mock_control.verify
|
65
|
-
ensure
|
66
|
-
@main_mock_control.clear_expectations if @main_mock_control
|
67
|
-
$main_mock_control = nil
|
68
|
-
reset_stubs
|
69
|
-
end
|
70
|
-
|
71
|
-
alias :verify_hardmocks :verify_mocks
|
72
|
-
|
73
|
-
# Purge the main MockControl of all expectations, restore all concrete stubbed/mocked methods
|
74
|
-
def clear_expectations
|
75
|
-
@main_mock_control.clear_expectations if @main_mock_control
|
76
|
-
reset_stubs
|
77
|
-
$main_mock_control = nil
|
78
|
-
end
|
79
|
-
|
80
|
-
def reset_stubs
|
81
|
-
Hardmock.restore_all_replaced_methods
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
require 'extend_test_unit'
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Hardmock
|
2
|
-
# Raised when:
|
3
|
-
# * Unexpected method is called on a mock object
|
4
|
-
# * Bad arguments passed to an expected call
|
5
|
-
class ExpectationError < StandardError #:nodoc:#
|
6
|
-
end
|
7
|
-
|
8
|
-
# Raised for methods that should no longer be called. Hopefully, the exception message contains helpful alternatives.
|
9
|
-
class DeprecationError < StandardError #:nodoc:#
|
10
|
-
end
|
11
|
-
|
12
|
-
# Raised when stubbing fails
|
13
|
-
class StubbingError < StandardError #:nodoc:#
|
14
|
-
end
|
15
|
-
|
16
|
-
# Raised when it is discovered that an expected method call was never made.
|
17
|
-
class VerifyError < StandardError #:nodoc:#
|
18
|
-
def initialize(msg,unmet_expectations)
|
19
|
-
super("#{msg}:" + unmet_expectations.map { |ex| "\n * #{ex.to_s}" }.join)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,229 +0,0 @@
|
|
1
|
-
require 'hardmock/utils'
|
2
|
-
|
3
|
-
module Hardmock
|
4
|
-
class Expectation
|
5
|
-
include Utils
|
6
|
-
attr_reader :block_value
|
7
|
-
|
8
|
-
def initialize(options) #:nodoc:
|
9
|
-
@options = options
|
10
|
-
end
|
11
|
-
|
12
|
-
def apply_method_call(mock,mname,args,block) #:nodoc:
|
13
|
-
unless @options[:mock].equal?(mock)
|
14
|
-
raise anger("Wrong object", mock,mname,args)
|
15
|
-
end
|
16
|
-
unless @options[:method] == mname
|
17
|
-
raise anger("Wrong method",mock,mname,args)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Tester-defined block to invoke at method-call-time:
|
21
|
-
expectation_block = @options[:block]
|
22
|
-
|
23
|
-
expected_args = @options[:arguments]
|
24
|
-
# if we have a block, we can skip the argument check if none were specified
|
25
|
-
unless (expected_args.nil? || expected_args.empty?) && expectation_block && !@options[:suppress_arguments_to_block]
|
26
|
-
unless expected_args == args
|
27
|
-
raise anger("Wrong arguments",mock,mname,args)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
relayed_args = args.dup
|
32
|
-
if block
|
33
|
-
if expectation_block.nil?
|
34
|
-
# Can't handle a runtime block without an expectation block
|
35
|
-
raise ExpectationError.new("Unexpected block provided to #{to_s}")
|
36
|
-
else
|
37
|
-
# Runtime blocks are passed as final argument to the expectation block
|
38
|
-
unless @options[:suppress_arguments_to_block]
|
39
|
-
relayed_args << block
|
40
|
-
else
|
41
|
-
# Arguments suppressed; send only the block
|
42
|
-
relayed_args = [block]
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Run the expectation block:
|
48
|
-
@block_value = expectation_block.call(*relayed_args) if expectation_block
|
49
|
-
|
50
|
-
raise @options[:raises] unless @options[:raises].nil?
|
51
|
-
|
52
|
-
return_value = @options[:returns]
|
53
|
-
if return_value.nil?
|
54
|
-
return @block_value
|
55
|
-
else
|
56
|
-
return return_value
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# Set the return value for an expected method call.
|
61
|
-
# Eg,
|
62
|
-
# @cash_machine.expects.withdraw(20,:dollars).returns(20.00)
|
63
|
-
def returns(val)
|
64
|
-
@options[:returns] = val
|
65
|
-
self
|
66
|
-
end
|
67
|
-
alias_method :and_return, :returns
|
68
|
-
|
69
|
-
# Set the arguments for an expected method call.
|
70
|
-
# Eg,
|
71
|
-
# @cash_machine.expects.deposit.with(20, "dollars").returns(:balance => "20")
|
72
|
-
def with(*args)
|
73
|
-
@options[:arguments] = args
|
74
|
-
self
|
75
|
-
end
|
76
|
-
|
77
|
-
# Rig an expected method to raise an exception when the mock is invoked.
|
78
|
-
#
|
79
|
-
# Eg,
|
80
|
-
# @cash_machine.expects.withdraw(20,:dollars).raises "Insufficient funds"
|
81
|
-
#
|
82
|
-
# The argument can be:
|
83
|
-
# * an Exception -- will be used directly
|
84
|
-
# * a String -- will be used as the message for a RuntimeError
|
85
|
-
# * nothing -- RuntimeError.new("An Error") will be raised
|
86
|
-
def raises(err=nil)
|
87
|
-
case err
|
88
|
-
when Exception
|
89
|
-
@options[:raises] = err
|
90
|
-
when String
|
91
|
-
@options[:raises] = RuntimeError.new(err)
|
92
|
-
else
|
93
|
-
@options[:raises] = RuntimeError.new("An Error")
|
94
|
-
end
|
95
|
-
self
|
96
|
-
end
|
97
|
-
|
98
|
-
# Convenience method: assumes +block_value+ is set, and is set to a Proc
|
99
|
-
# (or anything that responds to 'call')
|
100
|
-
#
|
101
|
-
# light_event = @traffic_light.trap.subscribe(:light_changes)
|
102
|
-
#
|
103
|
-
# # This code will meet the expectation:
|
104
|
-
# @traffic_light.subscribe :light_changes do |color|
|
105
|
-
# puts color
|
106
|
-
# end
|
107
|
-
#
|
108
|
-
# The color-handling block is now stored in <tt>light_event.block_value</tt>
|
109
|
-
#
|
110
|
-
# The block can be invoked like this:
|
111
|
-
#
|
112
|
-
# light_event.trigger :red
|
113
|
-
#
|
114
|
-
# See Mock#trap and Mock#expects for information on using expectation objects
|
115
|
-
# after they are set.
|
116
|
-
#
|
117
|
-
def trigger(*block_arguments)
|
118
|
-
unless block_value
|
119
|
-
raise ExpectationError.new("No block value is currently set for expectation #{to_s}")
|
120
|
-
end
|
121
|
-
unless block_value.respond_to?(:call)
|
122
|
-
raise ExpectationError.new("Can't apply trigger to #{block_value} for expectation #{to_s}")
|
123
|
-
end
|
124
|
-
block_value.call *block_arguments
|
125
|
-
end
|
126
|
-
|
127
|
-
# Used when an expected method accepts a block at runtime.
|
128
|
-
# When the expected method is invoked, the block passed to
|
129
|
-
# that method will be invoked as well.
|
130
|
-
#
|
131
|
-
# NOTE: ExpectationError will be thrown upon running the expected method
|
132
|
-
# if the arguments you set up in +yields+ do not properly match up with
|
133
|
-
# the actual block that ends up getting passed.
|
134
|
-
#
|
135
|
-
# == Examples
|
136
|
-
# <b>Single invocation</b>: The block passed to +lock_down+ gets invoked
|
137
|
-
# once with no arguments:
|
138
|
-
#
|
139
|
-
# @safe_zone.expects.lock_down.yields
|
140
|
-
#
|
141
|
-
# # (works on code that looks like:)
|
142
|
-
# @safe_zone.lock_down do
|
143
|
-
# # ... this block invoked once
|
144
|
-
# end
|
145
|
-
#
|
146
|
-
# <b>Multi-parameter blocks:</b> The block passed to +each_item+ gets
|
147
|
-
# invoked twice, with <tt>:item1</tt> the first time, and with
|
148
|
-
# <tt>:item2</tt> the second time:
|
149
|
-
#
|
150
|
-
# @fruit_basket.expects.each_with_index.yields [:apple,1], [:orange,2]
|
151
|
-
#
|
152
|
-
# # (works on code that looks like:)
|
153
|
-
# @fruit_basket.each_with_index do |fruit,index|
|
154
|
-
# # ... this block invoked with fruit=:apple, index=1,
|
155
|
-
# # ... and then with fruit=:orange, index=2
|
156
|
-
# end
|
157
|
-
#
|
158
|
-
# <b>Arrays can be passed as arguments too</b>... if the block
|
159
|
-
# takes a single argument and you want to pass a series of arrays into it,
|
160
|
-
# that will work as well:
|
161
|
-
#
|
162
|
-
# @list_provider.expects.each_list.yields [1,2,3], [4,5,6]
|
163
|
-
#
|
164
|
-
# # (works on code that looks like:)
|
165
|
-
# @list_provider.each_list do |list|
|
166
|
-
# # ... list is [1,2,3] the first time
|
167
|
-
# # ... list is [4,5,6] the second time
|
168
|
-
# end
|
169
|
-
#
|
170
|
-
# <b>Return value</b>: You can set the return value for the method that
|
171
|
-
# accepts the block like so:
|
172
|
-
#
|
173
|
-
# @cruncher.expects.do_things.yields(:bean1,:bean2).returns("The Results")
|
174
|
-
#
|
175
|
-
# <b>Raising errors</b>: You can set the raised exception for the method that
|
176
|
-
# accepts the block. NOTE: the error will be raised _after_ the block has
|
177
|
-
# been invoked.
|
178
|
-
#
|
179
|
-
# # :bean1 and :bean2 will be passed to the block, then an error is raised:
|
180
|
-
# @cruncher.expects.do_things.yields(:bean1,:bean2).raises("Too crunchy")
|
181
|
-
#
|
182
|
-
def yields(*items)
|
183
|
-
@options[:suppress_arguments_to_block] = true
|
184
|
-
if items.empty?
|
185
|
-
# Yield once
|
186
|
-
@options[:block] = lambda do |block|
|
187
|
-
if block.arity != 0 and block.arity != -1
|
188
|
-
raise ExpectationError.new("The given block was expected to have no parameter count; instead, got #{block.arity} to <#{to_s}>")
|
189
|
-
end
|
190
|
-
block.call
|
191
|
-
end
|
192
|
-
else
|
193
|
-
# Yield one or more specific items
|
194
|
-
@options[:block] = lambda do |block|
|
195
|
-
items.each do |item|
|
196
|
-
if item.kind_of?(Array)
|
197
|
-
if block.arity == item.size
|
198
|
-
# Unfold the array into the block's arguments:
|
199
|
-
block.call *item
|
200
|
-
elsif block.arity == 1
|
201
|
-
# Just pass the array in
|
202
|
-
block.call item
|
203
|
-
else
|
204
|
-
# Size mismatch
|
205
|
-
raise ExpectationError.new("Can't pass #{item.inspect} to block with arity #{block.arity} to <#{to_s}>")
|
206
|
-
end
|
207
|
-
else
|
208
|
-
if block.arity != 1
|
209
|
-
# Size mismatch
|
210
|
-
raise ExpectationError.new("Can't pass #{item.inspect} to block with arity #{block.arity} to <#{to_s}>")
|
211
|
-
end
|
212
|
-
block.call item
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
self
|
218
|
-
end
|
219
|
-
|
220
|
-
def to_s # :nodoc:
|
221
|
-
format_method_call_string(@options[:mock],@options[:method],@options[:arguments])
|
222
|
-
end
|
223
|
-
|
224
|
-
private
|
225
|
-
def anger(msg, mock,mname,args)
|
226
|
-
ExpectationError.new("#{msg}: expected call <#{to_s}> but was <#{format_method_call_string(mock,mname,args)}>")
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|