thoughtbot-clearance 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +99 -0
- data/TODO.textile +21 -0
- data/generators/clearance/templates/app/views/sessions/new.html.erb +17 -0
- data/generators/clearance/templates/app/views/user_mailer/change_password.html.erb +6 -0
- data/generators/clearance/templates/app/views/user_mailer/confirmation.html.erb +1 -0
- data/generators/clearance/templates/app/views/users/_form.html.erb +7 -0
- data/generators/clearance/templates/app/views/users/edit.html.erb +4 -0
- data/generators/clearance/templates/app/views/users/new.html.erb +4 -0
- data/generators/clearance/templates/test/functional/confirmations_controller_test.rb +5 -0
- data/generators/clearance/templates/test/functional/passwords_controller_test.rb +5 -0
- data/generators/clearance/templates/test/functional/sessions_controller_test.rb +5 -0
- data/lib/clearance/test/functionals/users_controller_test.rb +60 -0
- data/lib/clearance/version.rb +7 -0
- data/lib/clearance.rb +1 -0
- data/test/rails_root/Capfile +3 -0
- data/test/rails_root/Rakefile +10 -0
- data/test/rails_root/app/controllers/application.rb +5 -0
- data/test/rails_root/app/controllers/confirmations_controller.rb +3 -0
- data/test/rails_root/app/controllers/passwords_controller.rb +3 -0
- data/test/rails_root/app/controllers/sessions_controller.rb +3 -0
- data/test/rails_root/app/controllers/users_controller.rb +3 -0
- data/test/rails_root/app/helpers/application_helper.rb +5 -0
- data/test/rails_root/app/helpers/confirmations_helper.rb +2 -0
- data/test/rails_root/app/helpers/passwords_helper.rb +2 -0
- data/test/rails_root/app/models/user.rb +3 -0
- data/test/rails_root/app/models/user_mailer.rb +7 -0
- data/test/rails_root/app/views/confirmations/new.html.erb +4 -0
- data/test/rails_root/app/views/layouts/_flashes.erb +5 -0
- data/test/rails_root/app/views/layouts/application.html.erb +14 -0
- data/test/rails_root/app/views/passwords/edit.html.erb +28 -0
- data/test/rails_root/app/views/passwords/new.html.erb +13 -0
- data/test/rails_root/app/views/sessions/new.html.erb +17 -0
- data/test/rails_root/app/views/user_mailer/change_password.html.erb +6 -0
- data/test/rails_root/app/views/user_mailer/confirmation.html.erb +1 -0
- data/test/rails_root/app/views/users/_form.html.erb +7 -0
- data/test/rails_root/app/views/users/edit.html.erb +4 -0
- data/test/rails_root/app/views/users/new.html.erb +4 -0
- data/test/rails_root/config/boot.rb +109 -0
- data/test/rails_root/config/database.yml +13 -0
- data/test/rails_root/config/environment.rb +17 -0
- data/test/rails_root/config/environments/development.rb +20 -0
- data/test/rails_root/config/environments/test.rb +24 -0
- data/test/rails_root/config/initializers/clearance.rb +8 -0
- data/test/rails_root/config/initializers/inflections.rb +10 -0
- data/test/rails_root/config/initializers/mime_types.rb +5 -0
- data/test/rails_root/config/initializers/requires.rb +13 -0
- data/test/rails_root/config/initializers/time_formats.rb +4 -0
- data/test/rails_root/config/routes.rb +19 -0
- data/test/rails_root/db/migrate/001_create_users.rb +18 -0
- data/test/rails_root/doc/README_FOR_APP +2 -0
- data/test/rails_root/doc/README_FOR_TEMPLATE +15 -0
- data/test/rails_root/lib/tasks/bootstrap.rake +16 -0
- data/test/rails_root/lib/tasks/capistrano.rake +96 -0
- data/test/rails_root/lib/tasks/git_tasks.rake +129 -0
- data/test/rails_root/public/404.html +30 -0
- data/test/rails_root/public/422.html +30 -0
- data/test/rails_root/public/500.html +30 -0
- data/test/rails_root/public/dispatch.rb +10 -0
- data/test/rails_root/public/favicon.ico +0 -0
- data/test/rails_root/public/images/rails.png +0 -0
- data/test/rails_root/public/javascripts/application.js +2 -0
- data/test/rails_root/public/javascripts/builder.js +136 -0
- data/test/rails_root/public/javascripts/controls.js +963 -0
- data/test/rails_root/public/javascripts/dragdrop.js +972 -0
- data/test/rails_root/public/javascripts/effects.js +1120 -0
- data/test/rails_root/public/javascripts/prototype.js +4225 -0
- data/test/rails_root/public/javascripts/scriptaculous.js +58 -0
- data/test/rails_root/public/javascripts/slider.js +277 -0
- data/test/rails_root/public/javascripts/sound.js +60 -0
- data/test/rails_root/public/robots.txt +1 -0
- data/test/rails_root/script/about +3 -0
- data/test/rails_root/script/breakpointer +3 -0
- data/test/rails_root/script/console +3 -0
- data/test/rails_root/script/create_project.rb +52 -0
- data/test/rails_root/script/dbconsole +3 -0
- data/test/rails_root/script/destroy +3 -0
- data/test/rails_root/script/generate +3 -0
- data/test/rails_root/script/performance/benchmarker +3 -0
- data/test/rails_root/script/performance/profiler +3 -0
- data/test/rails_root/script/performance/request +3 -0
- data/test/rails_root/script/plugin +3 -0
- data/test/rails_root/script/process/inspector +3 -0
- data/test/rails_root/script/process/reaper +3 -0
- data/test/rails_root/script/process/spawner +3 -0
- data/test/rails_root/script/runner +3 -0
- data/test/rails_root/script/server +3 -0
- data/test/rails_root/test/factories.rb +9 -0
- data/test/rails_root/test/functional/confirmations_controller_test.rb +5 -0
- data/test/rails_root/test/functional/passwords_controller_test.rb +5 -0
- data/test/rails_root/test/functional/sessions_controller_test.rb +5 -0
- data/test/rails_root/test/functional/users_controller_test.rb +5 -0
- data/test/rails_root/test/test_helper.rb +27 -0
- data/test/rails_root/test/unit/user_mailer_test.rb +6 -0
- data/test/rails_root/test/unit/user_test.rb +5 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/COPYING +3 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/MIT-LICENSE +7 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/README +35 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/RELEASE +246 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/Rakefile +188 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/examples/misc.rb +44 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/examples/mocha.rb +26 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/examples/stubba.rb +65 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/any_instance_method.rb +54 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/backtrace_filter.rb +17 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/cardinality.rb +95 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/central.rb +27 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/change_state_side_effect.rb +19 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/class_method.rb +86 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/configuration.rb +60 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/deprecation.rb +22 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/exception_raiser.rb +17 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/expectation.rb +445 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/expectation_error.rb +15 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/expectation_list.rb +50 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/in_state_ordering_constraint.rb +19 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/inspect.rb +39 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/instance_method.rb +16 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/is_a.rb +9 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/logger.rb +15 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/metaclass.rb +7 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/method_matcher.rb +21 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/mock.rb +196 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/mockery.rb +181 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/module_method.rb +16 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/multiple_yields.rb +20 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/names.rb +53 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/no_yields.rb +11 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/object.rb +134 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/all_of.rb +42 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/any_of.rb +47 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/any_parameters.rb +40 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/anything.rb +33 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/base.rb +15 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/equals.rb +42 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/has_entries.rb +45 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/has_entry.rb +56 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/has_key.rb +42 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/has_value.rb +42 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/includes.rb +40 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/instance_of.rb +42 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/is_a.rb +42 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/kind_of.rb +42 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/not.rb +42 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/object.rb +9 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/optionally.rb +55 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/regexp_matches.rb +43 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/responds_with.rb +43 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers/yaml_equivalent.rb +43 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameter_matchers.rb +26 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/parameters_matcher.rb +37 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/pretty_parameters.rb +28 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/return_values.rb +31 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/sequence.rb +42 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/single_return_value.rb +17 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/single_yield.rb +18 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/standalone.rb +166 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/state_machine.rb +91 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/stubbing_error.rb +16 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/test_case_adapter.rb +103 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/unexpected_invocation.rb +18 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha/yield_parameters.rb +31 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha.rb +20 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/mocha_standalone.rb +2 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/lib/stubba.rb +4 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/acceptance_test_helper.rb +38 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/bug_18914_test.rb +43 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/bug_21465_test.rb +34 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/bug_21563_test.rb +25 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/expected_invocation_count_test.rb +196 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/failure_messages_test.rb +64 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/mocha_example_test.rb +98 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/mocha_test_result_test.rb +84 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/mock_test.rb +100 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/mock_with_initializer_block_test.rb +51 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/mocked_methods_dispatch_test.rb +78 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/optional_parameters_test.rb +70 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/parameter_matcher_test.rb +179 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/partial_mocks_test.rb +47 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/return_value_test.rb +52 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/sequence_test.rb +186 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/standalone_test.rb +139 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/states_test.rb +70 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stub_any_instance_method_test.rb +195 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stub_class_method_test.rb +203 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stub_everything_test.rb +56 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stub_instance_method_test.rb +165 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stub_module_method_test.rb +163 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stub_test.rb +52 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stubba_example_test.rb +102 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stubba_test.rb +15 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stubba_test_result_test.rb +66 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stubbing_error_backtrace_test.rb +64 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stubbing_method_unnecessarily_test.rb +65 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +130 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stubbing_non_existent_class_method_test.rb +155 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stubbing_non_existent_instance_method_test.rb +145 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stubbing_non_public_any_instance_method_test.rb +130 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stubbing_non_public_class_method_test.rb +161 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stubbing_non_public_instance_method_test.rb +141 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/acceptance/stubbing_on_non_mock_object_test.rb +64 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/active_record_test_case.rb +36 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/deprecation_disabler.rb +15 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/execution_point.rb +36 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/method_definer.rb +18 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/simple_counter.rb +13 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/test_helper.rb +11 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/test_runner.rb +33 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/any_instance_method_test.rb +126 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/array_inspect_test.rb +16 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/backtrace_filter_test.rb +19 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/cardinality_test.rb +56 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/central_test.rb +65 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/change_state_side_effect_test.rb +41 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/class_method_test.rb +237 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/date_time_inspect_test.rb +21 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/exception_raiser_test.rb +42 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/expectation_list_test.rb +57 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/expectation_test.rb +459 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/hash_inspect_test.rb +16 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/in_state_ordering_constraint_test.rb +43 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/metaclass_test.rb +22 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/method_matcher_test.rb +23 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/mock_test.rb +290 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/mockery_test.rb +149 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/multiple_yields_test.rb +18 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/no_yields_test.rb +18 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/object_inspect_test.rb +37 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/object_test.rb +82 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/all_of_test.rb +26 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/any_of_test.rb +26 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/anything_test.rb +21 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/equals_test.rb +25 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/has_entries_test.rb +51 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/has_entry_test.rb +62 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/has_key_test.rb +36 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/has_value_test.rb +37 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/includes_test.rb +25 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/instance_of_test.rb +25 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/is_a_test.rb +25 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/kind_of_test.rb +25 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/not_test.rb +26 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/regexp_matches_test.rb +25 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/responds_with_test.rb +25 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/stub_matcher.rb +27 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameter_matchers/yaml_equivalent_test.rb +25 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/parameters_matcher_test.rb +121 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/return_values_test.rb +63 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/sequence_test.rb +104 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/single_return_value_test.rb +14 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/single_yield_test.rb +18 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/state_machine_test.rb +98 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/string_inspect_test.rb +11 -0
- data/test/rails_root/vendor/gems/mocha-0.9.1/test/unit/yield_parameters_test.rb +93 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/CONTRIBUTION_GUIDELINES.rdoc +12 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/MIT-LICENSE +22 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/README.rdoc +132 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/Rakefile +72 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/bin/convert_to_should_syntax +42 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/action_mailer/assertions.rb +39 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/action_mailer.rb +10 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/active_record/assertions.rb +85 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/active_record/macros.rb +715 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/active_record.rb +12 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/assertions.rb +45 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/context.rb +306 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/controller/formats/html.rb +201 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/controller/formats/xml.rb +170 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/controller/helpers.rb +64 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/controller/macros.rb +316 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/controller/resource_options.rb +236 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/controller.rb +30 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/helpers.rb +10 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/macros.rb +74 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/private_helpers.rb +22 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/proc_extensions.rb +14 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/rails.rb +19 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/tasks/list_tests.rake +24 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/tasks/yaml_to_shoulda.rake +28 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/tasks.rb +3 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda.rb +17 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/rails/init.rb +1 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/README +36 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/fail_macros.rb +34 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/fixtures/addresses.yml +3 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/fixtures/friendships.yml +0 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/fixtures/posts.yml +5 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/fixtures/products.yml +0 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/fixtures/taggings.yml +0 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/fixtures/tags.yml +9 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/fixtures/users.yml +6 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/functional/posts_controller_test.rb +104 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/functional/users_controller_test.rb +38 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/other/context_test.rb +145 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/other/convert_to_should_syntax_test.rb +63 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/other/helpers_test.rb +183 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/other/private_helpers_test.rb +34 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/other/should_test.rb +266 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/controllers/application.rb +25 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/controllers/posts_controller.rb +85 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/controllers/users_controller.rb +84 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/helpers/application_helper.rb +3 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/helpers/posts_helper.rb +2 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/helpers/users_helper.rb +2 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/models/address.rb +7 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/models/dog.rb +5 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/models/flea.rb +3 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/models/friendship.rb +4 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/models/post.rb +12 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/models/product.rb +12 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/models/tag.rb +8 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/models/tagging.rb +4 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/models/user.rb +28 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/views/layouts/posts.rhtml +17 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/views/layouts/users.rhtml +17 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/views/layouts/wide.html.erb +1 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/views/posts/edit.rhtml +27 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/views/posts/index.rhtml +25 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/views/posts/new.rhtml +26 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/views/posts/show.rhtml +18 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/views/users/edit.rhtml +22 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/views/users/index.rhtml +22 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/views/users/new.rhtml +21 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/app/views/users/show.rhtml +13 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/config/boot.rb +109 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/config/database.yml +4 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/config/environment.rb +14 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/config/environments/sqlite3.rb +0 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/config/initializers/new_rails_defaults.rb +15 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/config/initializers/shoulda.rb +8 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/config/routes.rb +6 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/db/migrate/001_create_users.rb +18 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/db/migrate/002_create_posts.rb +13 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/db/migrate/003_create_taggings.rb +12 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/db/migrate/004_create_tags.rb +11 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/db/migrate/005_create_dogs.rb +12 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/db/migrate/006_create_addresses.rb +14 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/db/migrate/007_create_fleas.rb +11 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/db/migrate/008_create_dogs_fleas.rb +12 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/db/migrate/009_create_products.rb +17 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/db/migrate/010_create_friendships.rb +14 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/db/schema.rb +0 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/log/sqlite3.log +1 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/public/404.html +30 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/public/422.html +30 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/public/500.html +30 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/script/console +3 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/rails_root/script/generate +3 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/test_helper.rb +33 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/unit/address_test.rb +10 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/unit/dog_test.rb +7 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/unit/flea_test.rb +6 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/unit/friendship_test.rb +6 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/unit/post_test.rb +15 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/unit/product_test.rb +27 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/unit/tag_test.rb +14 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/unit/tagging_test.rb +6 -0
- data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/test/unit/user_test.rb +52 -0
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/MIT-LICENSE +20 -0
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/README +34 -0
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/init.rb +9 -0
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/USAGE +18 -0
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/factory_generator.rb +17 -0
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/factory.rb +5 -0
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/fixtures.yml +19 -0
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/migration.rb +16 -0
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/model.rb +2 -0
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/unit_test.rb +7 -0
- metadata +486 -14
- data/clearance.gemspec +0 -50
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'mocha/parameter_matchers/base'
|
2
|
+
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
module ParameterMatchers
|
6
|
+
|
7
|
+
# :call-seq: any_parameters() -> parameter_matcher
|
8
|
+
#
|
9
|
+
# Matches any parameters.
|
10
|
+
# object = mock()
|
11
|
+
# object.expects(:method_1).with(any_parameters)
|
12
|
+
# object.method_1(1, 2, 3, 4)
|
13
|
+
# # no error raised
|
14
|
+
#
|
15
|
+
# object = mock()
|
16
|
+
# object.expects(:method_1).with(any_parameters)
|
17
|
+
# object.method_1(5, 6, 7, 8, 9, 0)
|
18
|
+
# # no error raised
|
19
|
+
def any_parameters
|
20
|
+
AnyParameters.new
|
21
|
+
end
|
22
|
+
|
23
|
+
class AnyParameters < Base # :nodoc:
|
24
|
+
|
25
|
+
def matches?(available_parameters)
|
26
|
+
while available_parameters.length > 0 do
|
27
|
+
available_parameters.shift
|
28
|
+
end
|
29
|
+
return true
|
30
|
+
end
|
31
|
+
|
32
|
+
def mocha_inspect
|
33
|
+
"any_parameters"
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'mocha/parameter_matchers/base'
|
2
|
+
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
module ParameterMatchers
|
6
|
+
|
7
|
+
# :call-seq: anything() -> parameter_matcher
|
8
|
+
#
|
9
|
+
# Matches any object.
|
10
|
+
# object = mock()
|
11
|
+
# object.expects(:method_1).with(anything)
|
12
|
+
# object.method_1('foo')
|
13
|
+
# # no error raised
|
14
|
+
def anything
|
15
|
+
Anything.new
|
16
|
+
end
|
17
|
+
|
18
|
+
class Anything < Base # :nodoc:
|
19
|
+
|
20
|
+
def matches?(available_parameters)
|
21
|
+
available_parameters.shift
|
22
|
+
return true
|
23
|
+
end
|
24
|
+
|
25
|
+
def mocha_inspect
|
26
|
+
"anything"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'mocha/parameter_matchers/base'
|
2
|
+
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
module ParameterMatchers
|
6
|
+
|
7
|
+
# :call-seq: equals(value) -> parameter_matcher
|
8
|
+
#
|
9
|
+
# Matches +Object+ equalling +value+.
|
10
|
+
# object = mock()
|
11
|
+
# object.expects(:method_1).with(equals(2))
|
12
|
+
# object.method_1(2)
|
13
|
+
# # no error raised
|
14
|
+
#
|
15
|
+
# object = mock()
|
16
|
+
# object.expects(:method_1).with(equals(2))
|
17
|
+
# object.method_1(3)
|
18
|
+
# # error raised, because method_1 was not called with Object equalling 3
|
19
|
+
def equals(value)
|
20
|
+
Equals.new(value)
|
21
|
+
end
|
22
|
+
|
23
|
+
class Equals < Base # :nodoc:
|
24
|
+
|
25
|
+
def initialize(value)
|
26
|
+
@value = value
|
27
|
+
end
|
28
|
+
|
29
|
+
def matches?(available_parameters)
|
30
|
+
parameter = available_parameters.shift
|
31
|
+
parameter == @value
|
32
|
+
end
|
33
|
+
|
34
|
+
def mocha_inspect
|
35
|
+
@value.mocha_inspect
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'mocha/parameter_matchers/base'
|
2
|
+
require 'mocha/parameter_matchers/all_of'
|
3
|
+
require 'mocha/parameter_matchers/has_entry'
|
4
|
+
|
5
|
+
module Mocha
|
6
|
+
|
7
|
+
module ParameterMatchers
|
8
|
+
|
9
|
+
# :call-seq: has_entries(entries) -> parameter_matcher
|
10
|
+
#
|
11
|
+
# Matches +Hash+ containing all +entries+.
|
12
|
+
# object = mock()
|
13
|
+
# object.expects(:method_1).with(has_entries('key_1' => 1, 'key_2' => 2))
|
14
|
+
# object.method_1('key_1' => 1, 'key_2' => 2, 'key_3' => 3)
|
15
|
+
# # no error raised
|
16
|
+
#
|
17
|
+
# object = mock()
|
18
|
+
# object.expects(:method_1).with(has_entries('key_1' => 1, 'key_2' => 2))
|
19
|
+
# object.method_1('key_1' => 1, 'key_2' => 99)
|
20
|
+
# # error raised, because method_1 was not called with Hash containing entries: 'key_1' => 1, 'key_2' => 2
|
21
|
+
def has_entries(entries)
|
22
|
+
HasEntries.new(entries)
|
23
|
+
end
|
24
|
+
|
25
|
+
class HasEntries < Base # :nodoc:
|
26
|
+
|
27
|
+
def initialize(entries)
|
28
|
+
@entries = entries
|
29
|
+
end
|
30
|
+
|
31
|
+
def matches?(available_parameters)
|
32
|
+
parameter = available_parameters.shift
|
33
|
+
has_entry_matchers = @entries.map { |key, value| HasEntry.new(key, value) }
|
34
|
+
AllOf.new(*has_entry_matchers).matches?([parameter])
|
35
|
+
end
|
36
|
+
|
37
|
+
def mocha_inspect
|
38
|
+
"has_entries(#{@entries.mocha_inspect})"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'mocha/parameter_matchers/base'
|
2
|
+
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
module ParameterMatchers
|
6
|
+
|
7
|
+
# :call-seq: has_entry(key, value) -> parameter_matcher
|
8
|
+
# has_entry(key => value) -> parameter_matcher
|
9
|
+
#
|
10
|
+
# Matches +Hash+ containing entry with +key+ and +value+.
|
11
|
+
# object = mock()
|
12
|
+
# object.expects(:method_1).with(has_entry('key_1', 1))
|
13
|
+
# object.method_1('key_1' => 1, 'key_2' => 2)
|
14
|
+
# # no error raised
|
15
|
+
#
|
16
|
+
# object = mock()
|
17
|
+
# object.expects(:method_1).with(has_entry('key_1' => 1))
|
18
|
+
# object.method_1('key_1' => 1, 'key_2' => 2)
|
19
|
+
# # no error raised
|
20
|
+
#
|
21
|
+
# object = mock()
|
22
|
+
# object.expects(:method_1).with(has_entry('key_1', 1))
|
23
|
+
# object.method_1('key_1' => 2, 'key_2' => 1)
|
24
|
+
# # error raised, because method_1 was not called with Hash containing entry: 'key_1' => 1
|
25
|
+
#
|
26
|
+
# object = mock()
|
27
|
+
# object.expects(:method_1).with(has_entry('key_1' => 1))
|
28
|
+
# object.method_1('key_1' => 2, 'key_2' => 1)
|
29
|
+
# # error raised, because method_1 was not called with Hash containing entry: 'key_1' => 1
|
30
|
+
def has_entry(*options)
|
31
|
+
key, value = options.shift, options.shift
|
32
|
+
key, value = key.to_a[0][0..1] if key.is_a?(Hash)
|
33
|
+
HasEntry.new(key, value)
|
34
|
+
end
|
35
|
+
|
36
|
+
class HasEntry < Base # :nodoc:
|
37
|
+
|
38
|
+
def initialize(key, value)
|
39
|
+
@key, @value = key, value
|
40
|
+
end
|
41
|
+
|
42
|
+
def matches?(available_parameters)
|
43
|
+
parameter = available_parameters.shift
|
44
|
+
matching_keys = parameter.keys.select { |key| @key.to_matcher.matches?([key]) }
|
45
|
+
matching_keys.any? { |key| @value.to_matcher.matches?([parameter[key]]) }
|
46
|
+
end
|
47
|
+
|
48
|
+
def mocha_inspect
|
49
|
+
"has_entry(#{@key.mocha_inspect} => #{@value.mocha_inspect})"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'mocha/parameter_matchers/base'
|
2
|
+
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
module ParameterMatchers
|
6
|
+
|
7
|
+
# :call-seq: has_key(key) -> parameter_matcher
|
8
|
+
#
|
9
|
+
# Matches +Hash+ containing +key+.
|
10
|
+
# object = mock()
|
11
|
+
# object.expects(:method_1).with(has_key('key_1'))
|
12
|
+
# object.method_1('key_1' => 1, 'key_2' => 2)
|
13
|
+
# # no error raised
|
14
|
+
#
|
15
|
+
# object = mock()
|
16
|
+
# object.expects(:method_1).with(has_key('key_1'))
|
17
|
+
# object.method_1('key_2' => 2)
|
18
|
+
# # error raised, because method_1 was not called with Hash containing key: 'key_1'
|
19
|
+
def has_key(key)
|
20
|
+
HasKey.new(key)
|
21
|
+
end
|
22
|
+
|
23
|
+
class HasKey < Base # :nodoc:
|
24
|
+
|
25
|
+
def initialize(key)
|
26
|
+
@key = key
|
27
|
+
end
|
28
|
+
|
29
|
+
def matches?(available_parameters)
|
30
|
+
parameter = available_parameters.shift
|
31
|
+
parameter.keys.any? { |key| @key.to_matcher.matches?([key]) }
|
32
|
+
end
|
33
|
+
|
34
|
+
def mocha_inspect
|
35
|
+
"has_key(#{@key.mocha_inspect})"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'mocha/parameter_matchers/base'
|
2
|
+
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
module ParameterMatchers
|
6
|
+
|
7
|
+
# :call-seq: has_value(value) -> parameter_matcher
|
8
|
+
#
|
9
|
+
# Matches +Hash+ containing +value+.
|
10
|
+
# object = mock()
|
11
|
+
# object.expects(:method_1).with(has_value(1))
|
12
|
+
# object.method_1('key_1' => 1, 'key_2' => 2)
|
13
|
+
# # no error raised
|
14
|
+
#
|
15
|
+
# object = mock()
|
16
|
+
# object.expects(:method_1).with(has_value(1))
|
17
|
+
# object.method_1('key_2' => 2)
|
18
|
+
# # error raised, because method_1 was not called with Hash containing value: 1
|
19
|
+
def has_value(value)
|
20
|
+
HasValue.new(value)
|
21
|
+
end
|
22
|
+
|
23
|
+
class HasValue < Base # :nodoc:
|
24
|
+
|
25
|
+
def initialize(value)
|
26
|
+
@value = value
|
27
|
+
end
|
28
|
+
|
29
|
+
def matches?(available_parameters)
|
30
|
+
parameter = available_parameters.shift
|
31
|
+
parameter.values.any? { |value| @value.to_matcher.matches?([value]) }
|
32
|
+
end
|
33
|
+
|
34
|
+
def mocha_inspect
|
35
|
+
"has_value(#{@value.mocha_inspect})"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'mocha/parameter_matchers/base'
|
2
|
+
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
module ParameterMatchers
|
6
|
+
|
7
|
+
# :call-seq: includes(item) -> parameter_matcher
|
8
|
+
#
|
9
|
+
# Matches any object that responds true to include?(item)
|
10
|
+
# object = mock()
|
11
|
+
# object.expects(:method_1).with(includes('foo'))
|
12
|
+
# object.method_1(['foo', 'bar'])
|
13
|
+
# # no error raised
|
14
|
+
#
|
15
|
+
# object.method_1(['baz'])
|
16
|
+
# # error raised, because ['baz'] does not include 'foo'.
|
17
|
+
def includes(item)
|
18
|
+
Includes.new(item)
|
19
|
+
end
|
20
|
+
|
21
|
+
class Includes < Base # :nodoc:
|
22
|
+
|
23
|
+
def initialize(item)
|
24
|
+
@item = item
|
25
|
+
end
|
26
|
+
|
27
|
+
def matches?(available_parameters)
|
28
|
+
parameter = available_parameters.shift
|
29
|
+
return parameter.include?(@item)
|
30
|
+
end
|
31
|
+
|
32
|
+
def mocha_inspect
|
33
|
+
"includes(#{@item.mocha_inspect})"
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'mocha/parameter_matchers/base'
|
2
|
+
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
module ParameterMatchers
|
6
|
+
|
7
|
+
# :call-seq: instance_of(klass) -> parameter_matcher
|
8
|
+
#
|
9
|
+
# Matches any object that is an instance of +klass+
|
10
|
+
# object = mock()
|
11
|
+
# object.expects(:method_1).with(instance_of(String))
|
12
|
+
# object.method_1('string')
|
13
|
+
# # no error raised
|
14
|
+
#
|
15
|
+
# object = mock()
|
16
|
+
# object.expects(:method_1).with(instance_of(String))
|
17
|
+
# object.method_1(99)
|
18
|
+
# # error raised, because method_1 was not called with an instance of String
|
19
|
+
def instance_of(klass)
|
20
|
+
InstanceOf.new(klass)
|
21
|
+
end
|
22
|
+
|
23
|
+
class InstanceOf < Base # :nodoc:
|
24
|
+
|
25
|
+
def initialize(klass)
|
26
|
+
@klass = klass
|
27
|
+
end
|
28
|
+
|
29
|
+
def matches?(available_parameters)
|
30
|
+
parameter = available_parameters.shift
|
31
|
+
parameter.instance_of?(@klass)
|
32
|
+
end
|
33
|
+
|
34
|
+
def mocha_inspect
|
35
|
+
"instance_of(#{@klass.mocha_inspect})"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'mocha/parameter_matchers/base'
|
2
|
+
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
module ParameterMatchers
|
6
|
+
|
7
|
+
# :call-seq: is_a(klass) -> parameter_matcher
|
8
|
+
#
|
9
|
+
# Matches any object that is a +klass+
|
10
|
+
# object = mock()
|
11
|
+
# object.expects(:method_1).with(is_a(Integer))
|
12
|
+
# object.method_1(99)
|
13
|
+
# # no error raised
|
14
|
+
#
|
15
|
+
# object = mock()
|
16
|
+
# object.expects(:method_1).with(is_a(Integer))
|
17
|
+
# object.method_1('string')
|
18
|
+
# # error raised, because method_1 was not called with an Integer
|
19
|
+
def is_a(klass)
|
20
|
+
IsA.new(klass)
|
21
|
+
end
|
22
|
+
|
23
|
+
class IsA < Base # :nodoc:
|
24
|
+
|
25
|
+
def initialize(klass)
|
26
|
+
@klass = klass
|
27
|
+
end
|
28
|
+
|
29
|
+
def matches?(available_parameters)
|
30
|
+
parameter = available_parameters.shift
|
31
|
+
parameter.is_a?(@klass)
|
32
|
+
end
|
33
|
+
|
34
|
+
def mocha_inspect
|
35
|
+
"is_a(#{@klass.mocha_inspect})"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'mocha/parameter_matchers/base'
|
2
|
+
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
module ParameterMatchers
|
6
|
+
|
7
|
+
# :call-seq: kind_of(klass) -> parameter_matcher
|
8
|
+
#
|
9
|
+
# Matches any object that is a kind of +klass+
|
10
|
+
# object = mock()
|
11
|
+
# object.expects(:method_1).with(kind_of(Integer))
|
12
|
+
# object.method_1(99)
|
13
|
+
# # no error raised
|
14
|
+
#
|
15
|
+
# object = mock()
|
16
|
+
# object.expects(:method_1).with(kind_of(Integer))
|
17
|
+
# object.method_1('string')
|
18
|
+
# # error raised, because method_1 was not called with a kind of Integer
|
19
|
+
def kind_of(klass)
|
20
|
+
KindOf.new(klass)
|
21
|
+
end
|
22
|
+
|
23
|
+
class KindOf < Base # :nodoc:
|
24
|
+
|
25
|
+
def initialize(klass)
|
26
|
+
@klass = klass
|
27
|
+
end
|
28
|
+
|
29
|
+
def matches?(available_parameters)
|
30
|
+
parameter = available_parameters.shift
|
31
|
+
parameter.kind_of?(@klass)
|
32
|
+
end
|
33
|
+
|
34
|
+
def mocha_inspect
|
35
|
+
"kind_of(#{@klass.mocha_inspect})"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'mocha/parameter_matchers/base'
|
2
|
+
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
module ParameterMatchers
|
6
|
+
|
7
|
+
# :call-seq: Not(parameter_matcher) -> parameter_matcher
|
8
|
+
#
|
9
|
+
# Matches if +parameter_matcher+ does not match.
|
10
|
+
# object = mock()
|
11
|
+
# object.expects(:method_1).with(Not(includes(1)))
|
12
|
+
# object.method_1([0, 2, 3])
|
13
|
+
# # no error raised
|
14
|
+
#
|
15
|
+
# object = mock()
|
16
|
+
# object.expects(:method_1).with(Not(includes(1)))
|
17
|
+
# object.method_1([0, 1, 2, 3])
|
18
|
+
# # error raised, because method_1 was not called with object not including 1
|
19
|
+
def Not(matcher)
|
20
|
+
Not.new(matcher)
|
21
|
+
end
|
22
|
+
|
23
|
+
class Not < Base # :nodoc:
|
24
|
+
|
25
|
+
def initialize(matcher)
|
26
|
+
@matcher = matcher
|
27
|
+
end
|
28
|
+
|
29
|
+
def matches?(available_parameters)
|
30
|
+
parameter = available_parameters.shift
|
31
|
+
!@matcher.matches?([parameter])
|
32
|
+
end
|
33
|
+
|
34
|
+
def mocha_inspect
|
35
|
+
"Not(#{@matcher.mocha_inspect})"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Mocha
|
2
|
+
|
3
|
+
module ParameterMatchers
|
4
|
+
|
5
|
+
# :call-seq: optionally(*parameter_matchers) -> parameter_matcher
|
6
|
+
#
|
7
|
+
# Matches optional parameters if available.
|
8
|
+
# object = mock()
|
9
|
+
# object.expects(:method_1).with(1, 2, optionally(3, 4))
|
10
|
+
# object.method_1(1, 2)
|
11
|
+
# # no error raised
|
12
|
+
#
|
13
|
+
# object = mock()
|
14
|
+
# object.expects(:method_1).with(1, 2, optionally(3, 4))
|
15
|
+
# object.method_1(1, 2, 3)
|
16
|
+
# # no error raised
|
17
|
+
#
|
18
|
+
# object = mock()
|
19
|
+
# object.expects(:method_1).with(1, 2, optionally(3, 4))
|
20
|
+
# object.method_1(1, 2, 3, 4)
|
21
|
+
# # no error raised
|
22
|
+
#
|
23
|
+
# object = mock()
|
24
|
+
# object.expects(:method_1).with(1, 2, optionally(3, 4))
|
25
|
+
# object.method_1(1, 2, 3, 5)
|
26
|
+
# # error raised, because optional parameters did not match
|
27
|
+
def optionally(*matchers)
|
28
|
+
Optionally.new(*matchers)
|
29
|
+
end
|
30
|
+
|
31
|
+
class Optionally < Base # :nodoc:
|
32
|
+
|
33
|
+
def initialize(*parameters)
|
34
|
+
@matchers = parameters.map { |parameter| parameter.to_matcher }
|
35
|
+
end
|
36
|
+
|
37
|
+
def matches?(available_parameters)
|
38
|
+
index = 0
|
39
|
+
while (available_parameters.length > 0) && (index < @matchers.length) do
|
40
|
+
matcher = @matchers[index]
|
41
|
+
return false unless matcher.matches?(available_parameters)
|
42
|
+
index += 1
|
43
|
+
end
|
44
|
+
return true
|
45
|
+
end
|
46
|
+
|
47
|
+
def mocha_inspect
|
48
|
+
"optionally(#{@matchers.map { |matcher| matcher.mocha_inspect }.join(", ") })"
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'mocha/parameter_matchers/base'
|
2
|
+
|
3
|
+
module Mocha
|
4
|
+
|
5
|
+
module ParameterMatchers
|
6
|
+
|
7
|
+
# :call-seq: regexp_matches(regular_expression) -> parameter_matcher
|
8
|
+
#
|
9
|
+
# Matches any object that matches +regular_expression+.
|
10
|
+
# object = mock()
|
11
|
+
# object.expects(:method_1).with(regexp_matches(/e/))
|
12
|
+
# object.method_1('hello')
|
13
|
+
# # no error raised
|
14
|
+
#
|
15
|
+
# object = mock()
|
16
|
+
# object.expects(:method_1).with(regexp_matches(/a/))
|
17
|
+
# object.method_1('hello')
|
18
|
+
# # error raised, because method_1 was not called with a parameter that matched the
|
19
|
+
# # regular expression
|
20
|
+
def regexp_matches(regexp)
|
21
|
+
RegexpMatches.new(regexp)
|
22
|
+
end
|
23
|
+
|
24
|
+
class RegexpMatches < Base # :nodoc:
|
25
|
+
|
26
|
+
def initialize(regexp)
|
27
|
+
@regexp = regexp
|
28
|
+
end
|
29
|
+
|
30
|
+
def matches?(available_parameters)
|
31
|
+
parameter = available_parameters.shift
|
32
|
+
parameter =~ @regexp
|
33
|
+
end
|
34
|
+
|
35
|
+
def mocha_inspect
|
36
|
+
"regexp_matches(#{@regexp.mocha_inspect})"
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'mocha/parameter_matchers/base'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Mocha
|
5
|
+
|
6
|
+
module ParameterMatchers
|
7
|
+
|
8
|
+
# :call-seq: responds_with(message, result) -> parameter_matcher
|
9
|
+
#
|
10
|
+
# Matches any object that responds to +message+ with +result+. To put it another way, it tests the quack, not the duck.
|
11
|
+
# object = mock()
|
12
|
+
# object.expects(:method_1).with(responds_with(:upcase, "FOO"))
|
13
|
+
# object.method_1("foo")
|
14
|
+
# # no error raised, because "foo".upcase == "FOO"
|
15
|
+
#
|
16
|
+
# object = mock()
|
17
|
+
# object.expects(:method_1).with(responds_with(:upcase, "BAR"))
|
18
|
+
# object.method_1("foo")
|
19
|
+
# # error raised, because "foo".upcase != "BAR"
|
20
|
+
def responds_with(message, result)
|
21
|
+
RespondsWith.new(message, result)
|
22
|
+
end
|
23
|
+
|
24
|
+
class RespondsWith < Base # :nodoc:
|
25
|
+
|
26
|
+
def initialize(message, result)
|
27
|
+
@message, @result = message, result
|
28
|
+
end
|
29
|
+
|
30
|
+
def matches?(available_parameters)
|
31
|
+
parameter = available_parameters.shift
|
32
|
+
parameter.__send__(@message) == @result
|
33
|
+
end
|
34
|
+
|
35
|
+
def mocha_inspect
|
36
|
+
"responds_with(#{@message.mocha_inspect}, #{@result.mocha_inspect})"
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|