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,12 @@
|
|
1
|
+
require 'shoulda'
|
2
|
+
require 'shoulda/active_record/assertions'
|
3
|
+
require 'shoulda/active_record/macros'
|
4
|
+
|
5
|
+
module Test # :nodoc: all
|
6
|
+
module Unit
|
7
|
+
class TestCase
|
8
|
+
include ThoughtBot::Shoulda::ActiveRecord::Assertions
|
9
|
+
extend ThoughtBot::Shoulda::ActiveRecord::Macros
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module ThoughtBot # :nodoc:
|
2
|
+
module Shoulda # :nodoc:
|
3
|
+
module Assertions
|
4
|
+
# Asserts that two arrays contain the same elements, the same number of times. Essentially ==, but unordered.
|
5
|
+
#
|
6
|
+
# assert_same_elements([:a, :b, :c], [:c, :a, :b]) => passes
|
7
|
+
def assert_same_elements(a1, a2, msg = nil)
|
8
|
+
[:select, :inject, :size].each do |m|
|
9
|
+
[a1, a2].each {|a| assert_respond_to(a, m, "Are you sure that #{a.inspect} is an array? It doesn't respond to #{m}.") }
|
10
|
+
end
|
11
|
+
|
12
|
+
assert a1h = a1.inject({}) { |h,e| h[e] = a1.select { |i| i == e }.size; h }
|
13
|
+
assert a2h = a2.inject({}) { |h,e| h[e] = a2.select { |i| i == e }.size; h }
|
14
|
+
|
15
|
+
assert_equal(a1h, a2h, msg)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Asserts that the given collection contains item x. If x is a regular expression, ensure that
|
19
|
+
# at least one element from the collection matches x. +extra_msg+ is appended to the error message if the assertion fails.
|
20
|
+
#
|
21
|
+
# assert_contains(['a', '1'], /\d/) => passes
|
22
|
+
# assert_contains(['a', '1'], 'a') => passes
|
23
|
+
# assert_contains(['a', '1'], /not there/) => fails
|
24
|
+
def assert_contains(collection, x, extra_msg = "")
|
25
|
+
collection = [collection] unless collection.is_a?(Array)
|
26
|
+
msg = "#{x.inspect} not found in #{collection.to_a.inspect} #{extra_msg}"
|
27
|
+
case x
|
28
|
+
when Regexp: assert(collection.detect { |e| e =~ x }, msg)
|
29
|
+
else assert(collection.include?(x), msg)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Asserts that the given collection does not contain item x. If x is a regular expression, ensure that
|
34
|
+
# none of the elements from the collection match x.
|
35
|
+
def assert_does_not_contain(collection, x, extra_msg = "")
|
36
|
+
collection = [collection] unless collection.is_a?(Array)
|
37
|
+
msg = "#{x.inspect} found in #{collection.to_a.inspect} " + extra_msg
|
38
|
+
case x
|
39
|
+
when Regexp: assert(!collection.detect { |e| e =~ x }, msg)
|
40
|
+
else assert(!collection.include?(x), msg)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,306 @@
|
|
1
|
+
module Thoughtbot # :nodoc:
|
2
|
+
module Shoulda
|
3
|
+
VERSION = '2.0.4'
|
4
|
+
|
5
|
+
class << self
|
6
|
+
attr_accessor :contexts
|
7
|
+
def contexts # :nodoc:
|
8
|
+
@contexts ||= []
|
9
|
+
end
|
10
|
+
|
11
|
+
def current_context # :nodoc:
|
12
|
+
self.contexts.last
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_context(context) # :nodoc:
|
16
|
+
self.contexts.push(context)
|
17
|
+
end
|
18
|
+
|
19
|
+
def remove_context # :nodoc:
|
20
|
+
self.contexts.pop
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# == Should statements
|
25
|
+
#
|
26
|
+
# Should statements are just syntactic sugar over normal Test::Unit test methods. A should block
|
27
|
+
# contains all the normal code and assertions you're used to seeing, with the added benefit that
|
28
|
+
# they can be wrapped inside context blocks (see below).
|
29
|
+
#
|
30
|
+
# === Example:
|
31
|
+
#
|
32
|
+
# class UserTest << Test::Unit::TestCase
|
33
|
+
#
|
34
|
+
# def setup
|
35
|
+
# @user = User.new("John", "Doe")
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# should "return its full name"
|
39
|
+
# assert_equal 'John Doe', @user.full_name
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# ...will produce the following test:
|
45
|
+
# * <tt>"test: User should return its full name. "</tt>
|
46
|
+
#
|
47
|
+
# Note: The part before <tt>should</tt> in the test name is gleamed from the name of the Test::Unit class.
|
48
|
+
#
|
49
|
+
# Should statements can also take a Proc as a <tt>:before </tt>option. This proc runs after any
|
50
|
+
# parent context's setups but before the current context's setup.
|
51
|
+
#
|
52
|
+
# === Example:
|
53
|
+
#
|
54
|
+
# context "Some context" do
|
55
|
+
# setup { puts("I run after the :before proc") }
|
56
|
+
#
|
57
|
+
# should "run a :before proc", :before => lambda { puts("I run before the setup") } do
|
58
|
+
# assert true
|
59
|
+
# end
|
60
|
+
# end
|
61
|
+
|
62
|
+
def should(name, options = {}, &blk)
|
63
|
+
if Shoulda.current_context
|
64
|
+
block_given? ? Shoulda.current_context.should(name, options, &blk) : Should.current_context.should_eventually(name)
|
65
|
+
else
|
66
|
+
context_name = self.name.gsub(/Test/, "")
|
67
|
+
context = Thoughtbot::Shoulda::Context.new(context_name, self) do
|
68
|
+
block_given? ? should(name, options, &blk) : should_eventually(name)
|
69
|
+
end
|
70
|
+
context.build
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# == Before statements
|
75
|
+
#
|
76
|
+
# Before statements are should statements that run before the current
|
77
|
+
# context's setup. These are especially useful when setting expectations.
|
78
|
+
#
|
79
|
+
# === Example:
|
80
|
+
#
|
81
|
+
# class UserControllerTest < Test::Unit::TestCase
|
82
|
+
# context "the index action" do
|
83
|
+
# setup do
|
84
|
+
# @users = [Factory(:user)]
|
85
|
+
# User.stubs(:find).returns(@users)
|
86
|
+
# end
|
87
|
+
#
|
88
|
+
# context "on GET" do
|
89
|
+
# setup { get :index }
|
90
|
+
#
|
91
|
+
# should_respond_with :success
|
92
|
+
#
|
93
|
+
# # runs before "get :index"
|
94
|
+
# before_should "find all users" do
|
95
|
+
# User.expects(:find).with(:all).returns(@users)
|
96
|
+
# end
|
97
|
+
# end
|
98
|
+
# end
|
99
|
+
# end
|
100
|
+
def before_should(name, &blk)
|
101
|
+
should(name, :before => blk) { assert true }
|
102
|
+
end
|
103
|
+
|
104
|
+
# Just like should, but never runs, and instead prints an 'X' in the Test::Unit output.
|
105
|
+
def should_eventually(name, options = {}, &blk)
|
106
|
+
context_name = self.name.gsub(/Test/, "")
|
107
|
+
context = Thoughtbot::Shoulda::Context.new(context_name, self) do
|
108
|
+
should_eventually(name, &blk)
|
109
|
+
end
|
110
|
+
context.build
|
111
|
+
end
|
112
|
+
|
113
|
+
# == Contexts
|
114
|
+
#
|
115
|
+
# A context block groups should statements under a common set of setup/teardown methods.
|
116
|
+
# Context blocks can be arbitrarily nested, and can do wonders for improving the maintainability
|
117
|
+
# and readability of your test code.
|
118
|
+
#
|
119
|
+
# A context block can contain setup, should, should_eventually, and teardown blocks.
|
120
|
+
#
|
121
|
+
# class UserTest << Test::Unit::TestCase
|
122
|
+
# context "A User instance" do
|
123
|
+
# setup do
|
124
|
+
# @user = User.find(:first)
|
125
|
+
# end
|
126
|
+
#
|
127
|
+
# should "return its full name"
|
128
|
+
# assert_equal 'John Doe', @user.full_name
|
129
|
+
# end
|
130
|
+
# end
|
131
|
+
# end
|
132
|
+
#
|
133
|
+
# This code will produce the method <tt>"test: A User instance should return its full name. "</tt>.
|
134
|
+
#
|
135
|
+
# Contexts may be nested. Nested contexts run their setup blocks from out to in before each
|
136
|
+
# should statement. They then run their teardown blocks from in to out after each should statement.
|
137
|
+
#
|
138
|
+
# class UserTest << Test::Unit::TestCase
|
139
|
+
# context "A User instance" do
|
140
|
+
# setup do
|
141
|
+
# @user = User.find(:first)
|
142
|
+
# end
|
143
|
+
#
|
144
|
+
# should "return its full name"
|
145
|
+
# assert_equal 'John Doe', @user.full_name
|
146
|
+
# end
|
147
|
+
#
|
148
|
+
# context "with a profile" do
|
149
|
+
# setup do
|
150
|
+
# @user.profile = Profile.find(:first)
|
151
|
+
# end
|
152
|
+
#
|
153
|
+
# should "return true when sent :has_profile?"
|
154
|
+
# assert @user.has_profile?
|
155
|
+
# end
|
156
|
+
# end
|
157
|
+
# end
|
158
|
+
# end
|
159
|
+
#
|
160
|
+
# This code will produce the following methods
|
161
|
+
# * <tt>"test: A User instance should return its full name. "</tt>
|
162
|
+
# * <tt>"test: A User instance with a profile should return true when sent :has_profile?. "</tt>
|
163
|
+
#
|
164
|
+
# <b>Just like should statements, a context block can exist next to normal <tt>def test_the_old_way; end</tt>
|
165
|
+
# tests</b>. This means you do not have to fully commit to the context/should syntax in a test file.
|
166
|
+
|
167
|
+
def context(name, &blk)
|
168
|
+
if Shoulda.current_context
|
169
|
+
Shoulda.current_context.context(name, &blk)
|
170
|
+
else
|
171
|
+
context = Thoughtbot::Shoulda::Context.new(name, self, &blk)
|
172
|
+
context.build
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
class Context # :nodoc:
|
177
|
+
|
178
|
+
attr_accessor :name # my name
|
179
|
+
attr_accessor :parent # may be another context, or the original test::unit class.
|
180
|
+
attr_accessor :subcontexts # array of contexts nested under myself
|
181
|
+
attr_accessor :setup_blocks # blocks given via setup methods
|
182
|
+
attr_accessor :teardown_blocks # blocks given via teardown methods
|
183
|
+
attr_accessor :shoulds # array of hashes representing the should statements
|
184
|
+
attr_accessor :should_eventuallys # array of hashes representing the should eventually statements
|
185
|
+
|
186
|
+
def initialize(name, parent, &blk)
|
187
|
+
Shoulda.add_context(self)
|
188
|
+
self.name = name
|
189
|
+
self.parent = parent
|
190
|
+
self.setup_blocks = []
|
191
|
+
self.teardown_blocks = []
|
192
|
+
self.shoulds = []
|
193
|
+
self.should_eventuallys = []
|
194
|
+
self.subcontexts = []
|
195
|
+
|
196
|
+
merge_block(&blk)
|
197
|
+
Shoulda.remove_context
|
198
|
+
end
|
199
|
+
|
200
|
+
def merge_block(&blk)
|
201
|
+
blk.bind(self).call
|
202
|
+
end
|
203
|
+
|
204
|
+
def context(name, &blk)
|
205
|
+
self.subcontexts << Context.new(name, self, &blk)
|
206
|
+
end
|
207
|
+
|
208
|
+
def setup(&blk)
|
209
|
+
self.setup_blocks << blk
|
210
|
+
end
|
211
|
+
|
212
|
+
def teardown(&blk)
|
213
|
+
self.teardown_blocks << blk
|
214
|
+
end
|
215
|
+
|
216
|
+
def should(name, options = {}, &blk)
|
217
|
+
if block_given?
|
218
|
+
self.shoulds << { :name => name, :before => options[:before], :block => blk }
|
219
|
+
else
|
220
|
+
self.should_eventuallys << { :name => name }
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def should_eventually(name, &blk)
|
225
|
+
self.should_eventuallys << { :name => name, :block => blk }
|
226
|
+
end
|
227
|
+
|
228
|
+
def full_name
|
229
|
+
parent_name = parent.full_name if am_subcontext?
|
230
|
+
return [parent_name, name].join(" ").strip
|
231
|
+
end
|
232
|
+
|
233
|
+
def am_subcontext?
|
234
|
+
parent.is_a?(self.class) # my parent is the same class as myself.
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_unit_class
|
238
|
+
am_subcontext? ? parent.test_unit_class : parent
|
239
|
+
end
|
240
|
+
|
241
|
+
def create_test_from_should_hash(should)
|
242
|
+
test_name = ["test:", full_name, "should", "#{should[:name]}. "].flatten.join(' ').to_sym
|
243
|
+
|
244
|
+
if test_unit_class.instance_methods.include?(test_name.to_s)
|
245
|
+
warn " * WARNING: '#{test_name}' is already defined"
|
246
|
+
end
|
247
|
+
|
248
|
+
context = self
|
249
|
+
test_unit_class.send(:define_method, test_name) do
|
250
|
+
begin
|
251
|
+
context.run_parent_setup_blocks(self)
|
252
|
+
should[:before].bind(self).call if should[:before]
|
253
|
+
context.run_current_setup_blocks(self)
|
254
|
+
should[:block].bind(self).call
|
255
|
+
ensure
|
256
|
+
context.run_all_teardown_blocks(self)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
def run_all_setup_blocks(binding)
|
262
|
+
run_parent_setup_blocks(binding)
|
263
|
+
run_current_setup_blocks(binding)
|
264
|
+
end
|
265
|
+
|
266
|
+
def run_parent_setup_blocks(binding)
|
267
|
+
self.parent.run_all_setup_blocks(binding) if am_subcontext?
|
268
|
+
end
|
269
|
+
|
270
|
+
def run_current_setup_blocks(binding)
|
271
|
+
setup_blocks.each do |setup_block|
|
272
|
+
setup_block.bind(binding).call
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
def run_all_teardown_blocks(binding)
|
277
|
+
teardown_blocks.reverse.each do |teardown_block|
|
278
|
+
teardown_block.bind(binding).call
|
279
|
+
end
|
280
|
+
self.parent.run_all_teardown_blocks(binding) if am_subcontext?
|
281
|
+
end
|
282
|
+
|
283
|
+
def print_should_eventuallys
|
284
|
+
should_eventuallys.each do |should|
|
285
|
+
test_name = [full_name, "should", "#{should[:name]}. "].flatten.join(' ')
|
286
|
+
puts " * DEFERRED: " + test_name
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def build
|
291
|
+
shoulds.each do |should|
|
292
|
+
create_test_from_should_hash(should)
|
293
|
+
end
|
294
|
+
|
295
|
+
subcontexts.each { |context| context.build }
|
296
|
+
|
297
|
+
print_should_eventuallys
|
298
|
+
end
|
299
|
+
|
300
|
+
def method_missing(method, *args, &blk)
|
301
|
+
test_unit_class.send(method, *args, &blk)
|
302
|
+
end
|
303
|
+
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
data/test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/controller/formats/html.rb
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
module ThoughtBot # :nodoc:
|
2
|
+
module Shoulda # :nodoc:
|
3
|
+
module Controller # :nodoc:
|
4
|
+
module HTML # :nodoc: all
|
5
|
+
def self.included(other)
|
6
|
+
other.class_eval do
|
7
|
+
extend ThoughtBot::Shoulda::Controller::HTML::ClassMethods
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
def controller_name_from_class
|
13
|
+
self.name.gsub(/Test/, '')
|
14
|
+
end
|
15
|
+
|
16
|
+
def make_show_html_tests(res)
|
17
|
+
context "on GET to #{controller_name_from_class}#show" do
|
18
|
+
setup do
|
19
|
+
record = get_existing_record(res)
|
20
|
+
parent_params = make_parent_params(res, record)
|
21
|
+
get :show, parent_params.merge({ res.identifier => record.to_param })
|
22
|
+
end
|
23
|
+
|
24
|
+
if res.denied.actions.include?(:show)
|
25
|
+
should_not_assign_to res.object
|
26
|
+
should_redirect_to res.denied.redirect
|
27
|
+
should_set_the_flash_to res.denied.flash
|
28
|
+
else
|
29
|
+
should_assign_to res.object
|
30
|
+
should_respond_with :success
|
31
|
+
should_render_template :show
|
32
|
+
should_not_set_the_flash
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def make_edit_html_tests(res)
|
38
|
+
context "on GET to #{controller_name_from_class}#edit" do
|
39
|
+
setup do
|
40
|
+
@record = get_existing_record(res)
|
41
|
+
parent_params = make_parent_params(res, @record)
|
42
|
+
get :edit, parent_params.merge({ res.identifier => @record.to_param })
|
43
|
+
end
|
44
|
+
|
45
|
+
if res.denied.actions.include?(:edit)
|
46
|
+
should_not_assign_to res.object
|
47
|
+
should_redirect_to res.denied.redirect
|
48
|
+
should_set_the_flash_to res.denied.flash
|
49
|
+
else
|
50
|
+
should_assign_to res.object
|
51
|
+
should_respond_with :success
|
52
|
+
should_render_template :edit
|
53
|
+
should_not_set_the_flash
|
54
|
+
should_render_a_form
|
55
|
+
should "set @#{res.object} to requested instance" do
|
56
|
+
assert_equal @record, assigns(res.object)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def make_index_html_tests(res)
|
63
|
+
context "on GET to #{controller_name_from_class}#index" do
|
64
|
+
setup do
|
65
|
+
record = get_existing_record(res) rescue nil
|
66
|
+
parent_params = make_parent_params(res, record)
|
67
|
+
get(:index, parent_params)
|
68
|
+
end
|
69
|
+
|
70
|
+
if res.denied.actions.include?(:index)
|
71
|
+
should_not_assign_to res.object.to_s.pluralize
|
72
|
+
should_redirect_to res.denied.redirect
|
73
|
+
should_set_the_flash_to res.denied.flash
|
74
|
+
else
|
75
|
+
should_respond_with :success
|
76
|
+
should_assign_to res.object.to_s.pluralize
|
77
|
+
should_render_template :index
|
78
|
+
should_not_set_the_flash
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def make_new_html_tests(res)
|
84
|
+
context "on GET to #{controller_name_from_class}#new" do
|
85
|
+
setup do
|
86
|
+
record = get_existing_record(res) rescue nil
|
87
|
+
parent_params = make_parent_params(res, record)
|
88
|
+
get(:new, parent_params)
|
89
|
+
end
|
90
|
+
|
91
|
+
if res.denied.actions.include?(:new)
|
92
|
+
should_not_assign_to res.object
|
93
|
+
should_redirect_to res.denied.redirect
|
94
|
+
should_set_the_flash_to res.denied.flash
|
95
|
+
else
|
96
|
+
should_respond_with :success
|
97
|
+
should_assign_to res.object
|
98
|
+
should_not_set_the_flash
|
99
|
+
should_render_template :new
|
100
|
+
should_render_a_form
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def make_destroy_html_tests(res)
|
106
|
+
context "on DELETE to #{controller_name_from_class}#destroy" do
|
107
|
+
setup do
|
108
|
+
@record = get_existing_record(res)
|
109
|
+
parent_params = make_parent_params(res, @record)
|
110
|
+
delete :destroy, parent_params.merge({ res.identifier => @record.to_param })
|
111
|
+
end
|
112
|
+
|
113
|
+
if res.denied.actions.include?(:destroy)
|
114
|
+
should_redirect_to res.denied.redirect
|
115
|
+
should_set_the_flash_to res.denied.flash
|
116
|
+
|
117
|
+
should "not destroy record" do
|
118
|
+
assert_nothing_raised { assert @record.reload }
|
119
|
+
end
|
120
|
+
else
|
121
|
+
should_set_the_flash_to res.destroy.flash
|
122
|
+
if res.destroy.redirect.is_a? Symbol
|
123
|
+
should_respond_with res.destroy.redirect
|
124
|
+
else
|
125
|
+
should_redirect_to res.destroy.redirect
|
126
|
+
end
|
127
|
+
|
128
|
+
should "destroy record" do
|
129
|
+
assert_raises(::ActiveRecord::RecordNotFound, "@#{res.object} was not destroyed.") do
|
130
|
+
@record.reload
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def make_create_html_tests(res)
|
138
|
+
context "on POST to #{controller_name_from_class}#create with #{res.create.params.inspect}" do
|
139
|
+
setup do
|
140
|
+
record = get_existing_record(res) rescue nil
|
141
|
+
parent_params = make_parent_params(res, record)
|
142
|
+
@count = res.klass.count
|
143
|
+
post :create, parent_params.merge(res.object => res.create.params)
|
144
|
+
end
|
145
|
+
|
146
|
+
if res.denied.actions.include?(:create)
|
147
|
+
should_redirect_to res.denied.redirect
|
148
|
+
should_set_the_flash_to res.denied.flash
|
149
|
+
should_not_assign_to res.object
|
150
|
+
|
151
|
+
should "not create new record" do
|
152
|
+
assert_equal @count, res.klass.count
|
153
|
+
end
|
154
|
+
else
|
155
|
+
should_assign_to res.object
|
156
|
+
should_set_the_flash_to res.create.flash
|
157
|
+
if res.create.redirect.is_a? Symbol
|
158
|
+
should_respond_with res.create.redirect
|
159
|
+
else
|
160
|
+
should_redirect_to res.create.redirect
|
161
|
+
end
|
162
|
+
|
163
|
+
should "not have errors on @#{res.object}" do
|
164
|
+
assert_equal [], pretty_error_messages(assigns(res.object)), "@#{res.object} has errors:"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def make_update_html_tests(res)
|
171
|
+
context "on PUT to #{controller_name_from_class}#update with #{res.create.params.inspect}" do
|
172
|
+
setup do
|
173
|
+
@record = get_existing_record(res)
|
174
|
+
parent_params = make_parent_params(res, @record)
|
175
|
+
put :update, parent_params.merge(res.identifier => @record.to_param, res.object => res.update.params)
|
176
|
+
end
|
177
|
+
|
178
|
+
if res.denied.actions.include?(:update)
|
179
|
+
should_not_assign_to res.object
|
180
|
+
should_redirect_to res.denied.redirect
|
181
|
+
should_set_the_flash_to res.denied.flash
|
182
|
+
else
|
183
|
+
should_assign_to res.object
|
184
|
+
should_set_the_flash_to(res.update.flash)
|
185
|
+
if res.update.redirect.is_a? Symbol
|
186
|
+
should_respond_with res.update.redirect
|
187
|
+
else
|
188
|
+
should_redirect_to res.update.redirect
|
189
|
+
end
|
190
|
+
|
191
|
+
should "not have errors on @#{res.object}" do
|
192
|
+
assert_equal [], pretty_error_messages(assigns(res.object)), "@#{res.object} has errors:"
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|