ceedling 0.12.2 → 0.13.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -14
- data/.gitmodules +9 -0
- data/.rspec +1 -0
- data/Gemfile +10 -2
- data/README.md +97 -67
- data/{new_project_template → assets}/project.yml +0 -0
- data/{new_project_template → assets}/rakefile.rb +0 -0
- data/bin/ceedling +77 -44
- data/ceedling.gemspec +18 -5
- data/config/test_environment.rb +12 -0
- data/docs/CeedlingLogo.png +0 -0
- data/docs/CeedlingPacket.md +1934 -0
- data/docs/CeedlingPacket.odt +0 -0
- data/docs/CeedlingPacket.pdf +0 -0
- data/examples/temp_sensor/project.yml +71 -74
- data/examples/temp_sensor/rakefile.rb +3 -5
- data/examples/temp_sensor/src/AdcConductor.h +2 -0
- data/examples/temp_sensor/src/TemperatureCalculator.h +2 -0
- data/examples/temp_sensor/src/Types.h +0 -13
- data/examples/temp_sensor/src/UsartBaudRateRegisterCalculator.h +2 -0
- data/examples/temp_sensor/src/UsartHardware.c +0 -12
- data/examples/temp_sensor/src/UsartHardware.h +0 -1
- data/examples/temp_sensor/test/{test_AdcConductor.c → TestAdcConductor.c} +0 -0
- data/examples/temp_sensor/test/{test_AdcHardware.c → TestAdcHardware.c} +0 -0
- data/examples/temp_sensor/test/{test_AdcModel.c → TestAdcModel.c} +0 -0
- data/examples/temp_sensor/test/{test_Executor.c → TestExecutor.c} +0 -0
- data/examples/temp_sensor/test/{test_Main.c → TestMain.c} +0 -0
- data/examples/temp_sensor/test/{test_Model.c → TestModel.c} +0 -0
- data/examples/temp_sensor/test/{test_TaskScheduler.c → TestTaskScheduler.c} +0 -0
- data/examples/temp_sensor/test/{test_TemperatureCalculator.c → TestTemperatureCalculator.c} +0 -0
- data/examples/temp_sensor/test/{test_TemperatureFilter.c → TestTemperatureFilter.c} +0 -2
- data/examples/temp_sensor/test/{test_TimerConductor.c → TestTimerConductor.c} +0 -0
- data/examples/temp_sensor/test/{test_TimerHardware.c → TestTimerHardware.c} +0 -0
- data/examples/temp_sensor/test/{test_TimerModel.c → TestTimerModel.c} +0 -0
- data/examples/temp_sensor/test/{test_UsartBaudRateRegisterCalculator.c → TestUsartBaudRateRegisterCalculator.c} +0 -0
- data/examples/temp_sensor/test/{test_UsartConductor.c → TestUsartConductor.c} +0 -0
- data/examples/temp_sensor/test/{test_UsartHardware.c → TestUsartHardware.c} +0 -20
- data/examples/temp_sensor/test/{test_UsartModel.c → TestUsartModel.c} +0 -0
- data/examples/temp_sensor/test/support/UnityHelper.c +7 -5
- data/examples/temp_sensor/test/support/UnityHelper.h +5 -5
- data/{new_project_template/vendor/ceedling/lib → lib}/build_invoker_utils.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/cacheinator.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/cacheinator_helper.rb +0 -0
- data/lib/ceedling.rb +16 -4
- data/lib/ceedling/version.rb +4 -4
- data/lib/ceedling/version.rb.erb +1 -1
- data/{new_project_template/vendor/ceedling/lib → lib}/cmock_builder.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/configurator.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/configurator_builder.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/configurator_plugins.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/configurator_setup.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/configurator_validator.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/constants.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/defaults.rb +2 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/dependinator.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/erb_wrapper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/file_finder.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/file_finder_helper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/file_path_utils.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/file_system_utils.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/file_system_wrapper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/file_wrapper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/flaginator.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/generator.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/generator_helper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/generator_test_results.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/generator_test_results_sanity_checker.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/generator_test_runner.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/loginator.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/makefile.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/objects.yml +0 -2
- data/lib/par_map.rb +19 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/plugin.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/plugin_builder.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/plugin_manager.rb +20 -8
- data/{new_project_template/vendor/ceedling/lib → lib}/plugin_manager_helper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/plugin_reportinator.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/plugin_reportinator_helper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/preprocessinator.rb +0 -0
- data/lib/preprocessinator_extractor.rb +30 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/preprocessinator_file_handler.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/preprocessinator_helper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/preprocessinator_includes_handler.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/project_config_manager.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/project_file_loader.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/rake_utils.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/rake_wrapper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/rakefile.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/release_invoker.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/release_invoker_helper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/reportinator.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/rules_cmock.rake +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/rules_preprocess.rake +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/rules_release.rake +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/rules_release_deep_dependencies.rake +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/rules_tests.rake +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/rules_tests_deep_dependencies.rake +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/setupinator.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/stream_wrapper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/streaminator.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/streaminator_helper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/system_utils.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/system_wrapper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/task_invoker.rb +7 -3
- data/{new_project_template/vendor/ceedling/lib → lib}/tasks_base.rake +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/tasks_filesystem.rake +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/tasks_release.rake +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/tasks_release_deep_dependencies.rake +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/tasks_tests.rake +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/tasks_tests_deep_dependencies.rake +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/tasks_vendor.rake +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/test_includes_extractor.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/test_invoker.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/test_invoker_helper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/tool_executor.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/tool_executor_helper.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/verbosinator.rb +0 -0
- data/{new_project_template/vendor/ceedling/lib → lib}/yaml_wrapper.rb +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/bullseye/bullseye.rake +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/bullseye/bullseye.rb +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/bullseye/defaults.yml +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/bullseye/readme.txt +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/bullseye/template.erb +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/gcov/defaults.yml +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/gcov/gcov.rake +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/gcov/gcov.rb +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/gcov/readme.txt +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/gcov/template.erb +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/module_generator/config/module_generator.yml +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/module_generator/lib/module_generator.rb +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/module_generator/module_generator.rake +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/stdout_ide_tests_report/config/stdout_ide_tests_report.yml +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/stdout_ide_tests_report/lib/stdout_ide_tests_report.rb +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/stdout_pretty_tests_report/assets/template.erb +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/stdout_pretty_tests_report/config/stdout_pretty_tests_report.yml +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/stdout_pretty_tests_report/lib/stdout_pretty_tests_report.rb +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/warnings_report/warnings_report.rb +0 -0
- data/{new_project_template/vendor/ceedling/plugins → plugins}/xml_tests_report/xml_tests_report.rb +0 -0
- data/rakefile.rb +14 -0
- data/release/build.info +2 -0
- data/{new_project_template/vendor/ceedling/release → release}/version.info +0 -0
- data/spec/configurator_builder_spec.rb +7 -0
- data/spec/configurator_helper_spec.rb +5 -0
- data/spec/configurator_spec.rb +10 -0
- data/spec/par_map_spec.rb +57 -0
- data/spec/preprocessinator_extractor_spec.rb +46 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/uncatagorized_specs_spec.rb +8 -0
- data/test_graveyard/integration/paths.yml +17 -0
- data/test_graveyard/integration/paths_test.rb +80 -0
- data/test_graveyard/integration/rake_rules_aux_dependencies_test.rb +75 -0
- data/test_graveyard/integration/rake_rules_cmock_test.rb +74 -0
- data/test_graveyard/integration/rake_rules_preprocess_test.rb +178 -0
- data/test_graveyard/integration/rake_rules_test.rb +268 -0
- data/test_graveyard/integration/rake_tasks_test.rb +103 -0
- data/test_graveyard/integration_test_helper.rb +34 -0
- data/test_graveyard/rakefile_rules.rb +10 -0
- data/test_graveyard/rakefile_rules_aux_dependencies.rb +10 -0
- data/test_graveyard/rakefile_rules_cmock.rb +10 -0
- data/test_graveyard/rakefile_rules_preprocess.rb +10 -0
- data/test_graveyard/rakefile_tasks.rb +10 -0
- data/test_graveyard/system/file_system_dependencies.yml +20 -0
- data/test_graveyard/system/file_system_kitchen_sink.yml +20 -0
- data/test_graveyard/system/file_system_mocks.yml +20 -0
- data/test_graveyard/system/file_system_preprocess.yml +20 -0
- data/test_graveyard/system/file_system_simple.yml +20 -0
- data/test_graveyard/system/file_system_test.rb +78 -0
- data/test_graveyard/system/mocks/include/a_file.h +2 -0
- data/test_graveyard/system/mocks/include/other_stuff.h +2 -0
- data/test_graveyard/system/mocks/include/stuff.h +3 -0
- data/test_graveyard/system/mocks/source/a_file.c +9 -0
- data/test_graveyard/system/mocks/test/test_a_file.c +41 -0
- data/test_graveyard/system/mocks/test/test_no_file.c +14 -0
- data/test_graveyard/system/project_mocks.yml +43 -0
- data/test_graveyard/system/project_mocks_test.rb +38 -0
- data/test_graveyard/system/project_simple.yml +36 -0
- data/test_graveyard/system/project_simple_test.rb +39 -0
- data/test_graveyard/system/rule_mocks_test.rb +44 -0
- data/test_graveyard/system/rule_runners_test.rb +44 -0
- data/test_graveyard/system/simple/include/other_stuff.h +2 -0
- data/test_graveyard/system/simple/include/stuff.h +3 -0
- data/test_graveyard/system/simple/source/other_stuff.c +6 -0
- data/test_graveyard/system/simple/source/stuff.c +7 -0
- data/test_graveyard/system/simple/test/test_other_stuff.c +30 -0
- data/test_graveyard/system/simple/test/test_stuff.c +51 -0
- data/test_graveyard/system_test_helper.rb +73 -0
- data/test_graveyard/test_helper.rb +93 -0
- data/test_graveyard/unit/busted/configurator_builder_test.rb +571 -0
- data/test_graveyard/unit/busted/configurator_helper_test.rb +234 -0
- data/test_graveyard/unit/busted/configurator_test.rb +232 -0
- data/test_graveyard/unit/busted/configurator_validator_test.rb +169 -0
- data/test_graveyard/unit/busted/deep_merge_fix_test.rb +55 -0
- data/test_graveyard/unit/busted/dependinator_test.rb +129 -0
- data/test_graveyard/unit/busted/file_finder_helper_test.rb +45 -0
- data/test_graveyard/unit/busted/file_finder_test.rb +114 -0
- data/test_graveyard/unit/busted/file_path_utils_test.rb +97 -0
- data/test_graveyard/unit/busted/file_system_utils_test.rb +21 -0
- data/test_graveyard/unit/busted/generator_test.rb +187 -0
- data/test_graveyard/unit/busted/generator_test_results_test.rb +129 -0
- data/test_graveyard/unit/busted/generator_test_runner_test.rb +478 -0
- data/test_graveyard/unit/busted/preprocessinator_file_handler_test.rb +38 -0
- data/test_graveyard/unit/busted/preprocessinator_helper_test.rb +156 -0
- data/test_graveyard/unit/busted/preprocessinator_includes_handler_test.rb +93 -0
- data/test_graveyard/unit/busted/preprocessinator_test.rb +57 -0
- data/test_graveyard/unit/busted/project_file_loader_test.rb +142 -0
- data/test_graveyard/unit/busted/setupinator_test.rb +45 -0
- data/test_graveyard/unit/busted/streaminator_test.rb +49 -0
- data/test_graveyard/unit/busted/task_invoker_test.rb +69 -0
- data/test_graveyard/unit/busted/test_includes_extractor_test.rb +111 -0
- data/test_graveyard/unit/busted/test_invoker_helper_test.rb +62 -0
- data/test_graveyard/unit/busted/test_invoker_test.rb +47 -0
- data/test_graveyard/unit/busted/tool_executor_helper_test.rb +100 -0
- data/test_graveyard/unit/busted/tool_executor_test.rb +351 -0
- data/test_graveyard/unit/busted/verbosinator_test.rb +65 -0
- data/test_graveyard/unit/preprocessinator_extractor_test.rb +731 -0
- data/test_graveyard/unit_test_helper.rb +16 -0
- data/vendor/behaviors/Manifest.txt +9 -0
- data/vendor/behaviors/Rakefile +19 -0
- data/vendor/behaviors/lib/behaviors.rb +76 -0
- data/vendor/behaviors/lib/behaviors/reporttask.rb +158 -0
- data/vendor/behaviors/test/behaviors_tasks_test.rb +73 -0
- data/vendor/behaviors/test/behaviors_test.rb +50 -0
- data/vendor/behaviors/test/tasks_test/Rakefile +19 -0
- data/vendor/behaviors/test/tasks_test/lib/user.rb +2 -0
- data/vendor/behaviors/test/tasks_test/test/user_test.rb +17 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/c_exception/lib/CException.c +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/c_exception/lib/CException.h +1 -1
- data/vendor/c_exception/release/build.info +2 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/c_exception/release/version.info +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/config/production_environment.rb +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/config/test_environment.rb +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/lib/cmock.rb +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/lib/cmock_config.rb +3 -3
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/lib/cmock_file_writer.rb +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/lib/cmock_generator.rb +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/lib/cmock_generator_plugin_array.rb +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/lib/cmock_generator_plugin_callback.rb +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/lib/cmock_generator_plugin_cexception.rb +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/lib/cmock_generator_plugin_expect.rb +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/lib/cmock_generator_plugin_ignore.rb +14 -4
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/lib/cmock_generator_utils.rb +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/lib/cmock_header_parser.rb +9 -5
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/lib/cmock_plugin_manager.rb +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/lib/cmock_unityhelper_parser.rb +75 -74
- data/vendor/cmock/release/build.info +2 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/release/version.info +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/src/cmock.c +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/cmock/src/cmock.h +0 -0
- data/vendor/constructor/History.rdoc +19 -0
- data/vendor/constructor/README.rdoc +72 -0
- data/vendor/constructor/Rakefile +33 -0
- data/vendor/constructor/homepage/Notes.txt +27 -0
- data/vendor/constructor/homepage/Rakefile +15 -0
- data/vendor/constructor/homepage/index.erb +27 -0
- data/vendor/constructor/homepage/index.html +36 -0
- data/vendor/constructor/homepage/page_header.graffle +0 -0
- data/vendor/constructor/homepage/page_header.html +9 -0
- data/vendor/constructor/homepage/page_header.png +0 -0
- data/vendor/constructor/homepage/sample_code.png +0 -0
- data/vendor/constructor/homepage/sample_code.rb +12 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/constructor/lib/constructor.rb +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/constructor/lib/constructor_struct.rb +0 -0
- data/vendor/constructor/specs/constructor_spec.rb +407 -0
- data/vendor/constructor/specs/constructor_struct_spec.rb +84 -0
- data/vendor/deep_merge/MIT-LICENSE +20 -0
- data/vendor/deep_merge/README +94 -0
- data/vendor/deep_merge/Rakefile +28 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/deep_merge/lib/deep_merge.rb +0 -0
- data/vendor/deep_merge/pkg/deep_merge-0.1.0.gem +0 -0
- data/vendor/deep_merge/test/test_deep_merge.rb +553 -0
- data/vendor/diy/History.txt +28 -0
- data/vendor/diy/README.rdoc +233 -0
- data/vendor/diy/Rakefile +33 -0
- data/vendor/diy/TODO.txt +9 -0
- data/vendor/diy/diy.gemspec +131 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/diy/lib/diy.rb +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/diy/lib/diy/factory.rb +0 -0
- data/vendor/diy/sample_code/car.rb +7 -0
- data/vendor/diy/sample_code/chassis.rb +5 -0
- data/vendor/diy/sample_code/diy_example.rb +26 -0
- data/vendor/diy/sample_code/engine.rb +5 -0
- data/vendor/diy/sample_code/objects.yml +10 -0
- data/vendor/diy/test/constructor.rb +119 -0
- data/vendor/diy/test/diy_test.rb +608 -0
- data/vendor/diy/test/factory_test.rb +79 -0
- data/vendor/diy/test/files/broken_construction.yml +7 -0
- data/vendor/diy/test/files/cat/cat.rb +3 -0
- data/vendor/diy/test/files/cat/extra_conflict.yml +5 -0
- data/vendor/diy/test/files/cat/heritage.rb +2 -0
- data/vendor/diy/test/files/cat/needs_input.yml +3 -0
- data/vendor/diy/test/files/cat/the_cat_lineage.rb +1 -0
- data/vendor/diy/test/files/dog/dog_model.rb +3 -0
- data/vendor/diy/test/files/dog/dog_presenter.rb +3 -0
- data/vendor/diy/test/files/dog/dog_view.rb +2 -0
- data/vendor/diy/test/files/dog/file_resolver.rb +2 -0
- data/vendor/diy/test/files/dog/other_thing.rb +2 -0
- data/vendor/diy/test/files/dog/simple.yml +11 -0
- data/vendor/diy/test/files/donkey/foo.rb +8 -0
- data/vendor/diy/test/files/donkey/foo/bar/qux.rb +7 -0
- data/vendor/diy/test/files/factory/beef.rb +5 -0
- data/vendor/diy/test/files/factory/dog.rb +6 -0
- data/vendor/diy/test/files/factory/factory.yml +19 -0
- data/vendor/diy/test/files/factory/farm/llama.rb +7 -0
- data/vendor/diy/test/files/factory/farm/pork.rb +7 -0
- data/vendor/diy/test/files/factory/kitten.rb +13 -0
- data/vendor/diy/test/files/fud/objects.yml +13 -0
- data/vendor/diy/test/files/fud/toy.rb +14 -0
- data/vendor/diy/test/files/functions/attached_things_builder.rb +2 -0
- data/vendor/diy/test/files/functions/invalid_method.yml +5 -0
- data/vendor/diy/test/files/functions/method_extractor.rb +3 -0
- data/vendor/diy/test/files/functions/nonsingleton_objects.yml +6 -0
- data/vendor/diy/test/files/functions/objects.yml +22 -0
- data/vendor/diy/test/files/functions/thing.rb +3 -0
- data/vendor/diy/test/files/functions/thing_builder.rb +25 -0
- data/vendor/diy/test/files/functions/things_builder.rb +3 -0
- data/vendor/diy/test/files/gnu/objects.yml +14 -0
- data/vendor/diy/test/files/gnu/thinger.rb +7 -0
- data/vendor/diy/test/files/goat/base.rb +8 -0
- data/vendor/diy/test/files/goat/can.rb +6 -0
- data/vendor/diy/test/files/goat/goat.rb +6 -0
- data/vendor/diy/test/files/goat/objects.yml +12 -0
- data/vendor/diy/test/files/goat/paper.rb +6 -0
- data/vendor/diy/test/files/goat/plane.rb +7 -0
- data/vendor/diy/test/files/goat/shirt.rb +6 -0
- data/vendor/diy/test/files/goat/wings.rb +8 -0
- data/vendor/diy/test/files/horse/holder_thing.rb +3 -0
- data/vendor/diy/test/files/horse/objects.yml +7 -0
- data/vendor/diy/test/files/namespace/animal/bird.rb +5 -0
- data/vendor/diy/test/files/namespace/animal/cat.rb +5 -0
- data/vendor/diy/test/files/namespace/animal/reptile/hardshell/turtle.rb +8 -0
- data/vendor/diy/test/files/namespace/animal/reptile/lizard.rb +7 -0
- data/vendor/diy/test/files/namespace/bad_module_specified.yml +8 -0
- data/vendor/diy/test/files/namespace/class_name_combine.yml +8 -0
- data/vendor/diy/test/files/namespace/hello.txt +1 -0
- data/vendor/diy/test/files/namespace/no_module_specified.yml +8 -0
- data/vendor/diy/test/files/namespace/objects.yml +21 -0
- data/vendor/diy/test/files/namespace/road.rb +2 -0
- data/vendor/diy/test/files/namespace/sky.rb +2 -0
- data/vendor/diy/test/files/namespace/subcontext.yml +22 -0
- data/vendor/diy/test/files/non_singleton/air.rb +2 -0
- data/vendor/diy/test/files/non_singleton/fat_cat.rb +3 -0
- data/vendor/diy/test/files/non_singleton/objects.yml +19 -0
- data/vendor/diy/test/files/non_singleton/pig.rb +3 -0
- data/vendor/diy/test/files/non_singleton/thread_spinner.rb +3 -0
- data/vendor/diy/test/files/non_singleton/tick.rb +3 -0
- data/vendor/diy/test/files/non_singleton/yard.rb +2 -0
- data/vendor/diy/test/files/yak/core_model.rb +3 -0
- data/vendor/diy/test/files/yak/core_presenter.rb +3 -0
- data/vendor/diy/test/files/yak/core_view.rb +1 -0
- data/vendor/diy/test/files/yak/data_source.rb +1 -0
- data/vendor/diy/test/files/yak/fringe_model.rb +3 -0
- data/vendor/diy/test/files/yak/fringe_presenter.rb +3 -0
- data/vendor/diy/test/files/yak/fringe_view.rb +1 -0
- data/vendor/diy/test/files/yak/giant_squid.rb +3 -0
- data/vendor/diy/test/files/yak/krill.rb +2 -0
- data/vendor/diy/test/files/yak/my_objects.yml +21 -0
- data/vendor/diy/test/files/yak/sub_sub_context_test.yml +27 -0
- data/vendor/diy/test/test_helper.rb +55 -0
- data/vendor/hardmock/CHANGES +78 -0
- data/vendor/hardmock/LICENSE +7 -0
- data/vendor/hardmock/README +70 -0
- data/vendor/hardmock/Rakefile +8 -0
- data/vendor/hardmock/config/environment.rb +12 -0
- data/vendor/hardmock/lib/assert_error.rb +23 -0
- data/vendor/hardmock/lib/extend_test_unit.rb +14 -0
- data/vendor/hardmock/lib/hardmock.rb +86 -0
- data/vendor/hardmock/lib/hardmock/errors.rb +22 -0
- data/vendor/hardmock/lib/hardmock/expectation.rb +229 -0
- data/vendor/hardmock/lib/hardmock/expectation_builder.rb +9 -0
- data/vendor/hardmock/lib/hardmock/expector.rb +26 -0
- data/vendor/hardmock/lib/hardmock/method_cleanout.rb +33 -0
- data/vendor/hardmock/lib/hardmock/mock.rb +180 -0
- data/vendor/hardmock/lib/hardmock/mock_control.rb +53 -0
- data/vendor/hardmock/lib/hardmock/stubbing.rb +210 -0
- data/vendor/hardmock/lib/hardmock/trapper.rb +31 -0
- data/vendor/hardmock/lib/hardmock/utils.rb +9 -0
- data/vendor/hardmock/lib/test_unit_before_after.rb +169 -0
- data/vendor/hardmock/rake_tasks/rdoc.rake +19 -0
- data/vendor/hardmock/rake_tasks/rdoc_options.rb +4 -0
- data/vendor/hardmock/rake_tasks/test.rake +22 -0
- data/vendor/hardmock/test/functional/assert_error_test.rb +52 -0
- data/vendor/hardmock/test/functional/auto_verify_test.rb +178 -0
- data/vendor/hardmock/test/functional/direct_mock_usage_test.rb +396 -0
- data/vendor/hardmock/test/functional/hardmock_test.rb +434 -0
- data/vendor/hardmock/test/functional/stubbing_test.rb +479 -0
- data/vendor/hardmock/test/test_helper.rb +43 -0
- data/vendor/hardmock/test/unit/expectation_builder_test.rb +19 -0
- data/vendor/hardmock/test/unit/expectation_test.rb +372 -0
- data/vendor/hardmock/test/unit/expector_test.rb +57 -0
- data/vendor/hardmock/test/unit/method_cleanout_test.rb +36 -0
- data/vendor/hardmock/test/unit/mock_control_test.rb +175 -0
- data/vendor/hardmock/test/unit/mock_test.rb +279 -0
- data/vendor/hardmock/test/unit/test_unit_before_after_test.rb +452 -0
- data/vendor/hardmock/test/unit/trapper_test.rb +62 -0
- data/vendor/hardmock/test/unit/verify_error_test.rb +40 -0
- data/vendor/unity/auto/colour_prompt.rb +94 -0
- data/vendor/unity/auto/colour_reporter.rb +39 -0
- data/vendor/unity/auto/generate_module.rb +202 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/unity/auto/generate_test_runner.rb +0 -0
- data/vendor/unity/auto/test_file_filter.rb +23 -0
- data/vendor/unity/auto/unity_test_summary.rb +139 -0
- data/vendor/unity/release/build.info +2 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/unity/release/version.info +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/unity/src/unity.c +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/unity/src/unity.h +0 -0
- data/{new_project_template/vendor/ceedling/vendor → vendor}/unity/src/unity_internals.h +94 -6
- metadata +443 -237
- data/.vim +0 -1
- data/.yardopts +0 -1
- data/LICENSE +0 -19
- data/Rakefile +0 -118
- data/ceedling-gem.sublime-project +0 -8
- data/examples/blinky/.DS_Store +0 -0
- data/examples/temp_sensor/src/AT91SAM7X256.h +0 -2556
- data/examples/temp_sensor/src/UsartGetChar.c +0 -6
- data/examples/temp_sensor/src/UsartGetChar.h +0 -8
- data/examples/temp_sensor/test/test_AdcHardwareConfigurator.c +0 -43
- data/examples/temp_sensor/test/test_AdcTemperatureSensor.c +0 -47
- data/examples/temp_sensor/test/test_TimerConfigurator.c +0 -112
- data/examples/temp_sensor/test/test_TimerInterruptConfigurator.c +0 -78
- data/examples/temp_sensor/test/test_TimerInterruptHandler.c +0 -66
- data/examples/temp_sensor/test/test_UsartConfigurator.c +0 -77
- data/examples/temp_sensor/test/test_UsartGetChar.c +0 -17
- data/examples/temp_sensor/test/test_UsartPutChar.c +0 -43
- data/examples/temp_sensor/test/test_UsartTransmitBufferStatus.c +0 -22
- data/new_project_template/build/.gitkeep +0 -0
- data/new_project_template/src/.gitkeep +0 -0
- data/new_project_template/test/.gitkeep +0 -0
- data/new_project_template/test/support/.gitkeep +0 -0
- data/new_project_template/vendor/ceedling/docs/CExceptionSummary.pdf +0 -0
- data/new_project_template/vendor/ceedling/docs/CMock Summary.pdf +0 -0
- data/new_project_template/vendor/ceedling/docs/Ceedling Packet.pdf +0 -0
- data/new_project_template/vendor/ceedling/docs/Unity Summary.pdf +0 -0
- data/new_project_template/vendor/ceedling/lib/preprocessinator_extractor.rb +0 -36
- data/new_project_template/vendor/ceedling/release/build.info +0 -1
- data/new_project_template/vendor/ceedling/vendor/c_exception/release/build.info +0 -1
- data/new_project_template/vendor/ceedling/vendor/cmock/release/build.info +0 -1
- data/new_project_template/vendor/ceedling/vendor/unity/release/build.info +0 -1
@@ -0,0 +1,12 @@
|
|
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
|
@@ -0,0 +1,23 @@
|
|
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
|
@@ -0,0 +1,14 @@
|
|
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
|
@@ -0,0 +1,86 @@
|
|
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'
|
@@ -0,0 +1,22 @@
|
|
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
|
@@ -0,0 +1,229 @@
|
|
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
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'hardmock/method_cleanout'
|
2
|
+
require 'hardmock/errors'
|
3
|
+
|
4
|
+
module Hardmock
|
5
|
+
class Expector #:nodoc:
|
6
|
+
include MethodCleanout
|
7
|
+
|
8
|
+
def initialize(mock,mock_control,expectation_builder)
|
9
|
+
@mock = mock
|
10
|
+
@mock_control = mock_control
|
11
|
+
@expectation_builder = expectation_builder
|
12
|
+
end
|
13
|
+
|
14
|
+
def method_missing(mname, *args, &block)
|
15
|
+
expectation = @expectation_builder.build_expectation(
|
16
|
+
:mock => @mock,
|
17
|
+
:method => mname,
|
18
|
+
:arguments => args,
|
19
|
+
:block => block)
|
20
|
+
|
21
|
+
@mock_control.add_expectation expectation
|
22
|
+
expectation
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
module Hardmock #:nodoc:
|
3
|
+
module MethodCleanout #:nodoc:
|
4
|
+
SACRED_METHODS = %w{
|
5
|
+
__id__
|
6
|
+
__send__
|
7
|
+
equal?
|
8
|
+
object_id
|
9
|
+
send
|
10
|
+
nil?
|
11
|
+
class
|
12
|
+
kind_of?
|
13
|
+
respond_to?
|
14
|
+
inspect
|
15
|
+
method
|
16
|
+
to_s
|
17
|
+
instance_variables
|
18
|
+
instance_eval
|
19
|
+
==
|
20
|
+
hm_metaclass
|
21
|
+
hm_meta_eval
|
22
|
+
hm_meta_def
|
23
|
+
}
|
24
|
+
|
25
|
+
def self.included(base) #:nodoc:
|
26
|
+
base.class_eval do
|
27
|
+
instance_methods.each do |m|
|
28
|
+
undef_method m unless SACRED_METHODS.include?(m.to_s)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|