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,104 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "test_helper")
|
2
|
+
require 'mocha/sequence'
|
3
|
+
require 'mocha/expectation'
|
4
|
+
|
5
|
+
class SequenceTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include Mocha
|
8
|
+
|
9
|
+
class FakeExpectation
|
10
|
+
|
11
|
+
attr_reader :ordering_constraints
|
12
|
+
|
13
|
+
def initialize(satisfied = false)
|
14
|
+
@satisfied = satisfied
|
15
|
+
@ordering_constraints = []
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_ordering_constraint(ordering_constraint)
|
19
|
+
@ordering_constraints << ordering_constraint
|
20
|
+
end
|
21
|
+
|
22
|
+
def satisfied?
|
23
|
+
@satisfied
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_should_be_satisfied_if_no_expectations_added
|
29
|
+
sequence = Sequence.new('name')
|
30
|
+
assert sequence.satisfied_to_index?(0)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_should_be_satisfied_if_one_unsatisfied_expectations_added_but_it_is_not_included_by_index
|
34
|
+
sequence = Sequence.new('name')
|
35
|
+
expectation = FakeExpectation.new(satisfied = false)
|
36
|
+
sequence.constrain_as_next_in_sequence(expectation)
|
37
|
+
assert sequence.satisfied_to_index?(0)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_should_not_be_satisfied_if_one_unsatisfied_expectations_added_and_it_is_included_by_index
|
41
|
+
sequence = Sequence.new('name')
|
42
|
+
expectation = FakeExpectation.new(satisfied = false)
|
43
|
+
sequence.constrain_as_next_in_sequence(expectation)
|
44
|
+
assert !sequence.satisfied_to_index?(1)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_should_be_satisfied_if_one_satisfied_expectations_added_and_it_is_included_by_index
|
48
|
+
sequence = Sequence.new('name')
|
49
|
+
expectation = FakeExpectation.new(satisfied = true)
|
50
|
+
sequence.constrain_as_next_in_sequence(expectation)
|
51
|
+
assert sequence.satisfied_to_index?(1)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_should_not_be_satisfied_if_one_satisfied_and_one_unsatisfied_expectation_added_and_both_are_included_by_index
|
55
|
+
sequence = Sequence.new('name')
|
56
|
+
expectation_one = FakeExpectation.new(satisfied = true)
|
57
|
+
expectation_two = FakeExpectation.new(satisfied = false)
|
58
|
+
sequence.constrain_as_next_in_sequence(expectation_one)
|
59
|
+
sequence.constrain_as_next_in_sequence(expectation_two)
|
60
|
+
assert !sequence.satisfied_to_index?(2)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_should_be_satisfied_if_two_satisfied_expectations_added_and_both_are_included_by_index
|
64
|
+
sequence = Sequence.new('name')
|
65
|
+
expectation_one = FakeExpectation.new(satisfied = true)
|
66
|
+
expectation_two = FakeExpectation.new(satisfied = true)
|
67
|
+
sequence.constrain_as_next_in_sequence(expectation_one)
|
68
|
+
sequence.constrain_as_next_in_sequence(expectation_two)
|
69
|
+
assert sequence.satisfied_to_index?(2)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_should_add_ordering_constraint_to_expectation
|
73
|
+
sequence = Sequence.new('name')
|
74
|
+
expectation = FakeExpectation.new
|
75
|
+
sequence.constrain_as_next_in_sequence(expectation)
|
76
|
+
assert_equal 1, expectation.ordering_constraints.length
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_should_not_allow_invocation_of_second_method_when_first_n_sequence_has_not_been_invoked
|
80
|
+
sequence = Sequence.new('name')
|
81
|
+
expectation_one = FakeExpectation.new(satisfied = false)
|
82
|
+
expectation_two = FakeExpectation.new(satisfied = false)
|
83
|
+
sequence.constrain_as_next_in_sequence(expectation_one)
|
84
|
+
sequence.constrain_as_next_in_sequence(expectation_two)
|
85
|
+
assert !expectation_two.ordering_constraints[0].allows_invocation_now?
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_should_allow_invocation_of_second_method_when_first_in_sequence_has_been_invoked
|
89
|
+
sequence = Sequence.new('name')
|
90
|
+
expectation_one = FakeExpectation.new(satisfied = true)
|
91
|
+
expectation_two = FakeExpectation.new(satisfied = false)
|
92
|
+
sequence.constrain_as_next_in_sequence(expectation_one)
|
93
|
+
sequence.constrain_as_next_in_sequence(expectation_two)
|
94
|
+
assert expectation_two.ordering_constraints[0].allows_invocation_now?
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_should_describe_ordering_constraint_as_being_part_of_named_sequence
|
98
|
+
sequence = Sequence.new('wibble')
|
99
|
+
expectation = FakeExpectation.new
|
100
|
+
sequence.constrain_as_next_in_sequence(expectation)
|
101
|
+
assert_equal "in sequence 'wibble'", expectation.ordering_constraints[0].mocha_inspect
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "test_helper")
|
2
|
+
|
3
|
+
require 'mocha/single_return_value'
|
4
|
+
|
5
|
+
class SingleReturnValueTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include Mocha
|
8
|
+
|
9
|
+
def test_should_return_value
|
10
|
+
value = SingleReturnValue.new('value')
|
11
|
+
assert_equal 'value', value.evaluate
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "test_helper")
|
2
|
+
|
3
|
+
require 'mocha/single_yield'
|
4
|
+
|
5
|
+
class SingleYieldTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include Mocha
|
8
|
+
|
9
|
+
def test_should_provide_parameters_for_single_yield_in_single_invocation
|
10
|
+
parameter_group = SingleYield.new(1, 2, 3)
|
11
|
+
parameter_groups = []
|
12
|
+
parameter_group.each do |parameters|
|
13
|
+
parameter_groups << parameters
|
14
|
+
end
|
15
|
+
assert_equal [[1, 2, 3]], parameter_groups
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "test_helper")
|
2
|
+
|
3
|
+
require 'mocha/state_machine'
|
4
|
+
|
5
|
+
class StateMachineTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include Mocha
|
8
|
+
|
9
|
+
def test_should_initially_be_in_no_state
|
10
|
+
state_machine = StateMachine.new('name')
|
11
|
+
any_state.each do |state|
|
12
|
+
assert !state_machine.is(state).active?
|
13
|
+
assert state_machine.is_not(state).active?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_be_able_to_enter_a_state
|
18
|
+
state_machine = StateMachine.new('name')
|
19
|
+
state = 'A'
|
20
|
+
other_states = any_state.reject { |s| s == state }
|
21
|
+
|
22
|
+
state_machine.is(state).activate
|
23
|
+
|
24
|
+
assert state_machine.is(state).active?
|
25
|
+
assert !state_machine.is_not(state).active?
|
26
|
+
other_states.each do |s|
|
27
|
+
assert !state_machine.is(s).active?
|
28
|
+
assert state_machine.is_not(s).active?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_should_be_able_to_change_state
|
33
|
+
state_machine = StateMachine.new('name')
|
34
|
+
state = 'B'
|
35
|
+
other_states = any_state.reject { |s| s == state }
|
36
|
+
|
37
|
+
state_machine.is('A').activate
|
38
|
+
state_machine.is(state).activate
|
39
|
+
|
40
|
+
assert state_machine.is(state).active?
|
41
|
+
assert !state_machine.is_not(state).active?
|
42
|
+
other_states.each do |s|
|
43
|
+
assert !state_machine.is(s).active?
|
44
|
+
assert state_machine.is_not(s).active?
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_should_be_put_into_an_initial_state
|
49
|
+
state_machine = StateMachine.new('name')
|
50
|
+
initial_state = 'A'
|
51
|
+
other_states = any_state.reject { |s| s == initial_state }
|
52
|
+
|
53
|
+
state_machine.starts_as(initial_state)
|
54
|
+
|
55
|
+
assert state_machine.is(initial_state).active?
|
56
|
+
assert !state_machine.is_not(initial_state).active?
|
57
|
+
other_states.each do |state|
|
58
|
+
assert !state_machine.is(state).active?
|
59
|
+
assert state_machine.is_not(state).active?
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_should_be_put_into_a_new_state
|
64
|
+
next_state = 'B'
|
65
|
+
|
66
|
+
other_states = any_state.reject { |s| s == next_state }
|
67
|
+
state_machine = StateMachine.new('name').starts_as('A')
|
68
|
+
|
69
|
+
state_machine.become(next_state)
|
70
|
+
|
71
|
+
assert state_machine.is(next_state).active?
|
72
|
+
assert !state_machine.is_not(next_state).active?
|
73
|
+
other_states.each do |state|
|
74
|
+
assert !state_machine.is(state).active?
|
75
|
+
assert state_machine.is_not(state).active?
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_should_describe_itself_as_name_and_current_state
|
80
|
+
state_machine = StateMachine.new('state_machine_name')
|
81
|
+
assert_equal 'state_machine_name has no current state', state_machine.mocha_inspect
|
82
|
+
inspectable_state = Class.new { define_method(:mocha_inspect) { "'inspectable_state'" } }.new
|
83
|
+
state_machine.is(inspectable_state).activate
|
84
|
+
assert_equal "state_machine_name is 'inspectable_state'", state_machine.mocha_inspect
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_should_have_self_describing_states
|
88
|
+
state_machine = StateMachine.new('state_machine_name')
|
89
|
+
inspectable_state = Class.new { define_method(:mocha_inspect) { "'inspectable_state'" } }.new
|
90
|
+
assert_equal "state_machine_name is 'inspectable_state'", state_machine.is(inspectable_state).mocha_inspect
|
91
|
+
assert_equal "state_machine_name is not 'inspectable_state'", state_machine.is_not(inspectable_state).mocha_inspect
|
92
|
+
end
|
93
|
+
|
94
|
+
def any_state
|
95
|
+
%w(A B C D)
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "test_helper")
|
2
|
+
require 'mocha/inspect'
|
3
|
+
|
4
|
+
class StringInspectTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_should_replace_escaped_quotes_with_single_quote
|
7
|
+
string = "my_string"
|
8
|
+
assert_equal "'my_string'", string.mocha_inspect
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "test_helper")
|
2
|
+
|
3
|
+
require 'mocha/yield_parameters'
|
4
|
+
require 'mocha/no_yields'
|
5
|
+
require 'mocha/single_yield'
|
6
|
+
require 'mocha/multiple_yields'
|
7
|
+
|
8
|
+
class YieldParametersTest < Test::Unit::TestCase
|
9
|
+
|
10
|
+
include Mocha
|
11
|
+
|
12
|
+
def test_should_return_null_yield_parameter_group_by_default
|
13
|
+
yield_parameters = YieldParameters.new
|
14
|
+
assert yield_parameters.next_invocation.is_a?(NoYields)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_return_single_yield_parameter_group
|
18
|
+
yield_parameters = YieldParameters.new
|
19
|
+
yield_parameters.add(1, 2, 3)
|
20
|
+
parameter_group = yield_parameters.next_invocation
|
21
|
+
assert parameter_group.is_a?(SingleYield)
|
22
|
+
assert_equal [1, 2, 3], parameter_group.parameters
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_should_keep_returning_single_yield_parameter_group
|
26
|
+
yield_parameters = YieldParameters.new
|
27
|
+
yield_parameters.add(1, 2, 3)
|
28
|
+
yield_parameters.next_invocation
|
29
|
+
parameter_group = yield_parameters.next_invocation
|
30
|
+
assert parameter_group.is_a?(SingleYield)
|
31
|
+
assert_equal [1, 2, 3], parameter_group.parameters
|
32
|
+
parameter_group = yield_parameters.next_invocation
|
33
|
+
assert parameter_group.is_a?(SingleYield)
|
34
|
+
assert_equal [1, 2, 3], parameter_group.parameters
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_should_return_consecutive_single_yield_parameter_groups
|
38
|
+
yield_parameters = YieldParameters.new
|
39
|
+
yield_parameters.add(1, 2, 3)
|
40
|
+
yield_parameters.add(4, 5)
|
41
|
+
parameter_group = yield_parameters.next_invocation
|
42
|
+
assert parameter_group.is_a?(SingleYield)
|
43
|
+
assert_equal [1, 2, 3], parameter_group.parameters
|
44
|
+
parameter_group = yield_parameters.next_invocation
|
45
|
+
assert parameter_group.is_a?(SingleYield)
|
46
|
+
assert_equal [4, 5], parameter_group.parameters
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_should_return_multiple_yield_parameter_group
|
50
|
+
yield_parameters = YieldParameters.new
|
51
|
+
yield_parameters.multiple_add([1, 2, 3], [4, 5])
|
52
|
+
parameter_group = yield_parameters.next_invocation
|
53
|
+
assert parameter_group.is_a?(MultipleYields)
|
54
|
+
assert_equal [[1, 2, 3], [4, 5]], parameter_group.parameter_groups
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_should_keep_returning_multiple_yield_parameter_group
|
58
|
+
yield_parameters = YieldParameters.new
|
59
|
+
yield_parameters.multiple_add([1, 2, 3], [4, 5])
|
60
|
+
yield_parameters.next_invocation
|
61
|
+
parameter_group = yield_parameters.next_invocation
|
62
|
+
assert parameter_group.is_a?(MultipleYields)
|
63
|
+
assert_equal [[1, 2, 3], [4, 5]], parameter_group.parameter_groups
|
64
|
+
parameter_group = yield_parameters.next_invocation
|
65
|
+
assert parameter_group.is_a?(MultipleYields)
|
66
|
+
assert_equal [[1, 2, 3], [4, 5]], parameter_group.parameter_groups
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_should_return_consecutive_multiple_yield_parameter_groups
|
70
|
+
yield_parameters = YieldParameters.new
|
71
|
+
yield_parameters.multiple_add([1, 2, 3], [4, 5])
|
72
|
+
yield_parameters.multiple_add([6, 7], [8, 9, 0])
|
73
|
+
parameter_group = yield_parameters.next_invocation
|
74
|
+
assert parameter_group.is_a?(MultipleYields)
|
75
|
+
assert_equal [[1, 2, 3], [4, 5]], parameter_group.parameter_groups
|
76
|
+
parameter_group = yield_parameters.next_invocation
|
77
|
+
assert parameter_group.is_a?(MultipleYields)
|
78
|
+
assert_equal [[6, 7], [8, 9, 0]], parameter_group.parameter_groups
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_should_return_consecutive_single_and_multiple_yield_parameter_groups
|
82
|
+
yield_parameters = YieldParameters.new
|
83
|
+
yield_parameters.add(1, 2, 3)
|
84
|
+
yield_parameters.multiple_add([4, 5, 6], [7, 8])
|
85
|
+
parameter_group = yield_parameters.next_invocation
|
86
|
+
assert parameter_group.is_a?(SingleYield)
|
87
|
+
assert_equal [1, 2, 3], parameter_group.parameters
|
88
|
+
parameter_group = yield_parameters.next_invocation
|
89
|
+
assert parameter_group.is_a?(MultipleYields)
|
90
|
+
assert_equal [[4, 5, 6], [7, 8]], parameter_group.parameter_groups
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
We're using GitHub[http://github.com/thoughtbot/shoulda/tree/master] and Lighthouse[http://thoughtbot.lighthouseapp.com/projects/5807], and we've been getting any combination of github pull requests, Lighthouse tickets, patches, emails, etc. We need to normalize this workflow to make sure we don't miss any fixes.
|
2
|
+
|
3
|
+
* Make sure you're accessing the source from the {official repository}[http://github.com/thoughtbot/shoulda/tree/master].
|
4
|
+
* We prefer git branches over patches, but we can take either.
|
5
|
+
* If you're using git, please make a branch for each separate contribution. We can cherry pick your commits, but pulling from a branch is easier.
|
6
|
+
* If you're submitting patches, please cut each fix or feature into a separate patch.
|
7
|
+
* There should be a Lighthouse[http://thoughtbot.lighthouseapp.com/projects/5807] ticket for any submission. If you've found a bug and want to fix it, open a new ticket at the same time.
|
8
|
+
* We've got github/lighthouse integration going, so you can update tickets when you commit. {This blog post}[http://hoth.entp.com/2008/4/11/github-and-lighthouse-sitting-in-a-tree] explains the commit options pretty well.
|
9
|
+
* Please <b>don't send pull requests</b> Just update the lighthouse ticket with the url for your fix (or attach the patch) when it's ready. The github pull requests pretty much get dropped on the floor until someone with commit rights notices them in the mailbox.
|
10
|
+
* Contributions without tests won't be accepted. The file <tt>/test/README</tt> explains the testing system pretty thoroughly.
|
11
|
+
|
12
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2007, Tammer Saleh, Thoughtbot, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,132 @@
|
|
1
|
+
= Shoulda - Making tests easy on the fingers and eyes
|
2
|
+
|
3
|
+
Shoulda makes it easy to write elegant, understandable, and maintainable tests. Shoulda consists of test macros, assertions, and helpers added on to the Test::Unit framework. It's fully compatible with your existing tests, and requires no retooling to use.
|
4
|
+
|
5
|
+
Helpers:: #context and #should give you rSpec like test blocks.
|
6
|
+
In addition, you get nested contexts and a much more readable syntax.
|
7
|
+
Macros:: Generate hundreds of lines of Controller and ActiveRecord tests with these powerful macros.
|
8
|
+
They get you started quickly, and can help you ensure that your application is conforming to best practices.
|
9
|
+
Assertions:: Many common rails testing idioms have been distilled into a set of useful assertions.
|
10
|
+
|
11
|
+
= Usage
|
12
|
+
|
13
|
+
=== Context Helpers (ThoughtBot::Shoulda::Context)
|
14
|
+
|
15
|
+
Stop killing your fingers with all of those underscores... Name your tests with plain sentences!
|
16
|
+
|
17
|
+
class UserTest << Test::Unit::TestCase
|
18
|
+
context "A User instance" do
|
19
|
+
setup do
|
20
|
+
@user = User.find(:first)
|
21
|
+
end
|
22
|
+
|
23
|
+
should "return its full name" do
|
24
|
+
assert_equal 'John Doe', @user.full_name
|
25
|
+
end
|
26
|
+
|
27
|
+
context "with a profile" do
|
28
|
+
setup do
|
29
|
+
@user.profile = Profile.find(:first)
|
30
|
+
end
|
31
|
+
|
32
|
+
should "return true when sent #has_profile?" do
|
33
|
+
assert @user.has_profile?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Produces the following test methods:
|
40
|
+
|
41
|
+
"test: A User instance should return its full name."
|
42
|
+
"test: A User instance with a profile should return true when sent #has_profile?."
|
43
|
+
|
44
|
+
So readable!
|
45
|
+
|
46
|
+
=== ActiveRecord Tests (ThoughtBot::Shoulda::ActiveRecord::Macros)
|
47
|
+
|
48
|
+
Quick macro tests for your ActiveRecord associations and validations:
|
49
|
+
|
50
|
+
class PostTest < Test::Unit::TestCase
|
51
|
+
fixtures :all
|
52
|
+
|
53
|
+
should_belong_to :user
|
54
|
+
should_have_many :tags, :through => :taggings
|
55
|
+
|
56
|
+
should_require_unique_attributes :title
|
57
|
+
should_require_attributes :body, :message => /wtf/
|
58
|
+
should_require_attributes :title
|
59
|
+
should_only_allow_numeric_values_for :user_id
|
60
|
+
end
|
61
|
+
|
62
|
+
class UserTest < Test::Unit::TestCase
|
63
|
+
should_have_many :posts
|
64
|
+
|
65
|
+
should_not_allow_values_for :email, "blah", "b lah"
|
66
|
+
should_allow_values_for :email, "a@b.com", "asdf@asdf.com"
|
67
|
+
should_ensure_length_in_range :email, 1..100
|
68
|
+
should_ensure_value_in_range :age, 1..100
|
69
|
+
should_protect_attributes :password
|
70
|
+
end
|
71
|
+
|
72
|
+
Makes TDD so much easier.
|
73
|
+
|
74
|
+
=== Controller Tests (ThoughtBot::Shoulda::Controller::Macros)
|
75
|
+
|
76
|
+
Macros to test the most common controller patterns...
|
77
|
+
|
78
|
+
context "on GET to :show for first record" do
|
79
|
+
setup do
|
80
|
+
get :show, :id => 1
|
81
|
+
end
|
82
|
+
|
83
|
+
should_assign_to :user
|
84
|
+
should_respond_with :success
|
85
|
+
should_render_template :show
|
86
|
+
should_not_set_the_flash
|
87
|
+
|
88
|
+
should "do something else really cool" do
|
89
|
+
assert_equal 1, assigns(:user).id
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
Test entire controllers in a few lines...
|
94
|
+
|
95
|
+
class PostsControllerTest < Test::Unit::TestCase
|
96
|
+
should_be_restful do |resource|
|
97
|
+
resource.parent = :user
|
98
|
+
|
99
|
+
resource.create.params = { :title => "first post", :body => 'blah blah blah'}
|
100
|
+
resource.update.params = { :title => "changed" }
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
should_be_restful generates 40 tests on the fly, for both html and xml requests.
|
105
|
+
|
106
|
+
=== Helpful Assertions (ThoughtBot::Shoulda::Assertions)
|
107
|
+
|
108
|
+
More to come here, but have fun with what's there.
|
109
|
+
|
110
|
+
assert_same_elements([:a, :b, :c], [:c, :a, :b])
|
111
|
+
assert_contains(['a', '1'], /\d/)
|
112
|
+
assert_contains(['a', '1'], 'a')
|
113
|
+
|
114
|
+
=== 3rd Party and Application Specific Macros
|
115
|
+
|
116
|
+
Any *.rb file under RAILS_ROOT/test/shoulda_macros/ or vendor/(plugins|gems)/gem_name/shoulda_macros/ will be automatically required when you run your tests. This allows you to distribute macros with your plugins, or to organize the macros inside your application. Remember to add your macro to Test::Unit::TestCase in the macro file:
|
117
|
+
|
118
|
+
# test/shoulda_macros/security.rb
|
119
|
+
class Test::Unit::TestCase
|
120
|
+
def self.should_be_denied(opts = {})
|
121
|
+
should_set_the_flash_to(opts[:flash] || /Please log in/i)
|
122
|
+
should_redirect_to(opts[:redirect] || 'login_url')
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
= Credits
|
127
|
+
|
128
|
+
Shoulda is maintained by {Tammer Saleh}[mailto:tsaleh@thoughtbot.com], and is funded by Thoughtbot[http://www.thoughtbot.com], inc.
|
129
|
+
|
130
|
+
= License
|
131
|
+
|
132
|
+
Shoulda is Copyright © 2006-2008 Tammer Saleh, Thoughtbot. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
require 'lib/shoulda/context'
|
6
|
+
load 'tasks/shoulda.rake'
|
7
|
+
|
8
|
+
# Test::Unit::UI::VERBOSE
|
9
|
+
test_files_pattern = 'test/{unit,functional,other}/**/*_test.rb'
|
10
|
+
Rake::TestTask.new do |t|
|
11
|
+
t.libs << 'lib'
|
12
|
+
t.pattern = test_files_pattern
|
13
|
+
t.verbose = false
|
14
|
+
end
|
15
|
+
|
16
|
+
Rake::RDocTask.new { |rdoc|
|
17
|
+
rdoc.rdoc_dir = 'doc'
|
18
|
+
rdoc.title = "Shoulda -- Making tests easy on the fingers and eyes"
|
19
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
20
|
+
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
21
|
+
rdoc.rdoc_files.include('README.rdoc', 'CONTRIBUTION_GUIDELINES.rdoc', 'lib/**/*.rb')
|
22
|
+
}
|
23
|
+
|
24
|
+
desc "Run code-coverage analysis using rcov"
|
25
|
+
task :coverage do
|
26
|
+
rm_rf "coverage"
|
27
|
+
files = Dir[test_files_pattern]
|
28
|
+
system "rcov --rails --sort coverage -Ilib #{files.join(' ')}"
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'Update documentation on website'
|
32
|
+
task :sync_docs => 'rdoc' do
|
33
|
+
`rsync -ave ssh doc/ dev@dev.thoughtbot.com:/home/dev/www/dev.thoughtbot.com/shoulda`
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'Default: run tests.'
|
37
|
+
task :default => ['test']
|
38
|
+
|
39
|
+
spec = Gem::Specification.new do |s|
|
40
|
+
s.name = "shoulda"
|
41
|
+
s.version = Thoughtbot::Shoulda::VERSION
|
42
|
+
s.summary = "Making tests easy on the fingers and eyes"
|
43
|
+
s.homepage = "http://thoughtbot.com/projects/shoulda"
|
44
|
+
s.rubyforge_project = "shoulda"
|
45
|
+
|
46
|
+
s.files = FileList["[A-Z]*", "{bin,lib,rails,test}/**/*"]
|
47
|
+
s.executables = s.files.grep(/^bin/) { |f| File.basename(f) }
|
48
|
+
|
49
|
+
s.has_rdoc = true
|
50
|
+
s.extra_rdoc_files = ["README.rdoc", "CONTRIBUTION_GUIDELINES.rdoc"]
|
51
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--main", "README.rdoc"]
|
52
|
+
|
53
|
+
s.authors = ["Tammer Saleh"]
|
54
|
+
s.email = "tsaleh@thoughtbot.com"
|
55
|
+
|
56
|
+
s.add_dependency "activesupport", ">= 2.0.0"
|
57
|
+
end
|
58
|
+
|
59
|
+
Rake::GemPackageTask.new spec do |pkg|
|
60
|
+
pkg.need_tar = true
|
61
|
+
pkg.need_zip = true
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "Clean files generated by rake tasks"
|
65
|
+
task :clobber => [:clobber_rdoc, :clobber_package]
|
66
|
+
|
67
|
+
desc "Generate a gemspec file for GitHub"
|
68
|
+
task :gemspec do
|
69
|
+
File.open("#{spec.name}.gemspec", 'w') do |f|
|
70
|
+
f.write spec.to_ruby
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
TMP = Dir::tmpdir
|
6
|
+
|
7
|
+
def usage(msg = nil)
|
8
|
+
puts "Error: #{msg}" if msg
|
9
|
+
puts if msg
|
10
|
+
puts "Usage: #{File.basename(__FILE__)} normal_test_file.rb"
|
11
|
+
puts
|
12
|
+
puts "Will convert an existing test file with names like "
|
13
|
+
puts
|
14
|
+
puts " def test_should_do_stuff"
|
15
|
+
puts " ..."
|
16
|
+
puts " end"
|
17
|
+
puts
|
18
|
+
puts "to one using the new syntax: "
|
19
|
+
puts
|
20
|
+
puts " should \"be super cool\" do"
|
21
|
+
puts " ..."
|
22
|
+
puts " end"
|
23
|
+
puts
|
24
|
+
puts "A copy of the old file will be left under #{TMP} in case\nthis script just seriously screws up"
|
25
|
+
puts
|
26
|
+
exit (msg ? 2 : 0)
|
27
|
+
end
|
28
|
+
|
29
|
+
usage("Wrong number of arguments.") unless ARGV.size == 1
|
30
|
+
usage("Temp directory '#{TMP}' is not valid. Set TMPDIR environment variable to a writeable directory.") unless File.directory?(TMP) && File.writable?(TMP)
|
31
|
+
|
32
|
+
file = ARGV.shift
|
33
|
+
tmpfile = File.join(TMP, File.basename(file))
|
34
|
+
usage("File '#{file}' doesn't exist") unless File.exists?(file)
|
35
|
+
|
36
|
+
FileUtils.cp(file, tmpfile)
|
37
|
+
contents = File.read(tmpfile)
|
38
|
+
contents.gsub!(/def test_should_(\S+)/) {|line| "should \"#{$1.tr('_', ' ')}\" do"}
|
39
|
+
contents.gsub!(/def test_(\S+)/) {|line| "should \"RENAME ME: test #{$1.tr('_', ' ')}\" do"}
|
40
|
+
File.open(file, 'w') { |f| f.write(contents) }
|
41
|
+
|
42
|
+
puts "File '#{file}' has been converted to 'should' syntax. Old version has been stored in '#{tmpfile}'"
|
data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/action_mailer/assertions.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module ThoughtBot # :nodoc:
|
2
|
+
module Shoulda # :nodoc:
|
3
|
+
module ActionMailer # :nodoc:
|
4
|
+
module Assertions
|
5
|
+
# Asserts that an email was delivered. Can take a block that can further
|
6
|
+
# narrow down the types of emails you're expecting.
|
7
|
+
#
|
8
|
+
# assert_sent_email
|
9
|
+
#
|
10
|
+
# Passes if ActionMailer::Base.deliveries has an email
|
11
|
+
#
|
12
|
+
# assert_sent_email do |email|
|
13
|
+
# email.subject =~ /hi there/ && email.to.include?('none@none.com')
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# Passes if there is an email with subject containing 'hi there' and
|
17
|
+
# 'none@none.com' as one of the recipients.
|
18
|
+
#
|
19
|
+
def assert_sent_email
|
20
|
+
emails = ::ActionMailer::Base.deliveries
|
21
|
+
assert !emails.empty?, "No emails were sent"
|
22
|
+
if block_given?
|
23
|
+
matching_emails = emails.select {|email| yield email }
|
24
|
+
assert !matching_emails.empty?, "None of the emails matched."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Asserts that no ActionMailer mails were delivered
|
29
|
+
#
|
30
|
+
# assert_did_not_send_email
|
31
|
+
def assert_did_not_send_email
|
32
|
+
msg = "Sent #{::ActionMailer::Base.deliveries.size} emails.\n"
|
33
|
+
::ActionMailer::Base.deliveries.each { |m| msg << " '#{m.subject}' sent to #{m.to.to_sentence}\n" }
|
34
|
+
assert ::ActionMailer::Base.deliveries.empty?, msg
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|