aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vendor/plugins/rspec/.autotest3
-rw-r--r--vendor/plugins/rspec/.gitignore7
-rw-r--r--vendor/plugins/rspec/CHANGES52
-rw-r--r--vendor/plugins/rspec/MIT-LICENSE2
-rw-r--r--vendor/plugins/rspec/README53
-rw-r--r--vendor/plugins/rspec/Rakefile30
-rw-r--r--vendor/plugins/rspec/TODO1
-rw-r--r--vendor/plugins/rspec/UPGRADE24
-rw-r--r--vendor/plugins/rspec/autotest/discover.rb6
-rw-r--r--vendor/plugins/rspec/autotest/rspec.rb1
-rw-r--r--vendor/plugins/rspec/examples/pure/partial_mock_example.rb1
-rw-r--r--vendor/plugins/rspec/examples/stories/calculator.rb2
-rw-r--r--vendor/plugins/rspec/examples/stories/game-of-life/.loadpath5
-rw-r--r--vendor/plugins/rspec/failing_examples/README.txt7
-rw-r--r--vendor/plugins/rspec/lib/autotest/rspec.rb62
-rw-r--r--vendor/plugins/rspec/lib/spec.rb7
-rw-r--r--vendor/plugins/rspec/lib/spec/example.rb2
-rw-r--r--vendor/plugins/rspec/lib/spec/example/configuration.rb46
-rw-r--r--vendor/plugins/rspec/lib/spec/example/example_group.rb3
-rw-r--r--vendor/plugins/rspec/lib/spec/example/example_group_factory.rb44
-rw-r--r--vendor/plugins/rspec/lib/spec/example/example_group_methods.rb37
-rw-r--r--vendor/plugins/rspec/lib/spec/example/example_methods.rb10
-rw-r--r--vendor/plugins/rspec/lib/spec/example/module_inclusion_warnings.rb37
-rw-r--r--vendor/plugins/rspec/lib/spec/expectations/differs/default.rb2
-rw-r--r--vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb16
-rw-r--r--vendor/plugins/rspec/lib/spec/expectations/handler.rb8
-rwxr-xr-xvendor/plugins/rspec/lib/spec/extensions.rb1
-rw-r--r--vendor/plugins/rspec/lib/spec/extensions/metaclass.rb7
-rwxr-xr-xvendor/plugins/rspec/lib/spec/extensions/object.rb4
-rw-r--r--vendor/plugins/rspec/lib/spec/interop/test.rb4
-rw-r--r--vendor/plugins/rspec/lib/spec/interop/test/unit/ui/console/testrunner.rb1
-rw-r--r--vendor/plugins/rspec/lib/spec/matchers/change.rb2
-rw-r--r--vendor/plugins/rspec/lib/spec/matchers/has.rb12
-rw-r--r--vendor/plugins/rspec/lib/spec/matchers/raise_error.rb95
-rw-r--r--vendor/plugins/rspec/lib/spec/mocks.rb2
-rw-r--r--vendor/plugins/rspec/lib/spec/mocks/argument_constraint_matchers.rb6
-rw-r--r--vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb26
-rw-r--r--vendor/plugins/rspec/lib/spec/mocks/extensions.rb1
-rw-r--r--vendor/plugins/rspec/lib/spec/mocks/framework.rb15
-rw-r--r--vendor/plugins/rspec/lib/spec/mocks/message_expectation.rb34
-rw-r--r--vendor/plugins/rspec/lib/spec/mocks/mock.rb16
-rw-r--r--vendor/plugins/rspec/lib/spec/mocks/proxy.rb38
-rw-r--r--vendor/plugins/rspec/lib/spec/rake/spectask.rb10
-rw-r--r--vendor/plugins/rspec/lib/spec/runner.rb14
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb2
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/formatter/base_formatter.rb5
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb4
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/formatter/failing_example_groups_formatter.rb12
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/formatter/html_formatter.rb32
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/formatter/nested_text_formatter.rb65
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/formatter/profile_formatter.rb4
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/formatter/progress_bar_formatter.rb6
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/formatter/specdoc_formatter.rb2
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb3
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/formatter/story/plain_text_formatter.rb30
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/option_parser.rb70
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/options.rb118
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/reporter.rb26
-rw-r--r--vendor/plugins/rspec/lib/spec/runner/spec_parser.rb80
-rw-r--r--vendor/plugins/rspec/lib/spec/story/extensions/regexp.rb4
-rw-r--r--vendor/plugins/rspec/lib/spec/story/extensions/string.rb4
-rw-r--r--vendor/plugins/rspec/lib/spec/story/runner.rb16
-rw-r--r--vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb4
-rw-r--r--vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb8
-rw-r--r--vendor/plugins/rspec/lib/spec/story/runner/story_mediator.rb2
-rw-r--r--vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb4
-rw-r--r--vendor/plugins/rspec/lib/spec/story/step.rb20
-rw-r--r--vendor/plugins/rspec/lib/spec/story/story.rb19
-rw-r--r--vendor/plugins/rspec/lib/spec/story/world.rb2
-rw-r--r--vendor/plugins/rspec/lib/spec/version.rb44
-rw-r--r--vendor/plugins/rspec/plugins/mock_frameworks/rspec.rb2
-rw-r--r--vendor/plugins/rspec/spec/README.jruby1
-rw-r--r--vendor/plugins/rspec/spec/autotest/rspec_spec.rb107
-rw-r--r--vendor/plugins/rspec/spec/autotest_helper.rb3
-rw-r--r--vendor/plugins/rspec/spec/autotest_matchers.rb47
-rw-r--r--vendor/plugins/rspec/spec/rspec_suite.rb2
-rw-r--r--vendor/plugins/rspec/spec/spec.opts (renamed from vendor/plugins/rspec/spec.opts)0
-rw-r--r--vendor/plugins/rspec/spec/spec/example/example_group/described_module_spec.rb20
-rw-r--r--vendor/plugins/rspec/spec/spec/example/example_group/warning_messages_spec.rb76
-rw-r--r--vendor/plugins/rspec/spec/spec/example/example_group_factory_spec.rb219
-rw-r--r--vendor/plugins/rspec/spec/spec/example/example_group_methods_spec.rb81
-rw-r--r--vendor/plugins/rspec/spec/spec/example/example_group_spec.rb14
-rw-r--r--vendor/plugins/rspec/spec/spec/example/example_methods_spec.rb145
-rw-r--r--vendor/plugins/rspec/spec/spec/example/nested_example_group_spec.rb12
-rw-r--r--vendor/plugins/rspec/spec/spec/expectations/differs/default_spec.rb36
-rw-r--r--vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_fails.rb10
-rw-r--r--vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_passes.rb10
-rw-r--r--vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_with_errors.rb10
-rw-r--r--vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_fails.rb10
-rw-r--r--vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_passes.rb10
-rw-r--r--vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_with_errors.rb10
-rw-r--r--vendor/plugins/rspec/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb38
-rw-r--r--vendor/plugins/rspec/spec/spec/interop/test/unit/spec_spec.rb45
-rw-r--r--vendor/plugins/rspec/spec/spec/interop/test/unit/testcase_spec.rb43
-rw-r--r--vendor/plugins/rspec/spec/spec/interop/test/unit/testcase_spec_with_test_unit.rb20
-rw-r--r--vendor/plugins/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec.rb2
-rw-r--r--vendor/plugins/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec_with_test_unit.rb34
-rw-r--r--vendor/plugins/rspec/spec/spec/matchers/be_spec.rb24
-rw-r--r--vendor/plugins/rspec/spec/spec/matchers/has_spec.rb16
-rw-r--r--vendor/plugins/rspec/spec/spec/matchers/raise_error_spec.rb132
-rw-r--r--vendor/plugins/rspec/spec/spec/mocks/bug_report_10263_spec.rb (renamed from vendor/plugins/rspec/spec/spec/mocks/bug_report_10263.rb)2
-rw-r--r--vendor/plugins/rspec/spec/spec/mocks/bug_report_11545_spec.rb2
-rw-r--r--vendor/plugins/rspec/spec/spec/mocks/failing_mock_argument_constraints_spec.rb8
-rw-r--r--vendor/plugins/rspec/spec/spec/mocks/hash_including_matcher_spec.rb32
-rw-r--r--vendor/plugins/rspec/spec/spec/mocks/mock_spec.rb93
-rw-r--r--vendor/plugins/rspec/spec/spec/mocks/partial_mock_spec.rb46
-rw-r--r--vendor/plugins/rspec/spec/spec/mocks/passing_mock_argument_constraints_spec.rb6
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/command_line_spec.rb5
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/execution_context_spec.rb8
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb5
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html381
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6.html55
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/formatter/html_formatter_spec.rb3
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/formatter/nested_text_formatter_spec.rb333
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_spec.rb14
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb4
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/formatter/specdoc_formatter_spec.rb188
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb214
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html61
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb213
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/options_spec.rb194
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/reporter_spec.rb17
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/resources/a_bar.rb0
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/resources/a_foo.rb0
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/resources/a_spec.rb1
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/spec_drb.opts1
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/spec_parser/spec_parser_fixture.rb70
-rw-r--r--vendor/plugins/rspec/spec/spec/runner/spec_parser_spec.rb117
-rw-r--r--vendor/plugins/rspec/spec/spec/spec_classes.rb4
-rw-r--r--vendor/plugins/rspec/spec/spec/story/runner/plain_text_story_runner_spec.rb27
-rw-r--r--vendor/plugins/rspec/spec/spec/story/runner/scenario_runner_spec.rb176
-rw-r--r--vendor/plugins/rspec/spec/spec/story/runner/story_mediator_spec.rb4
-rw-r--r--vendor/plugins/rspec/spec/spec/story/runner/story_runner_spec.rb42
-rw-r--r--vendor/plugins/rspec/spec/spec/story/runner_spec.rb131
-rw-r--r--vendor/plugins/rspec/spec/spec/story/step_spec.rb41
-rw-r--r--vendor/plugins/rspec/spec/spec/story/story_spec.rb4
-rw-r--r--vendor/plugins/rspec/spec/spec/story/world_spec.rb7
-rw-r--r--vendor/plugins/rspec/stories/all.rb2
-rw-r--r--vendor/plugins/rspec/stories/example_groups/stories.rb7
-rw-r--r--vendor/plugins/rspec/stories/interop/test_case_with_should_methods2
-rw-r--r--vendor/plugins/rspec/stories/mock_framework_integration/stories.rb7
-rw-r--r--vendor/plugins/rspec/stories/mock_framework_integration/use_flexmock.story9
-rw-r--r--vendor/plugins/rspec/stories/resources/spec/spec_with_flexmock.rb18
-rw-r--r--vendor/plugins/rspec_on_rails/.gitignore4
-rw-r--r--vendor/plugins/rspec_on_rails/CHANGES21
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server20
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts7
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb8
-rwxr-xr-xvendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb3
-rwxr-xr-xvendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb8
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb4
-rwxr-xr-xvendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb4
-rwxr-xr-xvendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb12
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb6
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb4
-rw-r--r--vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/lib/autotest/discover.rb1
-rw-r--r--vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails.rb5
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example.rb1
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb1
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb104
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb23
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb58
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example/rails_example_group.rb51
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example/render_observer.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb24
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/configuration.rb7
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/matchers.rb1
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb6
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/include_text.rb54
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb2
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb4
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/mocks.rb115
-rw-r--r--vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb46
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb29
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb7
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb21
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb33
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb27
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb25
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb63
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb70
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb6
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb91
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/mocks/ar_classes.rb10
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb23
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/mocks/stub_model_spec.rb78
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/sample_modified_fixture.rb8
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb5
-rw-r--r--vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb69
-rw-r--r--vendor/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb23
-rw-r--r--vendor/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb4
-rw-r--r--vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml4
-rw-r--r--vendor/plugins/rspec_on_rails/tasks/rspec.rake4
200 files changed, 4576 insertions, 1719 deletions
diff --git a/vendor/plugins/rspec/.autotest b/vendor/plugins/rspec/.autotest
new file mode 100644
index 000000000..6ca66a445
--- /dev/null
+++ b/vendor/plugins/rspec/.autotest
@@ -0,0 +1,3 @@
+Autotest.add_hook :initialize do |at|
+ at.add_exception("spec/interop/test/unit/resources")
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec/.gitignore b/vendor/plugins/rspec/.gitignore
new file mode 100644
index 000000000..8e5fb3a88
--- /dev/null
+++ b/vendor/plugins/rspec/.gitignore
@@ -0,0 +1,7 @@
+pkg
+doc
+tmtags
+story_server/prototype/rspec_stories.html
+.DS_Store
+.emacs-project
+*~
diff --git a/vendor/plugins/rspec/CHANGES b/vendor/plugins/rspec/CHANGES
index f9c578cdd..0ac5b62f9 100644
--- a/vendor/plugins/rspec/CHANGES
+++ b/vendor/plugins/rspec/CHANGES
@@ -1,6 +1,58 @@
+== Version 1.1.4
+
+Maintenance release.
+
+Note: we've removed the metaclass method from Object. There were some
+generated specs that used it, and they will now break. Just replace the
+metaclass call with (class << self; self; end) and all will be well.
+
+* pending steps print out yellow in stories (patch from Kyle Hargraves)
+* Deprecation warnings for specs that assume auto-inclusion of modules. Closes #326 (patch from Scott Taylor)
+* mock.should_not_receive(:anything) fails fast (once again)
+* Patch from Antti Tarvainen to stop files from being loaded repeatedly when running heckle. Closes #333.
+* Fixed bug in which session object in example was not the same instance used in the controller. Closes #331.
+* Applied patch from Antti Tarvainen to fix bug where heckle runs rspec runs heckle runs rspec etc. Closes #280.
+* Applied patch from Zach Dennis to merge :steps functionality to :steps_for. Closes #324.
+* Applied patch from Ryan Davis to add eval of block passed to raise_error matcher. Closes #321.
+* alias :context :describe in example_group_methods. Closes #312.
+* Applied patch from Ben Mabey to make the Story runner exit with a non-0 exit code on failing stories. Closes #228.
+* Applied patch from Coda Hale to get the :red hook called in autotest. Closes #279.
+* Applied patch from Patrick Ritchie to support --drb in spec.opts. Closes #274, #293.
+* Moved metaclass method from Object to an internal module which gets included where it is needed.
+* Applied patch from Dayo Esho: and_yield clobbers return value from block. Closes #217.
+* Applied patch from Bob Cotton: ExampleGroupFactory.default resets previously registered types. Closes #222.
+* Applied patch from Mike Williams to support the lib directory in rails apps with the Textmate Alternate File command. Closes #276.
+* ExampleGroupMethods#xspecify aliases #xit
+* A SharedExampleGroup can be created within another ExampleGroup.
+* Applied patch from Bob Cotton: Nested ExampleGroups do not have a spec_path. Closes #224.
+* Add before_suite and after_suite callbacks to ExampleGroupMethods and Options. Closes #210.
+* The after(:suite) callback lambda is passed a boolean representing whether the suite passed or failed
+* Added NestedTextFormatter. Closes #366.
+* decoupled mock framework from global extensions used by rspec - supports use of flexmock or mocha w/ rails
+* Applied patch from Roman Chernyatchik to allow the user to pass in the rails version into spectask. Closes #325, #370
+
+== Version 1.1.3
+
+Maintenance release.
+Notice to autotest users: you must also upgrade to ZenTest-3.9.0.
+
+* Tightened up exceptions list in autotest/rails_spec. Closes #264.
+* Applied patch from Ryan Davis for ZenTest-3.9.0 compatibility
+* Applied patch from Kero to add step_upcoming to story listeners. Closes #253.
+* Fixed bug where the wrong named error was not always caught by "should raise_error"
+* Applied patch from Luis Lavena: No coloured output on Windows due missing RUBYOPT. Closes #244.
+* Applied patch from Craig Demyanovich to add support for "should_not render_template" to rspec_on_rails. Closes #241.
+* Added --pattern (-p for short) option to control what files get loaded. Defaults to '**/*_spec.rb'
+* Exit with non-0 exit code if examples *or tests* (in test/unit interop mode) fail. Closes #203.
+* Moved at_exit hook to a method in Spec::Runner which only runs if specs get loaded. Closes #242.
+* Applied patch from kakutani ensuring that base_view_path gets cleared after each view example. Closes #235.
+* More tweaks to regexp step names
+* Fixed focused specs in nested ExampleGroups. Closes #225.
+
== Version 1.1.2
Minor bug fixes/enhancements.
+Notice to autotest users: you must also upgrade to ZenTest-3.8.0.
* RSpec's Autotest subclasses compatible with ZenTest-3.8.0 (thanks to Ryan Davis for making it easier on Autotest subs).
* Applied patch from idl to add spec/lib to rake stats. Closes #226.
diff --git a/vendor/plugins/rspec/MIT-LICENSE b/vendor/plugins/rspec/MIT-LICENSE
index 1d11ea59e..336e52c94 100644
--- a/vendor/plugins/rspec/MIT-LICENSE
+++ b/vendor/plugins/rspec/MIT-LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2005-2007 The RSpec Development Team
+Copyright (c) 2005-2008 The RSpec Development Team
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/vendor/plugins/rspec/README b/vendor/plugins/rspec/README
index 0683b0deb..a532dca93 100644
--- a/vendor/plugins/rspec/README
+++ b/vendor/plugins/rspec/README
@@ -5,9 +5,9 @@ with Executable Scenarios and Executable Examples at the code level.
RSpec ships with several modules:
-Spec::Story provides a framework for expressing User Stories
+Spec::Story provides a framework for expressing User Stories and Scenarios
-Spec::Example provides a framework for expressing code Examples
+Spec::Example provides a framework for expressing Isolated Examples
Spec::Matchers provides Expression Matchers for use with Spec::Expectations
and Spec::Mocks.
@@ -22,50 +22,15 @@ behaviour to your existing objects.
== Installation
-The simplest approach is to install the gem:
+The simplest approach is to install the gem (as root in some environments):
- gem install -r rspec #mac users must sudo
+ gem install -r rspec
== Building the RSpec gem
-If you prefer to build the gem locally, check out source from svn://rubyforge.org/var/svn/rspec/trunk. Then
-do the following:
- rake gem
- gem install pkg/rspec-0.x.x.gem (you may have to sudo)
-
-== Running RSpec's specs
-In order to run RSpec's full suite of specs (rake pre_commit) you must install the following gems:
-
-* rake # Runs the build script
-* rcov # Verifies that the code is 100% covered by specs
-* webby # Generates the static HTML website
-* syntax # Required to highlight ruby code
-* diff-lcs # Required if you use the --diff switch
-* win32console # Required by the --colour switch if you're on Windows
-* meta_project # Required in order to make releases at RubyForge
-* heckle # Required if you use the --heckle switch
-* hpricot # Used for parsing HTML from the HTML output formatter in RSpec's own specs
-
-Once those are all installed, you should be able to run the suite with the following steps:
-
-* svn co svn://rubyforge.org/var/svn/rspec/trunk rspec
-* cd rspec
-* rake install_dependencies
-* cd example_rails_app
-* export RSPEC_RAILS_VERSION=1.2.3
-* rake rspec:generate_mysql_config
-* mysql -u root < db/mysql_setup.sql
-* cd ..
-* rake pre_commit
-
-Note that RSpec itself - once built - doesn't have any dependencies outside the Ruby core
-and stdlib - with a few exceptions:
-
-* The spec command line uses diff-lcs when --diff is specified.
-* The spec command line uses heckle when --heckle is specified.
-* The Spec::Rake::SpecTask needs RCov if RCov is enabled in the task.
-
-See http://rspec.rubyforge.org for further documentation.
-
-== Contributing
+If you prefer to build the gem locally:
+ git clone git://github.com/dchelimsky/rspec.git
+ cd rspec
+ rake gem
+ gem install pkg/rspec-0.x.x.gem #as root
diff --git a/vendor/plugins/rspec/Rakefile b/vendor/plugins/rspec/Rakefile
index 84d0b7da5..9405e30bf 100644
--- a/vendor/plugins/rspec/Rakefile
+++ b/vendor/plugins/rspec/Rakefile
@@ -7,8 +7,6 @@ require 'rake/rdoctask'
require 'rake/testtask'
require 'spec/version'
dir = File.dirname(__FILE__)
-$LOAD_PATH.unshift(File.expand_path("#{dir}/../pre_commit/lib"))
-require "pre_commit"
# Some of the tasks are in separate files since they are also part of the website documentation
load File.dirname(__FILE__) + '/rake_tasks/examples.rake'
@@ -22,10 +20,12 @@ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
PKG_FILES = FileList[
'[A-Z]*',
'lib/**/*.rb',
- 'spec/**/*.rb',
+ 'spec/**/*',
'examples/**/*',
+ 'failing_examples/**/*',
'plugins/**/*',
- 'stories/**/*'
+ 'stories/**/*',
+ 'rake_tasks/**/*'
]
task :default => [:verify_rcov]
@@ -34,7 +34,7 @@ task :verify_rcov => [:spec, :stories]
desc "Run all specs"
Spec::Rake::SpecTask.new do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
- t.spec_opts = ['--options', 'spec.opts']
+ t.spec_opts = ['--options', 'spec/spec.opts']
unless ENV['NO_RCOV']
t.rcov = true
t.rcov_dir = '../doc/output/coverage'
@@ -53,8 +53,8 @@ end
desc "Run all specs and store html output in doc/output/report.html"
Spec::Rake::SpecTask.new('spec_html') do |t|
- t.spec_files = FileList['spec/**/*_spec.rb', '../../RSpec.tmbundle/Support/spec/*_spec.rb']
- t.spec_opts = ['--format html:../doc/output/report.html','--backtrace']
+ t.spec_files = FileList['spec/**/*_spec.rb']
+ t.spec_opts = ['--format html:../../../../doc/output/report.html', '--format progress','--backtrace']
end
desc "Run all failing examples"
@@ -155,14 +155,6 @@ task :tag do
`#{create_current_cmd}` ; "ERROR: #{create_current_cmd}" unless $? == 0
end
-desc "Run this task before you commit. You should see 'OK TO COMMIT'"
-task(:pre_commit) {core.pre_commit}
-
-desc "Build the website, but do not publish it"
-task(:website) {core.website}
-
-task(:rdoc_rails) {core.rdoc_rails}
-
task :verify_user do
raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
end
@@ -194,10 +186,10 @@ end
desc "Package the Rails plugin"
task :package_rspec_on_rails do
mkdir 'pkg' rescue nil
- rm_rf 'pkg/rspec_on_rails' rescue nil
- `svn export ../rspec_on_rails pkg/rspec_on_rails-#{PKG_VERSION}`
+ rm_rf 'pkg/rspec-rails' rescue nil
+ `svn export ../rspec-rails pkg/rspec_on_rails-#{PKG_VERSION}`
Dir.chdir 'pkg' do
- `tar cvzf rspec_on_rails-#{PKG_VERSION}.tgz rspec_on_rails-#{PKG_VERSION}`
+ `tar cvzf rspec-rails-#{PKG_VERSION}.tgz rspec-rails-#{PKG_VERSION}`
end
end
task :pkg => :package_rspec_on_rails
@@ -218,7 +210,7 @@ task :publish_packages => [:verify_user, :package] do
release_files = FileList[
"pkg/#{PKG_FILE_NAME}.gem",
"pkg/#{PKG_FILE_NAME}.tgz",
- "pkg/rspec_on_rails-#{PKG_VERSION}.tgz",
+ "pkg/rspec-rails-#{PKG_VERSION}.tgz",
"pkg/#{PKG_FILE_NAME}.zip",
"pkg/RSpec-#{PKG_VERSION}.tmbundle.tgz"
]
diff --git a/vendor/plugins/rspec/TODO b/vendor/plugins/rspec/TODO
index 250bb66c2..8b1378917 100644
--- a/vendor/plugins/rspec/TODO
+++ b/vendor/plugins/rspec/TODO
@@ -1,2 +1 @@
-=== Before releasing 1.1.0:
diff --git a/vendor/plugins/rspec/UPGRADE b/vendor/plugins/rspec/UPGRADE
index 0a2c6f528..923b31530 100644
--- a/vendor/plugins/rspec/UPGRADE
+++ b/vendor/plugins/rspec/UPGRADE
@@ -1,29 +1,5 @@
-= Upgrading existing code to RSpec-0.9
-
-== General (see below for Spec::Rails specifics)
-
-=== New Syntax for should and should_not
-
-* Use translator (should get 90% of your code)
-* Manually fix "parenthesis" warnings
-
-=== Change before_context_eval to before_eval
-
-before_context_eval is an un-published hook used by
-Spec::Rails to create specialized behaviour contexts.
-Most of you don't need to change this, but for those
-who have exploited it, you'll need to change it to
-before_eval.
-
== Spec::Rails
-=== spec_helper.rb
-
-We've added a new way to configure Spec::Runner to do
-things like use_transactional_fixtures and use_instantiated_fixtures.
-You'll need to update spec/spec_helper.rb accordingly. You can either
-just re-generate it:
-
script/generate rspec
Or modify spec_helper.rb based on the template, which can be found at:
diff --git a/vendor/plugins/rspec/autotest/discover.rb b/vendor/plugins/rspec/autotest/discover.rb
deleted file mode 100644
index c16b2e4ed..000000000
--- a/vendor/plugins/rspec/autotest/discover.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# Used just for us to develop rspec with Autotest
-# We could symbolic link rspec/vendor/plugins/rspec => rspec/., but
-# this leads to a problem with subversion on windows. Autotest
-# uses Ruby's load path, which contains ".", so this is a workaround
-# (albeit, an unclean one)
-require File.dirname(__FILE__) + "/../lib/autotest/discover.rb"
diff --git a/vendor/plugins/rspec/autotest/rspec.rb b/vendor/plugins/rspec/autotest/rspec.rb
deleted file mode 100644
index b170d8f98..000000000
--- a/vendor/plugins/rspec/autotest/rspec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require File.dirname(__FILE__) + "/../lib/autotest/rspec.rb"
diff --git a/vendor/plugins/rspec/examples/pure/partial_mock_example.rb b/vendor/plugins/rspec/examples/pure/partial_mock_example.rb
index 841ec8847..2af608b2f 100644
--- a/vendor/plugins/rspec/examples/pure/partial_mock_example.rb
+++ b/vendor/plugins/rspec/examples/pure/partial_mock_example.rb
@@ -25,4 +25,5 @@ describe "A partial mock" do
MockableClass.msg_2
MockableClass.msg_3
end
+
end
diff --git a/vendor/plugins/rspec/examples/stories/calculator.rb b/vendor/plugins/rspec/examples/stories/calculator.rb
index 390437c55..d86fc7e5c 100644
--- a/vendor/plugins/rspec/examples/stories/calculator.rb
+++ b/vendor/plugins/rspec/examples/stories/calculator.rb
@@ -27,7 +27,7 @@ Story "addition", %{
As an accountant
I want to add numbers
So that I can count some beans
-}, :steps => steps do
+}, :steps_for => steps do
Scenario "2 + 3" do
Given "an addend of 2"
And "an addend of 3"
diff --git a/vendor/plugins/rspec/examples/stories/game-of-life/.loadpath b/vendor/plugins/rspec/examples/stories/game-of-life/.loadpath
new file mode 100644
index 000000000..9a6222015
--- /dev/null
+++ b/vendor/plugins/rspec/examples/stories/game-of-life/.loadpath
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<loadpath>
+ <pathentry path="" type="src"/>
+ <pathentry path="org.rubypeople.rdt.launching.RUBY_CONTAINER" type="con"/>
+</loadpath>
diff --git a/vendor/plugins/rspec/failing_examples/README.txt b/vendor/plugins/rspec/failing_examples/README.txt
new file mode 100644
index 000000000..38c667d92
--- /dev/null
+++ b/vendor/plugins/rspec/failing_examples/README.txt
@@ -0,0 +1,7 @@
+"Why have failing examples?", you might ask.
+
+They allow us to see failure messages. RSpec wants to provide meaningful and helpful failure messages. The failures in this directory not only provide you a way of seeing the failure messages, but they provide RSpec's own specs a way of describing what they should look like and ensuring they stay correct.
+
+To see the types of messages you can expect, stand in this directory and run:
+
+../bin/spec ./*.rb \ No newline at end of file
diff --git a/vendor/plugins/rspec/lib/autotest/rspec.rb b/vendor/plugins/rspec/lib/autotest/rspec.rb
index cf7421ee1..164f298f5 100644
--- a/vendor/plugins/rspec/lib/autotest/rspec.rb
+++ b/vendor/plugins/rspec/lib/autotest/rspec.rb
@@ -18,35 +18,18 @@ end
class RspecCommandError < StandardError; end
class Autotest::Rspec < Autotest
-
- def tests_for_file(filename)
- super.select { |f| @files.has_key? f }
- end
-
- alias :specs_for_file :tests_for_file
-
- def failed_results(results)
- results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
- end
- def handle_results(results)
- @files_to_test = consolidate_failures failed_results(results)
- unless @files_to_test.empty? then
- hook :red
- else
- hook :green
- end unless $TESTING
- @tainted = true unless @files_to_test.empty?
+ def initialize
+ super
+ self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m
+ self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
end
-
+
def consolidate_failures(failed)
- filters = Hash.new { |h,k| h[k] = [] }
- failed.each do |spec, failed_trace|
- @files.keys.select{|f| f =~ /spec\//}.each do |f|
- if failed_trace =~ Regexp.new(f)
- filters[f] << spec
- break
- end
+ filters = new_hash_of_arrays
+ failed.each do |spec, trace|
+ if trace =~ /\n(\.\/)?(.*\.rb):[\d]+:\Z?/
+ filters[$2] << spec
end
end
return filters
@@ -56,23 +39,25 @@ class Autotest::Rspec < Autotest
return "#{ruby} -S #{spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}"
end
- def add_options_if_present
+ def add_options_if_present # :nodoc:
File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
end
- # Finds the proper spec command to use. Precendence
- # is set in the lazily-evaluated method spec_commands. Alias + Override
- # that in ~/.autotest to provide a different spec command
- # then the default paths provided.
- def spec_command
- @spec_command ||= spec_commands.each do |command|
- if File.exists?(command)
- return @alt_separator ? (command.gsub @separator, @alt_separator) : command
- end
+ # Finds the proper spec command to use. Precendence is set in the
+ # lazily-evaluated method spec_commands. Alias + Override that in
+ # ~/.autotest to provide a different spec command then the default
+ # paths provided.
+ def spec_command(separator=File::ALT_SEPARATOR)
+ unless defined? @spec_command then
+ @spec_command = spec_commands.find { |cmd| File.exists? cmd }
+
+ raise RspecCommandError, "No spec command could be found!" unless @spec_command
+
+ @spec_command.gsub! File::SEPARATOR, separator if separator
end
- raise RspecCommandError, "No spec command could be found!"
+ @spec_command
end
-
+
# Autotest will look for spec commands in the following
# locations, in this order:
#
@@ -84,5 +69,4 @@ class Autotest::Rspec < Autotest
File.join(Config::CONFIG['bindir'], 'spec')
]
end
-
end
diff --git a/vendor/plugins/rspec/lib/spec.rb b/vendor/plugins/rspec/lib/spec.rb
index a0fc64750..c143aa885 100644
--- a/vendor/plugins/rspec/lib/spec.rb
+++ b/vendor/plugins/rspec/lib/spec.rb
@@ -27,11 +27,4 @@ module Spec
!Object.const_defined?(:Test) || Test::Unit.run?; \
end
end
-end
-
-at_exit do \
- unless $! || Spec.run?; \
- success = Spec.run; \
- exit success if Spec.exit?; \
- end \
end \ No newline at end of file
diff --git a/vendor/plugins/rspec/lib/spec/example.rb b/vendor/plugins/rspec/lib/spec/example.rb
index 39ff76b99..16ce12261 100644
--- a/vendor/plugins/rspec/lib/spec/example.rb
+++ b/vendor/plugins/rspec/lib/spec/example.rb
@@ -1,7 +1,7 @@
require 'timeout'
-require 'forwardable'
require 'spec/example/pending'
require 'spec/example/module_reopening_fix'
+require 'spec/example/module_inclusion_warnings'
require 'spec/example/example_group_methods'
require 'spec/example/example_methods'
require 'spec/example/example_group'
diff --git a/vendor/plugins/rspec/lib/spec/example/configuration.rb b/vendor/plugins/rspec/lib/spec/example/configuration.rb
index 674184727..cd3f46909 100644
--- a/vendor/plugins/rspec/lib/spec/example/configuration.rb
+++ b/vendor/plugins/rspec/lib/spec/example/configuration.rb
@@ -7,14 +7,20 @@ module Spec
# config.mock_with :rspec, :mocha, :flexmock, or :rr
# end
#
- # To use any other mock framework, you'll have to provide
- # your own adapter. This is simply a module that responds to
- # setup_mocks_for_rspec, verify_mocks_for_rspec and teardown_mocks_for_rspec.
+ # To use any other mock framework, you'll have to provide your own
+ # adapter. This is simply a module that responds to the following
+ # methods:
+ #
+ # setup_mocks_for_rspec
+ # verify_mocks_for_rspec
+ # teardown_mocks_for_rspec.
+ #
# These are your hooks into the lifecycle of a given example. RSpec will
- # call setup_mocks_for_rspec before running anything else in each Example.
- # After executing the #after methods, RSpec will then call verify_mocks_for_rspec
- # and teardown_mocks_for_rspec (this is guaranteed to run even if there are
- # failures in verify_mocks_for_rspec).
+ # call setup_mocks_for_rspec before running anything else in each
+ # Example. After executing the #after methods, RSpec will then call
+ # verify_mocks_for_rspec and teardown_mocks_for_rspec (this is
+ # guaranteed to run even if there are failures in
+ # verify_mocks_for_rspec).
#
# Once you've defined this module, you can pass that to mock_with:
#
@@ -35,12 +41,18 @@ module Spec
@mock_framework ||= mock_framework_path("rspec")
end
- # Declares modules to be included in all example groups (<tt>describe</tt> blocks).
- #
- # config.include(My::Bottle, My::Cup)
- #
- # If you want to restrict the inclusion to a subset of all the example groups then
- # specify this in a Hash as the last argument:
+ # :call-seq:
+ # include(Some::Helpers)
+ # include(Some::Helpers, More::Helpers)
+ # include(My::Helpers, :type => :key)
+ #
+ # Declares modules to be included in multiple example groups
+ # (<tt>describe</tt> blocks). With no :type, the modules listed will be
+ # included in all example groups. Use :type to restrict the inclusion to
+ # a subset of example groups. The value assigned to :type should be a
+ # key that maps to a class that is either a subclass of
+ # Spec::Example::ExampleGroup or extends Spec::Example::ExampleGroupMethods
+ # and includes Spec::Example::ExampleMethods
#
# config.include(My::Pony, My::Horse, :type => :farm)
#
@@ -70,7 +82,7 @@ module Spec
#
# This makes it possible to say:
#
- # person.should swim # passes if person.should_swim? returns true
+ # person.should swim # passes if person.can_swim? returns true
#
def predicate_matchers
@predicate_matchers ||= {}
@@ -85,10 +97,11 @@ module Spec
)
example_group.prepend_before(scope, &proc)
end
+
# Appends a global <tt>before</tt> block to all example groups.
#
- # If you want to restrict the block to a subset of all the example groups then
- # specify this in a Hash as the last argument:
+ # If you want to restrict the block to a subset of all the example
+ # groups then specify this in a Hash as the last argument:
#
# config.prepend_before(:all, :type => :farm)
#
@@ -115,6 +128,7 @@ module Spec
example_group.prepend_after(scope, &proc)
end
alias_method :after, :prepend_after
+
# Appends a global <tt>after</tt> block to all example groups.
# See #append_before for filtering semantics.
def append_after(*args, &proc)
diff --git a/vendor/plugins/rspec/lib/spec/example/example_group.rb b/vendor/plugins/rspec/lib/spec/example/example_group.rb
index d6e156f93..35997f0c4 100644
--- a/vendor/plugins/rspec/lib/spec/example/example_group.rb
+++ b/vendor/plugins/rspec/lib/spec/example/example_group.rb
@@ -1,6 +1,7 @@
module Spec
module Example
- # The superclass for all regular RSpec examples.
+ # Base class for customized example groups. Use this if you
+ # want to make a custom example group.
class ExampleGroup
extend Spec::Example::ExampleGroupMethods
include Spec::Example::ExampleMethods
diff --git a/vendor/plugins/rspec/lib/spec/example/example_group_factory.rb b/vendor/plugins/rspec/lib/spec/example/example_group_factory.rb
index 0414a3b96..c5caf4c9c 100644
--- a/vendor/plugins/rspec/lib/spec/example/example_group_factory.rb
+++ b/vendor/plugins/rspec/lib/spec/example/example_group_factory.rb
@@ -7,52 +7,54 @@ module Spec
default(ExampleGroup)
end
- # Registers an example group class +klass+ with the symbol
- # +type+. For example:
+ # Registers an example group class +klass+ with the symbol +type+. For
+ # example:
#
- # Spec::Example::ExampleGroupFactory.register(:farm, Spec::Farm::Example::FarmExampleGroup)
+ # Spec::Example::ExampleGroupFactory.register(:farm, FarmExampleGroup)
#
- # This will cause Main#describe from a file living in
- # <tt>spec/farm</tt> to create example group instances of type
- # Spec::Farm::Example::FarmExampleGroup.
- def register(id, example_group_class)
- @example_group_types[id] = example_group_class
+ # With that you can append a hash with :type => :farm to the describe
+ # method and it will load an instance of FarmExampleGroup.
+ #
+ # describe Pig, :type => :farm do
+ # ...
+ #
+ # If you don't use the hash explicitly, <tt>describe</tt> will
+ # implicitly use an instance of FarmExampleGroup for any file loaded
+ # from the <tt>./spec/farm</tt> directory.
+ def register(key, example_group_class)
+ @example_group_types[key] = example_group_class
end
# Sets the default ExampleGroup class
def default(example_group_class)
old = @example_group_types
@example_group_types = Hash.new(example_group_class)
- @example_group_types.merge(old) if old
+ @example_group_types.merge!(old) if old
end
- def get(id=nil)
- if @example_group_types.values.include?(id)
- id
+ def get(key=nil)
+ if @example_group_types.values.include?(key)
+ key
else
- @example_group_types[id]
+ @example_group_types[key]
end
end
def create_example_group(*args, &block)
opts = Hash === args.last ? args.last : {}
- if opts[:shared]
- SharedExampleGroup.new(*args, &block)
- else
- superclass = determine_superclass(opts)
- superclass.describe(*args, &block)
- end
+ superclass = determine_superclass(opts)
+ superclass.describe(*args, &block)
end
protected
def determine_superclass(opts)
- id = if opts[:type]
+ key = if opts[:type]
opts[:type]
elsif opts[:spec_path] =~ /spec(\\|\/)(#{@example_group_types.keys.join('|')})/
$2 == '' ? nil : $2.to_sym
end
- get(id)
+ get(key)
end
end
diff --git a/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb b/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb
index 8f73a9853..64e90cdb2 100644
--- a/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb
+++ b/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb
@@ -11,13 +11,14 @@ module Spec
end
end
- attr_reader :description_text, :description_args, :description_options, :spec_path
+ attr_reader :description_text, :description_args, :description_options, :spec_path, :registration_binding_block
def inherited(klass)
super
- klass.register
+ klass.register {}
+ Spec::Runner.register_at_exit_hook
end
-
+
# Makes the describe/it syntax available from a class. For example:
#
# class StackSpec < Spec::ExampleGroup
@@ -33,10 +34,17 @@ module Spec
# end
#
def describe(*args, &example_group_block)
+ args << {} unless Hash === args.last
if example_group_block
- self.subclass("Subclass") do
- describe(*args)
- module_eval(&example_group_block)
+ params = args.last
+ params[:spec_path] = eval("caller(0)[1]", example_group_block) unless params[:spec_path]
+ if params[:shared]
+ SharedExampleGroup.new(*args, &example_group_block)
+ else
+ self.subclass("Subclass") do
+ describe(*args)
+ module_eval(&example_group_block)
+ end
end
else
set_description(*args)
@@ -44,6 +52,7 @@ module Spec
self
end
end
+ alias :context :describe
# Use this to pull in examples from shared example groups.
# See Spec::Runner for information about shared example groups.
@@ -106,11 +115,12 @@ module Spec
def xit(description=nil, opts={}, &block)
Kernel.warn("Example disabled: #{description}")
end
+ alias_method :xspecify, :xit
def run
examples = examples_to_run
- return true if examples.empty?
reporter.add_example_group(self)
+ return true if examples.empty?
return dry_run(examples) if dry_run?
plugin_mock_framework
@@ -149,10 +159,12 @@ module Spec
@description_text = ExampleGroupMethods.description_text(*args)
@spec_path = File.expand_path(options[:spec_path]) if options[:spec_path]
if described_type.class == Module
- include described_type
+ @described_module = described_type
end
self
end
+
+ attr_reader :described_module
def examples #:nodoc:
examples = example_objects.dup
@@ -236,7 +248,8 @@ module Spec
@after_each_parts = nil
end
- def register
+ def register(&registration_binding_block)
+ @registration_binding_block = registration_binding_block
rspec_options.add_example_group self
end
@@ -244,6 +257,10 @@ module Spec
rspec_options.remove_example_group self
end
+ def registration_backtrace
+ eval("caller", registration_binding_block.binding)
+ end
+
def run_before_each(example)
execute_in_class_hierarchy do |example_group|
example.eval_each_fail_fast(example_group.before_each_parts)
@@ -378,6 +395,7 @@ module Spec
case scope
when :each; before_each_parts
when :all; before_all_parts
+ when :suite; rspec_options.before_suite_parts
end
end
@@ -385,6 +403,7 @@ module Spec
case scope
when :each; after_each_parts
when :all; after_all_parts
+ when :suite; rspec_options.after_suite_parts
end
end
diff --git a/vendor/plugins/rspec/lib/spec/example/example_methods.rb b/vendor/plugins/rspec/lib/spec/example/example_methods.rb
index 6dd4c9c72..d4d716c2d 100644
--- a/vendor/plugins/rspec/lib/spec/example/example_methods.rb
+++ b/vendor/plugins/rspec/lib/spec/example/example_methods.rb
@@ -3,6 +3,8 @@ module Spec
module ExampleMethods
extend ExampleGroupMethods
extend ModuleReopeningFix
+ include ModuleInclusionWarnings
+
PENDING_EXAMPLE_BLOCK = lambda {
raise Spec::Example::ExamplePendingError.new("Not Yet Implemented")
@@ -63,6 +65,10 @@ module Spec
def description
@_defined_description || @_matcher_description || "NO NAME"
end
+
+ def __full_description
+ "#{self.class.description} #{self.description}"
+ end
def set_instance_variables_from_hash(ivars)
ivars.each do |variable_name, value|
@@ -81,6 +87,10 @@ module Spec
Spec::Matchers.clear_generated_description
end
end
+
+ def implementation_backtrace
+ eval("caller", @_implementation)
+ end
protected
include Matchers
diff --git a/vendor/plugins/rspec/lib/spec/example/module_inclusion_warnings.rb b/vendor/plugins/rspec/lib/spec/example/module_inclusion_warnings.rb
new file mode 100644
index 000000000..c65faf2dd
--- /dev/null
+++ b/vendor/plugins/rspec/lib/spec/example/module_inclusion_warnings.rb
@@ -0,0 +1,37 @@
+module Spec
+ module Example
+ # In the future, modules will no longer be automatically included
+ # in the Example Group (based on the description name); when that
+ # time comes, this code should be removed.
+ module ModuleInclusionWarnings
+ # Thanks, Francis Hwang.
+ class MethodDispatcher
+ def initialize(mod, target=nil)
+ @mod = mod
+ @target = target
+ end
+
+ def respond_to?(sym)
+ @mod && @mod.instance_methods.include?(sym.to_s)
+ end
+
+ def call(sym, *args, &blk)
+ Kernel.warn("Modules will no longer be automatically included in RSpec version 1.1.4. Called from #{caller[2]}")
+ @target.extend @mod
+ @target.send(sym, *args, &blk)
+ end
+ end
+
+ def respond_to?(sym)
+ MethodDispatcher.new(self.class.described_module).respond_to?(sym) ? true : super
+ end
+
+ private
+
+ def method_missing(sym, *args, &blk)
+ md = MethodDispatcher.new(self.class.described_module, self)
+ self.respond_to?(sym) ? md.call(sym, *args, &blk) : super
+ end
+ end
+ end
+end
diff --git a/vendor/plugins/rspec/lib/spec/expectations/differs/default.rb b/vendor/plugins/rspec/lib/spec/expectations/differs/default.rb
index a5eb1bb89..74b59bbe3 100644
--- a/vendor/plugins/rspec/lib/spec/expectations/differs/default.rb
+++ b/vendor/plugins/rspec/lib/spec/expectations/differs/default.rb
@@ -17,7 +17,7 @@ module Spec
end
# This is snagged from diff/lcs/ldiff.rb (which is a commandline tool)
- def diff_as_string(data_old, data_new)
+ def diff_as_string(data_new, data_old)
data_old = data_old.split(/\n/).map! { |e| e.chomp }
data_new = data_new.split(/\n/).map! { |e| e.chomp }
output = ""
diff --git a/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb b/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb
index a3925bbee..2091c2947 100644
--- a/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb
+++ b/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb
@@ -27,12 +27,8 @@ module Spec
#
# NOTE that this does NOT support receiver.should != expected.
# Instead, use receiver.should_not == expected
- def should(matcher = :default_parameter, &block)
- if :default_parameter == matcher
- Spec::Matchers::PositiveOperatorMatcher.new(self)
- else
- ExpectationMatcherHandler.handle_matcher(self, matcher, &block)
- end
+ def should(matcher=:use_operator_matcher, &block)
+ ExpectationMatcherHandler.handle_matcher(self, matcher, &block)
end
# :call-seq:
@@ -54,12 +50,8 @@ module Spec
# => Passes unless (receiver =~ regexp)
#
# See Spec::Matchers for more information about matchers
- def should_not(matcher = :default_parameter, &block)
- if :default_parameter == matcher
- Spec::Matchers::NegativeOperatorMatcher.new(self)
- else
- NegativeExpectationMatcherHandler.handle_matcher(self, matcher, &block)
- end
+ def should_not(matcher=:use_operator_matcher, &block)
+ NegativeExpectationMatcherHandler.handle_matcher(self, matcher, &block)
end
end
diff --git a/vendor/plugins/rspec/lib/spec/expectations/handler.rb b/vendor/plugins/rspec/lib/spec/expectations/handler.rb
index e6dce0846..2e5f2a621 100644
--- a/vendor/plugins/rspec/lib/spec/expectations/handler.rb
+++ b/vendor/plugins/rspec/lib/spec/expectations/handler.rb
@@ -12,6 +12,10 @@ module Spec
class << self
include MatcherHandlerHelper
def handle_matcher(actual, matcher, &block)
+ if :use_operator_matcher == matcher
+ return Spec::Matchers::PositiveOperatorMatcher.new(actual)
+ end
+
unless matcher.respond_to?(:matches?)
raise InvalidMatcherError, "Expected a matcher, got #{matcher.inspect}."
end
@@ -27,6 +31,10 @@ module Spec
class << self
include MatcherHandlerHelper
def handle_matcher(actual, matcher, &block)
+ if :use_operator_matcher == matcher
+ return Spec::Matchers::NegativeOperatorMatcher.new(actual)
+ end
+
unless matcher.respond_to?(:matches?)
raise InvalidMatcherError, "Expected a matcher, got #{matcher.inspect}."
end
diff --git a/vendor/plugins/rspec/lib/spec/extensions.rb b/vendor/plugins/rspec/lib/spec/extensions.rb
index 9a313d0e7..715bb49f2 100755
--- a/vendor/plugins/rspec/lib/spec/extensions.rb
+++ b/vendor/plugins/rspec/lib/spec/extensions.rb
@@ -1,3 +1,4 @@
require 'spec/extensions/object'
require 'spec/extensions/class'
require 'spec/extensions/main'
+require 'spec/extensions/metaclass'
diff --git a/vendor/plugins/rspec/lib/spec/extensions/metaclass.rb b/vendor/plugins/rspec/lib/spec/extensions/metaclass.rb
new file mode 100644
index 000000000..acf9febea
--- /dev/null
+++ b/vendor/plugins/rspec/lib/spec/extensions/metaclass.rb
@@ -0,0 +1,7 @@
+module Spec
+ module MetaClass
+ def metaclass
+ class << self; self; end
+ end
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec/lib/spec/extensions/object.rb b/vendor/plugins/rspec/lib/spec/extensions/object.rb
index e9f6364e2..0b8c26fa2 100755
--- a/vendor/plugins/rspec/lib/spec/extensions/object.rb
+++ b/vendor/plugins/rspec/lib/spec/extensions/object.rb
@@ -3,8 +3,4 @@ class Object
options = Hash === args.last ? args.pop : {}
return args, options
end
-
- def metaclass
- class << self; self; end
- end
end
diff --git a/vendor/plugins/rspec/lib/spec/interop/test.rb b/vendor/plugins/rspec/lib/spec/interop/test.rb
index 5c9543398..afa16137b 100644
--- a/vendor/plugins/rspec/lib/spec/interop/test.rb
+++ b/vendor/plugins/rspec/lib/spec/interop/test.rb
@@ -7,4 +7,6 @@ require 'spec/interop/test/unit/autorunner'
require 'spec/interop/test/unit/testresult'
require 'spec/interop/test/unit/ui/console/testrunner'
-Spec::Example::ExampleGroupFactory.default(Test::Unit::TestCase) \ No newline at end of file
+Spec::Example::ExampleGroupFactory.default(Test::Unit::TestCase)
+
+Test::Unit.run = true
diff --git a/vendor/plugins/rspec/lib/spec/interop/test/unit/ui/console/testrunner.rb b/vendor/plugins/rspec/lib/spec/interop/test/unit/ui/console/testrunner.rb
index 663dd4722..8e9995e02 100644
--- a/vendor/plugins/rspec/lib/spec/interop/test/unit/ui/console/testrunner.rb
+++ b/vendor/plugins/rspec/lib/spec/interop/test/unit/ui/console/testrunner.rb
@@ -36,6 +36,7 @@ module Test
alias_method :finished_without_rspec, :finished
def finished_with_rspec(elapsed_time)
+ @ran_test ||= false
if @ran_test
finished_without_rspec(elapsed_time)
end
diff --git a/vendor/plugins/rspec/lib/spec/matchers/change.rb b/vendor/plugins/rspec/lib/spec/matchers/change.rb
index 784e516ed..8f4ecc187 100644
--- a/vendor/plugins/rspec/lib/spec/matchers/change.rb
+++ b/vendor/plugins/rspec/lib/spec/matchers/change.rb
@@ -114,7 +114,7 @@ EOF
#
# string = "string"
# lambda {
- # string.reverse
+ # string.reverse!
# }.should change { string }.from("string").to("gnirts")
#
# lambda {
diff --git a/vendor/plugins/rspec/lib/spec/matchers/has.rb b/vendor/plugins/rspec/lib/spec/matchers/has.rb
index cc5a250b8..60199f54d 100644
--- a/vendor/plugins/rspec/lib/spec/matchers/has.rb
+++ b/vendor/plugins/rspec/lib/spec/matchers/has.rb
@@ -8,24 +8,14 @@ module Spec
end
def matches?(target)
- @target = target
- begin
- return target.send(predicate, *@args)
- rescue => @error
- # This clause should be empty, but rcov will not report it as covered
- # unless something (anything) is executed within the clause
- rcov_error_report = "http://eigenclass.org/hiki.rb?rcov-0.8.0"
- end
- return false
+ target.send(predicate, *@args)
end
def failure_message
- raise @error if @error
"expected ##{predicate}(#{@args[0].inspect}) to return true, got false"
end
def negative_failure_message
- raise @error if @error
"expected ##{predicate}(#{@args[0].inspect}) to return false, got true"
end
diff --git a/vendor/plugins/rspec/lib/spec/matchers/raise_error.rb b/vendor/plugins/rspec/lib/spec/matchers/raise_error.rb
index b45dcf65c..c003849b6 100644
--- a/vendor/plugins/rspec/lib/spec/matchers/raise_error.rb
+++ b/vendor/plugins/rspec/lib/spec/matchers/raise_error.rb
@@ -1,50 +1,66 @@
module Spec
module Matchers
-
class RaiseError #:nodoc:
- def initialize(error_or_message=Exception, message=nil)
- if String === error_or_message
- @expected_error = Exception
- @expected_message = error_or_message
+ def initialize(error_or_message=Exception, message=nil, &block)
+ @block = block
+ case error_or_message
+ when String, Regexp
+ @expected_error, @expected_message = Exception, error_or_message
else
- @expected_error = error_or_message
- @expected_message = message
+ @expected_error, @expected_message = error_or_message, message
end
end
-
+
def matches?(proc)
@raised_expected_error = false
- @raised_other = false
+ @with_expected_message = false
+ @eval_block = false
+ @eval_block_passed = false
begin
proc.call
rescue @expected_error => @actual_error
- if @expected_message.nil?
- @raised_expected_error = true
- else
- case @expected_message
- when Regexp
- if @expected_message =~ @actual_error.message
- @raised_expected_error = true
- else
- @raised_other = true
- end
- else
- if @expected_message == @actual_error.message
- @raised_expected_error = true
- else
- @raised_other = true
- end
- end
- end
- rescue => @actual_error
- @raised_other = true
- ensure
- return @raised_expected_error
+ @raised_expected_error = true
+ @with_expected_message = verify_message
+ rescue Exception => @actual_error
+ # This clause should be empty, but rcov will not report it as covered
+ # unless something (anything) is executed within the clause
+ rcov_error_report = "http://eigenclass.org/hiki.rb?rcov-0.8.0"
+ end
+
+ unless negative_expectation?
+ eval_block if @raised_expected_error && @with_expected_message && @block
+ end
+ ensure
+ return (@raised_expected_error && @with_expected_message) ? (@eval_block ? @eval_block_passed : true) : false
+ end
+
+ def eval_block
+ @eval_block = true
+ begin
+ @block[@actual_error]
+ @eval_block_passed = true
+ rescue Exception => err
+ @actual_error = err
+ end
+ end
+
+ def verify_message
+ case @expected_message
+ when nil
+ return true
+ when Regexp
+ return @expected_message =~ @actual_error.message
+ else
+ return @expected_message == @actual_error.message
end
end
def failure_message
- return "expected #{expected_error}#{actual_error}" if @raised_other || !@raised_expected_error
+ if @eval_block
+ return @actual_error.message
+ else
+ return "expected #{expected_error}#{actual_error}"
+ end
end
def negative_failure_message
@@ -70,6 +86,11 @@ module Spec
def actual_error
@actual_error.nil? ? " but nothing was raised" : ", got #{@actual_error.inspect}"
end
+
+ def negative_expectation?
+ # YES - I'm a bad person... help me find a better way - ryand
+ caller.first(3).find { |s| s =~ /should_not/ }
+ end
end
# :call-seq:
@@ -77,6 +98,10 @@ module Spec
# should raise_error(NamedError)
# should raise_error(NamedError, String)
# should raise_error(NamedError, Regexp)
+ # should raise_error() { |error| ... }
+ # should raise_error(NamedError) { |error| ... }
+ # should raise_error(NamedError, String) { |error| ... }
+ # should raise_error(NamedError, Regexp) { |error| ... }
# should_not raise_error()
# should_not raise_error(NamedError)
# should_not raise_error(NamedError, String)
@@ -86,11 +111,13 @@ module Spec
# With a named error, matches only if that specific error is raised.
# With a named error and messsage specified as a String, matches only if both match.
# With a named error and messsage specified as a Regexp, matches only if both match.
+ # Pass an optional block to perform extra verifications on the exception matched
#
# == Examples
#
# lambda { do_something_risky }.should raise_error
# lambda { do_something_risky }.should raise_error(PoorRiskDecisionError)
+ # lambda { do_something_risky }.should raise_error(PoorRiskDecisionError) { |error| error.data.should == 42 }
# lambda { do_something_risky }.should raise_error(PoorRiskDecisionError, "that was too risky")
# lambda { do_something_risky }.should raise_error(PoorRiskDecisionError, /oo ri/)
#
@@ -98,8 +125,8 @@ module Spec
# lambda { do_something_risky }.should_not raise_error(PoorRiskDecisionError)
# lambda { do_something_risky }.should_not raise_error(PoorRiskDecisionError, "that was too risky")
# lambda { do_something_risky }.should_not raise_error(PoorRiskDecisionError, /oo ri/)
- def raise_error(error=Exception, message=nil)
- Matchers::RaiseError.new(error, message)
+ def raise_error(error=Exception, message=nil, &block)
+ Matchers::RaiseError.new(error, message, &block)
end
end
end
diff --git a/vendor/plugins/rspec/lib/spec/mocks.rb b/vendor/plugins/rspec/lib/spec/mocks.rb
index 9f9cd215b..678dd6aae 100644
--- a/vendor/plugins/rspec/lib/spec/mocks.rb
+++ b/vendor/plugins/rspec/lib/spec/mocks.rb
@@ -1,3 +1,4 @@
+require 'spec/mocks/framework'
require 'spec/mocks/methods'
require 'spec/mocks/argument_constraint_matchers'
require 'spec/mocks/spec_methods'
@@ -11,7 +12,6 @@ require 'spec/mocks/error_generator'
require 'spec/mocks/extensions/object'
require 'spec/mocks/space'
-
module Spec
# == Mocks and Stubs
#
diff --git a/vendor/plugins/rspec/lib/spec/mocks/argument_constraint_matchers.rb b/vendor/plugins/rspec/lib/spec/mocks/argument_constraint_matchers.rb
index 0e4777082..96ccf0f4a 100644
--- a/vendor/plugins/rspec/lib/spec/mocks/argument_constraint_matchers.rb
+++ b/vendor/plugins/rspec/lib/spec/mocks/argument_constraint_matchers.rb
@@ -1,7 +1,7 @@
module Spec
module Mocks
module ArgumentConstraintMatchers
-
+
# Shortcut for creating an instance of Spec::Mocks::DuckTypeArgConstraint
def duck_type(*args)
DuckTypeArgConstraint.new(*args)
@@ -19,6 +19,10 @@ module Spec
BooleanArgConstraint.new(nil)
end
+ def hash_including(expected={})
+ HashIncludingConstraint.new(expected)
+ end
+
def no_args
NoArgsConstraint.new
end
diff --git a/vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb b/vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb
index 34a1d4d03..b3fdcc80d 100644
--- a/vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb
+++ b/vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb
@@ -108,6 +108,32 @@ module Spec
"duck_type"
end
end
+
+ class HashIncludingConstraint
+ def initialize(expected)
+ @expected = expected
+ end
+
+ def ==(actual)
+ @expected.each do | key, value |
+ # check key for case that value evaluates to nil
+ return false unless actual.has_key?(key) && actual[key] == value
+ end
+ true
+ rescue NoMethodError => ex
+ return false
+ end
+
+ def matches?(value)
+ self == value
+ end
+
+ def description
+ "hash_including(#{@expected.inspect.sub(/^\{/,"").sub(/\}$/,"")})"
+ end
+
+ end
+
class ArgumentExpectation
attr_reader :args
diff --git a/vendor/plugins/rspec/lib/spec/mocks/extensions.rb b/vendor/plugins/rspec/lib/spec/mocks/extensions.rb
new file mode 100644
index 000000000..6fd51a272
--- /dev/null
+++ b/vendor/plugins/rspec/lib/spec/mocks/extensions.rb
@@ -0,0 +1 @@
+require 'spec/mocks/extensions/object'
diff --git a/vendor/plugins/rspec/lib/spec/mocks/framework.rb b/vendor/plugins/rspec/lib/spec/mocks/framework.rb
new file mode 100644
index 000000000..92089673a
--- /dev/null
+++ b/vendor/plugins/rspec/lib/spec/mocks/framework.rb
@@ -0,0 +1,15 @@
+# Require everything except the global extensions of class and object. This
+# supports wrapping rspec's mocking functionality without invading every
+# object in the system.
+
+require 'spec/mocks/methods'
+require 'spec/mocks/argument_constraint_matchers'
+require 'spec/mocks/spec_methods'
+require 'spec/mocks/proxy'
+require 'spec/mocks/mock'
+require 'spec/mocks/argument_expectation'
+require 'spec/mocks/message_expectation'
+require 'spec/mocks/order_group'
+require 'spec/mocks/errors'
+require 'spec/mocks/error_generator'
+require 'spec/mocks/space'
diff --git a/vendor/plugins/rspec/lib/spec/mocks/message_expectation.rb b/vendor/plugins/rspec/lib/spec/mocks/message_expectation.rb
index 6bd2f1c32..0b10290b3 100644
--- a/vendor/plugins/rspec/lib/spec/mocks/message_expectation.rb
+++ b/vendor/plugins/rspec/lib/spec/mocks/message_expectation.rb
@@ -72,12 +72,18 @@ module Spec
end
def invoke(args, block)
+ if @expected_received_count == 0
+ @actual_received_count += 1
+ @error_generator.raise_expectation_error @sym, @expected_received_count, @actual_received_count, *args
+ end
+
@order_group.handle_order_constraint self
begin
Kernel::raise @exception_to_raise unless @exception_to_raise.nil?
Kernel::throw @symbol_to_throw unless @symbol_to_throw.nil?
+
if !@method_block.nil?
default_return_val = invoke_method_block(args)
elsif @args_to_yield.size > 0
@@ -112,12 +118,14 @@ module Spec
if block.nil?
@error_generator.raise_missing_block_error @args_to_yield
end
+ value = nil
@args_to_yield.each do |args_to_yield_this_time|
if block.arity > -1 && args_to_yield_this_time.length != block.arity
@error_generator.raise_wrong_arity_error args_to_yield_this_time, block.arity
end
- block.call(*args_to_yield_this_time)
+ value = block.call(*args_to_yield_this_time)
end
+ value
end
def invoke_consecutive_return_block(args, block)
@@ -147,9 +155,8 @@ module Spec
@sym == sym and not @args_expectation.check_args(args)
end
- def verify_messages_received
- return if ignoring_args? || matches_exact_count? ||
- matches_at_least_count? || matches_at_most_count?
+ def verify_messages_received
+ return if expected_messages_received?
generate_error
rescue Spec::Mocks::MockExpectationError => error
@@ -157,6 +164,11 @@ module Spec
Kernel::raise error
end
+ def expected_messages_received?
+ ignoring_args? || matches_exact_count? ||
+ matches_at_least_count? || matches_at_most_count?
+ end
+
def ignoring_args?
@expected_received_count == :any
end
@@ -173,8 +185,20 @@ module Spec
@expected_received_count == @actual_received_count
end
+ def similar_messages
+ @similar_messages ||= []
+ end
+
+ def advise(args, block)
+ similar_messages << args
+ end
+
def generate_error
- @error_generator.raise_expectation_error(@sym, @expected_received_count, @actual_received_count, *@args_expectation.args)
+ if similar_messages.empty?
+ @error_generator.raise_expectation_error(@sym, @expected_received_count, @actual_received_count, *@args_expectation.args)
+ else
+ @error_generator.raise_unexpected_message_args_error(self, *@similar_messages.first)
+ end
end
def with(*args, &block)
diff --git a/vendor/plugins/rspec/lib/spec/mocks/mock.rb b/vendor/plugins/rspec/lib/spec/mocks/mock.rb
index f029b1b8f..d0b5f204d 100644
--- a/vendor/plugins/rspec/lib/spec/mocks/mock.rb
+++ b/vendor/plugins/rspec/lib/spec/mocks/mock.rb
@@ -3,19 +3,21 @@ module Spec
class Mock
include Methods
- # Creates a new mock with a +name+ (that will be used in error messages only)
- # == Options:
- # * <tt>:null_object</tt> - if true, the mock object acts as a forgiving null object allowing any message to be sent to it.
+ # Creates a new mock with a +name+ (that will be used in error messages
+ # only) == Options:
+ # * <tt>:null_object</tt> - if true, the mock object acts as a forgiving
+ # null object allowing any message to be sent to it.
def initialize(name, stubs_and_options={})
@name = name
@options = parse_options(stubs_and_options)
assign_stubs(stubs_and_options)
end
- # This allows for comparing the mock to other objects that proxy
- # such as ActiveRecords belongs_to proxy objects
- # By making the other object run the comparison, we're sure the call gets delegated to the proxy target
- # This is an unfortunate side effect from ActiveRecord, but this should be safe unless the RHS redefines == in a nonsensical manner
+ # This allows for comparing the mock to other objects that proxy such as
+ # ActiveRecords belongs_to proxy objects By making the other object run
+ # the comparison, we're sure the call gets delegated to the proxy target
+ # This is an unfortunate side effect from ActiveRecord, but this should
+ # be safe unless the RHS redefines == in a nonsensical manner
def ==(other)
other == __mock_proxy
end
diff --git a/vendor/plugins/rspec/lib/spec/mocks/proxy.rb b/vendor/plugins/rspec/lib/spec/mocks/proxy.rb
index 03db3b113..45b96a30b 100644
--- a/vendor/plugins/rspec/lib/spec/mocks/proxy.rb
+++ b/vendor/plugins/rspec/lib/spec/mocks/proxy.rb
@@ -63,10 +63,14 @@ module Spec
def message_received(sym, *args, &block)
if expectation = find_matching_expectation(sym, *args)
expectation.invoke(args, block)
- elsif stub = find_matching_method_stub(sym, *args)
+ elsif (stub = find_matching_method_stub(sym, *args))
+ if expectation = find_almost_matching_expectation(sym, *args)
+ expectation.advise(args, block) unless expectation.expected_messages_received?
+ end
stub.invoke([], block)
elsif expectation = find_almost_matching_expectation(sym, *args)
- raise_unexpected_message_args_error(expectation, *args) unless has_negative_expectation?(sym) unless null_object?
+ expectation.advise(args, block) if null_object? unless expectation.expected_messages_received?
+ raise_unexpected_message_args_error(expectation, *args) unless (has_negative_expectation?(sym) or null_object?)
else
@target.send :method_missing, sym, *args, &block
end
@@ -88,18 +92,20 @@ module Spec
end
def define_expected_method(sym)
- if target_responds_to?(sym) && !metaclass.method_defined?(munge(sym))
+ visibility_string = "#{visibility(sym)} :#{sym}"
+ if target_responds_to?(sym) && !target_metaclass.method_defined?(munge(sym))
munged_sym = munge(sym)
- metaclass.instance_eval do
+ target_metaclass.instance_eval do
alias_method munged_sym, sym if method_defined?(sym.to_s)
end
@proxied_methods << sym
end
- metaclass_eval(<<-EOF, __FILE__, __LINE__)
+ target_metaclass.class_eval(<<-EOF, __FILE__, __LINE__)
def #{sym}(*args, &block)
__mock_proxy.message_received :#{sym}, *args, &block
end
+ #{visibility_string}
EOF
end
@@ -109,6 +115,18 @@ module Spec
return @target.respond_to?(sym)
end
+ def visibility(sym)
+ if Mock === @target
+ 'public'
+ elsif target_metaclass.private_method_defined?(sym)
+ 'private'
+ elsif target_metaclass.protected_method_defined?(sym)
+ 'protected'
+ else
+ 'public'
+ end
+ end
+
def munge(sym)
"proxied_by_rspec__#{sym.to_s}".to_sym
end
@@ -125,12 +143,8 @@ module Spec
@proxied_methods.clear
end
- def metaclass_eval(str, filename, lineno)
- metaclass.class_eval(str, filename, lineno)
- end
-
- def metaclass
- (class << @target; self; end)
+ def target_metaclass
+ class << @target; self; end
end
def verify_expectations
@@ -142,7 +156,7 @@ module Spec
def reset_proxied_methods
@proxied_methods.each do |sym|
munged_sym = munge(sym)
- metaclass.instance_eval do
+ target_metaclass.instance_eval do
if method_defined?(munged_sym.to_s)
alias_method sym, munged_sym
undef_method munged_sym
diff --git a/vendor/plugins/rspec/lib/spec/rake/spectask.rb b/vendor/plugins/rspec/lib/spec/rake/spectask.rb
index c59e226f5..ecf39506d 100644
--- a/vendor/plugins/rspec/lib/spec/rake/spectask.rb
+++ b/vendor/plugins/rspec/lib/spec/rake/spectask.rb
@@ -11,7 +11,7 @@ module Spec
# A Rake task that runs a set of specs.
#
# Example:
- #
+ #
# Spec::Rake::SpecTask.new do |t|
# t.warning = true
# t.rcov = true
@@ -87,7 +87,7 @@ module Spec
# Whether or not to use RCov (default is false)
# See http://eigenclass.org/hiki.rb?rcov
attr_accessor :rcov
-
+
# Array of commandline options to pass to RCov. Defaults to ['--exclude', 'lib\/spec,bin\/spec'].
# Ignored if rcov=false
# Setting the RCOV_OPTS environment variable overrides this.
@@ -117,7 +117,7 @@ module Spec
# used, then the list of spec files is the union of the two.
# Setting the SPEC environment variable overrides this.
attr_accessor :spec_files
-
+
# Use verbose output. If this is set to true, the task will print
# the executed spec command to stdout. Defaults to false.
attr_accessor :verbose
@@ -155,7 +155,7 @@ module Spec
# ruby [ruby_opts] -Ilib -S rcov [rcov_opts] bin/spec -- examples [spec_opts]
# or
# ruby [ruby_opts] -Ilib bin/spec examples [spec_opts]
- cmd = "ruby "
+ cmd = "#{File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])} "
rb_opts = ruby_opts.clone
rb_opts << "-I\"#{lib_path}\""
@@ -210,7 +210,7 @@ module Spec
STDERR.puts "RSPECOPTS is DEPRECATED and will be removed in a future version. Use SPEC_OPTS instead." if ENV['RSPECOPTS']
ENV['SPEC_OPTS'] || ENV['RSPECOPTS'] || spec_opts.join(" ") || ""
end
-
+
def evaluate(o) # :nodoc:
case o
when Proc then o.call
diff --git a/vendor/plugins/rspec/lib/spec/runner.rb b/vendor/plugins/rspec/lib/spec/runner.rb
index 1a9373fee..97ef95bd2 100644
--- a/vendor/plugins/rspec/lib/spec/runner.rb
+++ b/vendor/plugins/rspec/lib/spec/runner.rb
@@ -183,6 +183,20 @@ module Spec
def configure
yield configuration
end
+
+ def register_at_exit_hook # :nodoc:
+ $spec_runner_at_exit_hook_registered ||= nil
+ unless $spec_runner_at_exit_hook_registered
+ at_exit do
+ unless $! || Spec.run?; \
+ success = Spec.run; \
+ exit success if Spec.exit?; \
+ end
+ end
+ $spec_runner_at_exit_hook_registered = true
+ end
+ end
+
end
end
end
diff --git a/vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb b/vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
index 5fd2fb99f..587e57d90 100644
--- a/vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
+++ b/vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
@@ -27,7 +27,7 @@ module Spec
/\/lib\/ruby\//,
/bin\/spec:/,
/bin\/rcov:/,
- /lib\/rspec_on_rails/,
+ /lib\/rspec-rails/,
/vendor\/rails/,
# TextMate's Ruby and RSpec plugins
/Ruby\.tmbundle\/Support\/tmruby.rb:/,
diff --git a/vendor/plugins/rspec/lib/spec/runner/formatter/base_formatter.rb b/vendor/plugins/rspec/lib/spec/runner/formatter/base_formatter.rb
index c8647cf50..a1269b513 100644
--- a/vendor/plugins/rspec/lib/spec/runner/formatter/base_formatter.rb
+++ b/vendor/plugins/rspec/lib/spec/runner/formatter/base_formatter.rb
@@ -19,8 +19,7 @@ module Spec
end
# This method is invoked at the beginning of the execution of each example_group.
- # +name+ is the name of the example_group and +first+ is true if it is the
- # first example_group - otherwise it's false.
+ # +example_group+ is the example_group.
#
# The next method to be invoked after this is #example_failed or #example_finished
def add_example_group(example_group)
@@ -46,7 +45,7 @@ module Spec
# been provided a block), or when an ExamplePendingError is raised.
# +message+ is the message from the ExamplePendingError, if it exists, or the
# default value of "Not Yet Implemented"
- def example_pending(example_group_description, example, message)
+ def example_pending(example, message)
end
# This method is invoked after all of the examples have executed. The next method
diff --git a/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb b/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb
index 859b2641d..bad023db7 100644
--- a/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb
+++ b/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb
@@ -26,8 +26,8 @@ module Spec
@pending_examples = []
end
- def example_pending(example_group_description, example, message)
- @pending_examples << ["#{example_group_description} #{example.description}", message]
+ def example_pending(example, message)
+ @pending_examples << [example.__full_description, message]
end
def dump_failure(counter, failure)
diff --git a/vendor/plugins/rspec/lib/spec/runner/formatter/failing_example_groups_formatter.rb b/vendor/plugins/rspec/lib/spec/runner/formatter/failing_example_groups_formatter.rb
index 5a4607983..8d39bc572 100644
--- a/vendor/plugins/rspec/lib/spec/runner/formatter/failing_example_groups_formatter.rb
+++ b/vendor/plugins/rspec/lib/spec/runner/formatter/failing_example_groups_formatter.rb
@@ -4,19 +4,15 @@ module Spec
module Runner
module Formatter
class FailingExampleGroupsFormatter < BaseTextFormatter
- def add_example_group(example_group)
- super
- @example_group_description_parts = example_group.description_parts
- end
-
def example_failed(example, counter, failure)
- if @example_group_description_parts
- description_parts = @example_group_description_parts.collect do |description|
+ if @example_group
+ description_parts = @example_group.description_parts.collect do |description|
description =~ /(.*) \(druby.*\)$/ ? $1 : description
end
@output.puts ::Spec::Example::ExampleGroupMethods.description_text(*description_parts)
+
@output.flush
- @example_group_description_parts = nil
+ @example_group = nil
end
end
diff --git a/vendor/plugins/rspec/lib/spec/runner/formatter/html_formatter.rb b/vendor/plugins/rspec/lib/spec/runner/formatter/html_formatter.rb
index ad153c8dc..e5368f2cb 100644
--- a/vendor/plugins/rspec/lib/spec/runner/formatter/html_formatter.rb
+++ b/vendor/plugins/rspec/lib/spec/runner/formatter/html_formatter.rb
@@ -9,18 +9,22 @@ module Spec
def initialize(options, output)
super
- @current_example_group_number = 0
- @current_example_number = 0
+ @example_group_number = 0
+ @example_number = 0
+ end
+
+ def method_missing(sym, *args)
+ # no-op
end
# The number of the currently running example_group
- def current_example_group_number
- @current_example_group_number
+ def example_group_number
+ @example_group_number
end
# The number of the currently running example (a global counter)
- def current_example_number
- @current_example_number
+ def example_number
+ @example_number
end
def start(example_count)
@@ -35,14 +39,14 @@ module Spec
super
@example_group_red = false
@example_group_red = false
- @current_example_group_number += 1
- unless current_example_group_number == 1
+ @example_group_number += 1
+ unless example_group_number == 1
@output.puts " </dl>"
@output.puts "</div>"
end
@output.puts "<div class=\"example_group\">"
@output.puts " <dl>"
- @output.puts " <dt id=\"example_group_#{current_example_group_number}\">#{h(example_group.description)}</dt>"
+ @output.puts " <dt id=\"example_group_#{example_group_number}\">#{h(example_group.description)}</dt>"
@output.flush
end
@@ -53,7 +57,7 @@ module Spec
end
def example_started(example)
- @current_example_number += 1
+ @example_number += 1
end
def example_passed(example)
@@ -67,7 +71,7 @@ module Spec
failure_style = failure.pending_fixed? ? 'pending_fixed' : 'failed'
@output.puts " <script type=\"text/javascript\">makeRed('rspec-header');</script>" unless @header_red
@header_red = true
- @output.puts " <script type=\"text/javascript\">makeRed('example_group_#{current_example_group_number}');</script>" unless @example_group_red
+ @output.puts " <script type=\"text/javascript\">makeRed('example_group_#{example_group_number}');</script>" unless @example_group_red
@example_group_red = true
move_progress
@output.puts " <dd class=\"spec #{failure_style}\">"
@@ -81,9 +85,9 @@ module Spec
@output.flush
end
- def example_pending(example_group_description, example, message)
+ def example_pending(example, message)
@output.puts " <script type=\"text/javascript\">makeYellow('rspec-header');</script>" unless @header_red
- @output.puts " <script type=\"text/javascript\">makeYellow('example_group_#{current_example_group_number}');</script>" unless @example_group_red
+ @output.puts " <script type=\"text/javascript\">makeYellow('example_group_#{example_group_number}');</script>" unless @example_group_red
move_progress
@output.puts " <dd class=\"spec not_implemented\"><span class=\"not_implemented_spec_name\">#{h(example.description)} (PENDING: #{h(message)})</span></dd>"
@output.flush
@@ -106,7 +110,7 @@ module Spec
def percent_done
result = 100.0
if @example_count != 0
- result = ((current_example_number).to_f / @example_count.to_f * 1000).to_i / 10.0
+ result = ((example_number).to_f / @example_count.to_f * 1000).to_i / 10.0
end
result
end
diff --git a/vendor/plugins/rspec/lib/spec/runner/formatter/nested_text_formatter.rb b/vendor/plugins/rspec/lib/spec/runner/formatter/nested_text_formatter.rb
new file mode 100644
index 000000000..f9aa5f67c
--- /dev/null
+++ b/vendor/plugins/rspec/lib/spec/runner/formatter/nested_text_formatter.rb
@@ -0,0 +1,65 @@
+require 'spec/runner/formatter/base_text_formatter'
+
+module Spec
+ module Runner
+ module Formatter
+ class NestedTextFormatter < BaseTextFormatter
+ attr_reader :previous_nested_example_groups
+ def initialize(options, where)
+ super
+ @previous_nested_example_groups = []
+ end
+
+ def add_example_group(example_group)
+ super
+
+ current_nested_example_groups = described_example_group_chain
+ current_nested_example_groups.each_with_index do |nested_example_group, i|
+ unless nested_example_group == previous_nested_example_groups[i]
+ output.puts "#{' ' * i}#{nested_example_group.description_args}"
+ end
+ end
+
+ @previous_nested_example_groups = described_example_group_chain
+ end
+
+ def example_failed(example, counter, failure)
+ message = if failure.expectation_not_met?
+ "#{current_indentation}#{example.description} (FAILED - #{counter})"
+ else
+ "#{current_indentation}#{example.description} (ERROR - #{counter})"
+ end
+
+ output.puts(failure.expectation_not_met? ? red(message) : magenta(message))
+ output.flush
+ end
+
+ def example_passed(example)
+ message = "#{current_indentation}#{example.description}"
+ output.puts green(message)
+ output.flush
+ end
+
+ def example_pending(example, message)
+ super
+ output.puts yellow("#{current_indentation}#{example.description} (PENDING: #{message})")
+ output.flush
+ end
+
+ def current_indentation
+ ' ' * previous_nested_example_groups.length
+ end
+
+ def described_example_group_chain
+ example_group_chain = []
+ example_group.send(:execute_in_class_hierarchy) do |parent_example_group|
+ if parent_example_group.description_args && !parent_example_group.description_args.empty?
+ example_group_chain << parent_example_group
+ end
+ end
+ example_group_chain
+ end
+ end
+ end
+ end
+end
diff --git a/vendor/plugins/rspec/lib/spec/runner/formatter/profile_formatter.rb b/vendor/plugins/rspec/lib/spec/runner/formatter/profile_formatter.rb
index 3784f3ac7..8671d721e 100644
--- a/vendor/plugins/rspec/lib/spec/runner/formatter/profile_formatter.rb
+++ b/vendor/plugins/rspec/lib/spec/runner/formatter/profile_formatter.rb
@@ -41,6 +41,10 @@ module Spec
end
@output.flush
end
+
+ def method_missing(sym, *args)
+ # ignore
+ end
end
end
end
diff --git a/vendor/plugins/rspec/lib/spec/runner/formatter/progress_bar_formatter.rb b/vendor/plugins/rspec/lib/spec/runner/formatter/progress_bar_formatter.rb
index 8d0e50432..032a2872d 100644
--- a/vendor/plugins/rspec/lib/spec/runner/formatter/progress_bar_formatter.rb
+++ b/vendor/plugins/rspec/lib/spec/runner/formatter/progress_bar_formatter.rb
@@ -14,7 +14,7 @@ module Spec
@output.flush
end
- def example_pending(example_group_description, example, message)
+ def example_pending(example, message)
super
@output.print yellow('P')
@output.flush
@@ -24,6 +24,10 @@ module Spec
@output.puts
@output.flush
end
+
+ def method_missing(sym, *args)
+ # ignore
+ end
end
end
end
diff --git a/vendor/plugins/rspec/lib/spec/runner/formatter/specdoc_formatter.rb b/vendor/plugins/rspec/lib/spec/runner/formatter/specdoc_formatter.rb
index f426dc948..facf1a65a 100644
--- a/vendor/plugins/rspec/lib/spec/runner/formatter/specdoc_formatter.rb
+++ b/vendor/plugins/rspec/lib/spec/runner/formatter/specdoc_formatter.rb
@@ -28,7 +28,7 @@ module Spec
output.flush
end
- def example_pending(example_group_description, example, message)
+ def example_pending(example, message)
super
output.puts yellow("- #{example.description} (PENDING: #{message})")
output.flush
diff --git a/vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb b/vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb
index b70ac153a..5a8134683 100644
--- a/vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb
+++ b/vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb
@@ -98,6 +98,9 @@ EOF
scenario_ended
end
+ def step_upcoming(type, description, *args)
+ end
+
def step_succeeded(type, description, *args)
print_step('passed', type, description, *args) # TODO: uses succeeded CSS class
end
diff --git a/vendor/plugins/rspec/lib/spec/runner/formatter/story/plain_text_formatter.rb b/vendor/plugins/rspec/lib/spec/runner/formatter/story/plain_text_formatter.rb
index 424e27cc6..31cd614cb 100644
--- a/vendor/plugins/rspec/lib/spec/runner/formatter/story/plain_text_formatter.rb
+++ b/vendor/plugins/rspec/lib/spec/runner/formatter/story/plain_text_formatter.rb
@@ -38,6 +38,7 @@ module Spec
@scenario_already_failed = false
@output.print "\n\n Scenario: #{scenario_name}"
@scenario_ok = true
+ @scenario_pending = false
end
def scenario_succeeded(story_title, scenario_name)
@@ -52,6 +53,7 @@ module Spec
def scenario_pending(story_title, scenario_name, msg)
@pending_scenario_count += 1 unless @scenario_already_failed
+ @scenario_pending = true
@scenario_already_failed = true
end
@@ -76,21 +78,29 @@ module Spec
end
end
end
-
+
+ def step_upcoming(type, description, *args)
+ end
+
def step_succeeded(type, description, *args)
- found_step(type, description, false, *args)
+ found_step(type, description, false, false, *args)
end
def step_pending(type, description, *args)
- found_step(type, description, false, *args)
+ found_step(type, description, false, true, *args)
@pending_steps << [@current_story_title, @current_scenario_name, description]
- @output.print " (PENDING)"
+ @output.print yellow(" (PENDING)")
+ @scenario_pending = true
@scenario_ok = false
end
def step_failed(type, description, *args)
- found_step(type, description, true, *args)
- @output.print red(@scenario_ok ? " (FAILED)" : " (SKIPPED)")
+ found_step(type, description, true, @scenario_pending, *args)
+ if @scenario_pending
+ @output.print yellow(" (SKIPPED)")
+ else
+ @output.print red(@scenario_ok ? " (FAILED)" : " (SKIPPED)")
+ end
@scenario_ok = false
end
@@ -103,7 +113,7 @@ module Spec
private
- def found_step(type, description, failed, *args)
+ def found_step(type, description, failed, pending, *args)
desc_string = description.step_name
arg_regexp = description.arg_regexp
text = if(type == @previous_type)
@@ -113,7 +123,11 @@ module Spec
end
i = -1
text << desc_string.gsub(arg_regexp) { |param| args[i+=1] }
- @output.print(failed ? red(text) : green(text))
+ if pending
+ @output.print yellow(text)
+ else
+ @output.print(failed ? red(text) : green(text))
+ end
if type == :'given scenario'
@previous_type = :given
diff --git a/vendor/plugins/rspec/lib/spec/runner/option_parser.rb b/vendor/plugins/rspec/lib/spec/runner/option_parser.rb
index 09cedccac..91525e089 100644
--- a/vendor/plugins/rspec/lib/spec/runner/option_parser.rb
+++ b/vendor/plugins/rspec/lib/spec/runner/option_parser.rb
@@ -15,7 +15,11 @@ module Spec
attr_reader :options
OPTIONS = {
- :diff => ["-D", "--diff [FORMAT]", "Show diff of objects that are expected to be equal when they are not",
+ :pattern => ["-p", "--pattern [PATTERN]","Limit files loaded to those matching this pattern. Defaults to '**/*_spec.rb'",
+ "Separate multiple patterns with commas.",
+ "Applies only to directories named on the command line (files",
+ "named explicitly on the command line will be loaded regardless)."],
+ :diff => ["-D", "--diff [FORMAT]","Show diff of objects that are expected to be equal when they are not",
"Builtin formats: unified|u|context|c",
"You can also specify a custom differ class",
"(in which case you should also specify --require)"],
@@ -32,7 +36,7 @@ module Spec
:specification => ["-s", "--specification [NAME]", "DEPRECATED - use -e instead", "(This will be removed when autotest works with -e)"],
:line => ["-l", "--line LINE_NUMBER", Integer, "Execute behaviout or specification at given line.",
"(does not work for dynamically generated specs)"],
- :format => ["-f", "--format FORMAT[:WHERE]", "Specifies what format to use for output. Specify WHERE to tell",
+ :format => ["-f", "--format FORMAT[:WHERE]","Specifies what format to use for output. Specify WHERE to tell",
"the formatter where to write the output. All built-in formats",
"expect WHERE to be a file name, and will write to STDOUT if it's",
"not specified. The --format option may be specified several times",
@@ -42,6 +46,7 @@ module Spec
"progress|p : Text progress",
"profile|o : Text progress with profiling of 10 slowest examples",
"specdoc|s : Example doc as text",
+ "indented|i : Example doc as indented text",
"html|h : A nice HTML report",
"failing_examples|e : Write all failing examples - input for --example",
"failing_example_groups|g : Write all failing example groups - input for --example",
@@ -53,13 +58,13 @@ module Spec
"FORMAT can also be the name of a custom formatter class",
"(in which case you should also specify --require to load it)"],
:require => ["-r", "--require FILE", "Require FILE before running specs",
- "Useful for loading custom formatters or other extensions.",
- "If this option is used it must come before the others"],
+ "Useful for loading custom formatters or other extensions.",
+ "If this option is used it must come before the others"],
:backtrace => ["-b", "--backtrace", "Output full backtrace"],
:loadby => ["-L", "--loadby STRATEGY", "Specify the strategy by which spec files should be loaded.",
- "STRATEGY can currently only be 'mtime' (File modification time)",
- "By default, spec files are loaded in alphabetical order if --loadby",
- "is not specified."],
+ "STRATEGY can currently only be 'mtime' (File modification time)",
+ "By default, spec files are loaded in alphabetical order if --loadby",
+ "is not specified."],
:reverse => ["-R", "--reverse", "Run examples in reverse order"],
:timeout => ["-t", "--timeout FLOAT", "Interrupt and fail each example that doesn't complete in the",
"specified time"],
@@ -84,11 +89,11 @@ module Spec
@out_stream = out
@options = Options.new(@error_stream, @out_stream)
- @spec_parser = SpecParser.new
@file_factory = File
self.banner = "Usage: spec (FILE|DIRECTORY|GLOB)+ [options]"
self.separator ""
+ on(*OPTIONS[:pattern]) {|pattern| @options.filename_pattern = pattern}
on(*OPTIONS[:diff]) {|diff| @options.parse_diff(diff)}
on(*OPTIONS[:colour]) {@options.colour = true}
on(*OPTIONS[:example]) {|example| @options.parse_example(example)}
@@ -103,11 +108,8 @@ module Spec
on(*OPTIONS[:heckle]) {|heckle| @options.load_heckle_runner(heckle)}
on(*OPTIONS[:dry_run]) {@options.dry_run = true}
on(*OPTIONS[:options_file]) {|options_file| parse_options_file(options_file)}
- on(*OPTIONS[:generate_options]) do |options_file|
- end
- on(*OPTIONS[:runner]) do |runner|
- @options.user_input_for_runner = runner
- end
+ on(*OPTIONS[:generate_options]) {|options_file|}
+ on(*OPTIONS[:runner]) {|runner| @options.user_input_for_runner = runner}
on(*OPTIONS[:drb]) {}
on(*OPTIONS[:version]) {parse_version}
on_tail(*OPTIONS[:help]) {parse_help}
@@ -124,10 +126,6 @@ module Spec
blk.call(file) if blk
end
- if @options.line_number
- set_spec_from_line_number
- end
-
@options
end
@@ -141,6 +139,10 @@ module Spec
def parse_options_file(options_file)
option_file_args = IO.readlines(options_file).map {|l| l.chomp.split " "}.flatten
@argv.push(*option_file_args)
+ # TODO - this is a brute force solution to http://rspec.lighthouseapp.com/projects/5645/tickets/293.
+ # Let's look for a cleaner way. Might not be one. But let's look. If not, perhaps
+ # this can be moved to a different method to indicate the special handling for drb?
+ parse_drb(@argv)
end
def parse_generate_options
@@ -170,12 +172,12 @@ module Spec
@options.examples_should_not_be_run
end
- def parse_drb
+ def parse_drb(argv = nil)
+ argv ||= @options.argv # TODO - see note about about http://rspec.lighthouseapp.com/projects/5645/tickets/293
is_drb = false
- argv = @options.argv
is_drb ||= argv.delete(OPTIONS[:drb][0])
is_drb ||= argv.delete(OPTIONS[:drb][1])
- return nil unless is_drb
+ return false unless is_drb
@options.examples_should_not_be_run
DrbCommandLine.run(
self.class.parse(argv, @error_stream, @out_stream)
@@ -193,37 +195,9 @@ module Spec
exit if stdout?
end
- def set_spec_from_line_number
- if @options.examples.empty?
- if @options.files.length == 1
- if @file_factory.file?(@options.files[0])
- source = @file_factory.open(@options.files[0])
- example = @spec_parser.spec_name_for(source, @options.line_number)
- @options.parse_example(example)
- elsif @file_factory.directory?(@options.files[0])
- @error_stream.puts "You must specify one file, not a directory when using the --line option"
- exit(1) if stderr?
- else
- @error_stream.puts "#{@options.files[0]} does not exist"
- exit(2) if stderr?
- end
- else
- @error_stream.puts "Only one file can be specified when using the --line option: #{@options.files.inspect}"
- exit(3) if stderr?
- end
- else
- @error_stream.puts "You cannot use both --line and --example"
- exit(4) if stderr?
- end
- end
-
def stdout?
@out_stream == $stdout
end
-
- def stderr?
- @error_stream == $stderr
- end
end
end
end
diff --git a/vendor/plugins/rspec/lib/spec/runner/options.rb b/vendor/plugins/rspec/lib/spec/runner/options.rb
index a5a07548d..6716464af 100644
--- a/vendor/plugins/rspec/lib/spec/runner/options.rb
+++ b/vendor/plugins/rspec/lib/spec/runner/options.rb
@@ -8,6 +8,8 @@ module Spec
EXAMPLE_FORMATTERS = { # Load these lazily for better speed
'specdoc' => ['spec/runner/formatter/specdoc_formatter', 'Formatter::SpecdocFormatter'],
's' => ['spec/runner/formatter/specdoc_formatter', 'Formatter::SpecdocFormatter'],
+ 'nested' => ['spec/runner/formatter/nested_text_formatter', 'Formatter::NestedTextFormatter'],
+ 'n' => ['spec/runner/formatter/nested_text_formatter', 'Formatter::NestedTextFormatter'],
'html' => ['spec/runner/formatter/html_formatter', 'Formatter::HtmlFormatter'],
'h' => ['spec/runner/formatter/html_formatter', 'Formatter::HtmlFormatter'],
'progress' => ['spec/runner/formatter/progress_bar_formatter', 'Formatter::ProgressBarFormatter'],
@@ -29,6 +31,7 @@ module Spec
}
attr_accessor(
+ :filename_pattern,
:backtrace_tweaker,
:context_lines,
:diff_format,
@@ -45,6 +48,8 @@ module Spec
:user_input_for_runner,
:error_stream,
:output_stream,
+ :before_suite_parts,
+ :after_suite_parts,
# TODO: BT - Figure out a better name
:argv
)
@@ -53,6 +58,7 @@ module Spec
def initialize(error_stream, output_stream)
@error_stream = error_stream
@output_stream = output_stream
+ @filename_pattern = "**/*_spec.rb"
@backtrace_tweaker = QuietBacktraceTweaker.new
@examples = []
@colour = false
@@ -63,9 +69,12 @@ module Spec
@diff_format = :unified
@files = []
@example_groups = []
+ @result = nil
@examples_run = false
@examples_should_be_run = nil
@user_input_for_runner = nil
+ @before_suite_parts = []
+ @after_suite_parts = []
end
def add_example_group(example_group)
@@ -78,16 +87,31 @@ module Spec
def run_examples
return true unless examples_should_be_run?
- runner = custom_runner || ExampleGroupRunner.new(self)
+ success = true
+ begin
+ before_suite_parts.each do |part|
+ part.call
+ end
+ runner = custom_runner || ExampleGroupRunner.new(self)
- runner.load_files(files_to_load)
- if example_groups.empty?
- true
- else
- success = runner.run
- @examples_run = true
- heckle if heckle_runner
- success
+ unless @files_loaded
+ runner.load_files(files_to_load)
+ @files_loaded = true
+ end
+
+ if example_groups.empty?
+ true
+ else
+ set_spec_from_line_number if line_number
+ success = runner.run
+ @examples_run = true
+ heckle if heckle_runner
+ success
+ end
+ ensure
+ after_suite_parts.each do |part|
+ part.call(success)
+ end
end
end
@@ -101,10 +125,14 @@ module Spec
def colour=(colour)
@colour = colour
- begin; \
- require 'Win32/Console/ANSI' if @colour && PLATFORM =~ /win32/; \
- rescue LoadError ; \
- raise "You must gem install win32console to use colour on Windows" ; \
+ if @colour && RUBY_PLATFORM =~ /win32/ ;\
+ begin ;\
+ require 'rubygems' ;\
+ require 'Win32/Console/ANSI' ;\
+ rescue LoadError ;\
+ warn "You must 'gem install win32console' to use colour on Windows" ;\
+ @colour = false ;\
+ end
end
end
@@ -170,11 +198,29 @@ module Spec
end
def number_of_examples
- @example_groups.inject(0) do |sum, example_group|
- sum + example_group.number_of_examples
+ total = 0
+ @example_groups.each do |example_group|
+ total += example_group.number_of_examples
end
+ total
end
+ def files_to_load
+ result = []
+ sorted_files.each do |file|
+ if File.directory?(file)
+ filename_pattern.split(",").each do |pattern|
+ result += Dir[File.expand_path("#{file}/#{pattern.strip}")]
+ end
+ elsif File.file?(file)
+ result << file
+ else
+ raise "File or directory not found: #{file}"
+ end
+ end
+ result
+ end
+
protected
def examples_should_be_run?
return @examples_should_be_run unless @examples_should_be_run.nil?
@@ -205,20 +251,6 @@ module Spec
end
end
- def files_to_load
- result = []
- sorted_files.each do |file|
- if test ?d, file
- result += Dir[File.expand_path("#{file}/**/*.rb")]
- elsif test ?f, file
- result << file
- else
- raise "File or directory not found: #{file}"
- end
- end
- result
- end
-
def custom_runner
return nil unless custom_runner?
klass_name, arg = ClassAndArgumentsParser.parse(user_input_for_runner)
@@ -231,9 +263,9 @@ module Spec
end
def heckle
- returns = self.heckle_runner.heckle_with
+ heckle_runner = self.heckle_runner
self.heckle_runner = nil
- returns
+ heckle_runner.heckle_with
end
def sorted_files
@@ -248,6 +280,30 @@ module Spec
require 'spec/expectations/differs/default'
self.differ_class = Spec::Expectations::Differs::Default
end
+
+ def set_spec_from_line_number
+ if examples.empty?
+ if files.length == 1
+ if File.directory?(files[0])
+ error_stream.puts "You must specify one file, not a directory when using the --line option"
+ exit(1) if stderr?
+ else
+ example = SpecParser.new.spec_name_for(files[0], line_number)
+ @examples = [example]
+ end
+ else
+ error_stream.puts "Only one file can be specified when using the --line option: #{files.inspect}"
+ exit(3) if stderr?
+ end
+ else
+ error_stream.puts "You cannot use both --line and --example"
+ exit(4) if stderr?
+ end
+ end
+
+ def stderr?
+ @error_stream == $stderr
+ end
end
end
end
diff --git a/vendor/plugins/rspec/lib/spec/runner/reporter.rb b/vendor/plugins/rspec/lib/spec/runner/reporter.rb
index cfc511baf..66db38406 100644
--- a/vendor/plugins/rspec/lib/spec/runner/reporter.rb
+++ b/vendor/plugins/rspec/lib/spec/runner/reporter.rb
@@ -26,7 +26,7 @@ module Spec
if error.nil?
example_passed(example)
elsif Spec::Example::ExamplePendingError === error
- example_pending(example_groups.last, example, error.message)
+ example_pending(example, error.message)
else
example_failed(example, error)
end
@@ -34,8 +34,7 @@ module Spec
def failure(example, error)
backtrace_tweaker.tweak_backtrace(error)
- example_name = "#{example_groups.last.description} #{example.description}"
- failure = Failure.new(example_name, error)
+ failure = Failure.new(example, error)
@failures << failure
formatters.each do |f|
f.example_failed(example, @failures.length, failure)
@@ -91,6 +90,7 @@ module Spec
index + 1
end
end
+
def dump_pending
formatters.each{|f| f.dump_pending}
end
@@ -104,28 +104,28 @@ module Spec
formatters.each{|f| f.example_passed(example)}
end
- def example_pending(example_group, example, message="Not Yet Implemented")
+ def example_pending(example, message="Not Yet Implemented")
@pending_count += 1
formatters.each do |f|
- f.example_pending(example_group.description, example, message)
+ f.example_pending(example, message)
end
end
class Failure
- attr_reader :exception
+ attr_reader :example, :exception
- def initialize(example_name, exception)
- @example_name = example_name
+ def initialize(example, exception)
+ @example = example
@exception = exception
end
def header
if expectation_not_met?
- "'#{@example_name}' FAILED"
+ "'#{example_name}' FAILED"
elsif pending_fixed?
- "'#{@example_name}' FIXED"
+ "'#{example_name}' FIXED"
else
- "#{@exception.class.name} in '#{@example_name}'"
+ "#{@exception.class.name} in '#{example_name}'"
end
end
@@ -137,6 +137,10 @@ module Spec
@exception.is_a?(Spec::Expectations::ExpectationNotMetError)
end
+ protected
+ def example_name
+ @example.__full_description
+ end
end
end
end
diff --git a/vendor/plugins/rspec/lib/spec/runner/spec_parser.rb b/vendor/plugins/rspec/lib/spec/runner/spec_parser.rb
index 5ce51e3b2..8beb384e9 100644
--- a/vendor/plugins/rspec/lib/spec/runner/spec_parser.rb
+++ b/vendor/plugins/rspec/lib/spec/runner/spec_parser.rb
@@ -2,14 +2,28 @@ module Spec
module Runner
# Parses a spec file and finds the nearest example for a given line number.
class SpecParser
- def spec_name_for(io, line_number)
- source = io.read
- example_group, example_group_line = example_group_at_line(source, line_number)
- example, example_line = example_at_line(source, line_number)
- if example_group && example && (example_group_line < example_line)
- "#{example_group} #{example}"
- elsif example_group
- example_group
+ attr_reader :best_match
+
+ def initialize
+ @best_match = {}
+ end
+
+ def spec_name_for(file, line_number)
+ best_match.clear
+ file = File.expand_path(file)
+ rspec_options.example_groups.each do |example_group|
+ consider_example_groups_for_best_match example_group, file, line_number
+
+ example_group.examples.each do |example|
+ consider_example_for_best_match example, example_group, file, line_number
+ end
+ end
+ if best_match[:example_group]
+ if best_match[:example]
+ "#{best_match[:example_group].description} #{best_match[:example].description}"
+ else
+ best_match[:example_group].description
+ end
else
nil
end
@@ -17,36 +31,40 @@ module Spec
protected
- def example_group_at_line(source, line_number)
- find_above(source, line_number, /^\s*(context|describe)\s+(.*)\s+do/)
- end
-
- def example_at_line(source, line_number)
- find_above(source, line_number, /^\s*(specify|it)\s+(.*)\s+do/)
+ def consider_example_groups_for_best_match(example_group, file, line_number)
+ parsed_backtrace = parse_backtrace(example_group.registration_backtrace)
+ parsed_backtrace.each do |example_file, example_line|
+ if is_best_match?(file, line_number, example_file, example_line)
+ best_match.clear
+ best_match[:example_group] = example_group
+ best_match[:line] = example_line
+ end
+ end
end
- # Returns the context/describe or specify/it name and the line number
- def find_above(source, line_number, pattern)
- lines_above_reversed(source, line_number).each_with_index do |line, n|
- return [parse_description($2), line_number-n] if line =~ pattern
+ def consider_example_for_best_match(example, example_group, file, line_number)
+ parsed_backtrace = parse_backtrace(example.implementation_backtrace)
+ parsed_backtrace.each do |example_file, example_line|
+ if is_best_match?(file, line_number, example_file, example_line)
+ best_match.clear
+ best_match[:example_group] = example_group
+ best_match[:example] = example
+ best_match[:line] = example_line
+ end
end
- nil
end
- def lines_above_reversed(source, line_number)
- lines = source.split("\n")
- lines[0...line_number].reverse
+ def is_best_match?(file, line_number, example_file, example_line)
+ file == File.expand_path(example_file) &&
+ example_line <= line_number &&
+ example_line > best_match[:line].to_i
end
-
- def parse_description(str)
- return str[1..-2] if str =~ /^['"].*['"]$/
- if matches = /^['"](.*)['"](,.*)?$/.match(str)
- return ::Spec::Example::ExampleGroupMethods.description_text(matches[1])
- end
- if matches = /^(.*)\s*,\s*['"](.*)['"](,.*)?$/.match(str)
- return ::Spec::Example::ExampleGroupMethods.description_text(matches[1], matches[2])
+
+ def parse_backtrace(backtrace)
+ backtrace.collect do |trace_line|
+ split_line = trace_line.split(':')
+ [split_line[0], Integer(split_line[1])]
end
- return str
end
end
end
diff --git a/vendor/plugins/rspec/lib/spec/story/extensions/regexp.rb b/vendor/plugins/rspec/lib/spec/story/extensions/regexp.rb
index 7955b4c33..8ee338605 100644
--- a/vendor/plugins/rspec/lib/spec/story/extensions/regexp.rb
+++ b/vendor/plugins/rspec/lib/spec/story/extensions/regexp.rb
@@ -1,9 +1,9 @@
class Regexp
def step_name
- self.source
+ self.source.gsub '\\$', '$$'
end
def arg_regexp
::Spec::Story::Step::PARAM_OR_GROUP_PATTERN
end
-end \ No newline at end of file
+end
diff --git a/vendor/plugins/rspec/lib/spec/story/extensions/string.rb b/vendor/plugins/rspec/lib/spec/story/extensions/string.rb
index 896578def..0e4ec1d68 100644
--- a/vendor/plugins/rspec/lib/spec/story/extensions/string.rb
+++ b/vendor/plugins/rspec/lib/spec/story/extensions/string.rb
@@ -4,6 +4,6 @@ class String
end
def arg_regexp
- ::Spec::Story::Step::PARAM_PATTERN
+ ::Spec::Story::Step::PARAM_OR_GROUP_PATTERN
end
-end \ No newline at end of file
+end
diff --git a/vendor/plugins/rspec/lib/spec/story/runner.rb b/vendor/plugins/rspec/lib/spec/story/runner.rb
index 2dd36fbc6..3d7ed59b5 100644
--- a/vendor/plugins/rspec/lib/spec/story/runner.rb
+++ b/vendor/plugins/rspec/lib/spec/story/runner.rb
@@ -10,16 +10,17 @@ module Spec
module Runner
class << self
def run_options # :nodoc:
- @run_options ||= ::Spec::Runner::OptionParser.parse(ARGV, $stderr, $stdout)
+ rspec_options
+ # @run_options ||= ::Spec::Runner::OptionParser.parse(ARGV, $stderr, $stdout)
end
def story_runner # :nodoc:
unless @story_runner
- @story_runner = StoryRunner.new(scenario_runner, world_creator)
+ @story_runner = create_story_runner
run_options.story_formatters.each do |formatter|
register_listener(formatter)
end
- Runner.register_exit_hook
+ self.register_exit_hook
end
@story_runner
end
@@ -32,6 +33,10 @@ module Spec
@world_creator ||= World
end
+ def create_story_runner
+ StoryRunner.new(scenario_runner, world_creator)
+ end
+
# Use this to register a customer output formatter.
def register_listener(listener)
story_runner.add_listener(listener) # run_started, story_started, story_ended, #run_ended
@@ -40,12 +45,9 @@ module Spec
end
def register_exit_hook # :nodoc:
- # TODO - when story runner uses test/unit runners like example runner does we can kill
- # this and also the assorted Kernel.stub!(:at_exit) in examples
at_exit do
- Runner.story_runner.run_stories unless $!
+ exit Runner.story_runner.run_stories unless $!
end
- # TODO exit with non-zero status if run fails
end
def dry_run
diff --git a/vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb b/vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
index 8d34ea2d2..a1bfbda4f 100644
--- a/vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
+++ b/vendor/plugins/rspec/lib/spec/story/runner/plain_text_story_runner.rb
@@ -26,9 +26,9 @@ module Spec
@story_file = path
end
- def run
+ def run(story_runner=Spec::Story::Runner.story_runner)
raise "You must set a path to the file with the story. See the RDoc." if @story_file.nil?
- mediator = Spec::Story::Runner::StoryMediator.new(steps, Spec::Story::Runner.story_runner, @options)
+ mediator = Spec::Story::Runner::StoryMediator.new(steps, story_runner, @options)
parser = Spec::Story::Runner::StoryParser.new(mediator)
story_text = File.read(@story_file)
diff --git a/vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb b/vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb
index aee52e412..2d7c58d03 100644
--- a/vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb
+++ b/vendor/plugins/rspec/lib/spec/story/runner/scenario_runner.rb
@@ -11,6 +11,12 @@ module Spec
run_story_ignoring_scenarios(scenario.story, world)
world.start_collecting_errors
+
+ unless scenario.body
+ @listeners.each { |l| l.scenario_pending(scenario.story.title, scenario.name, '') }
+ return true
+ end
+
world.instance_eval(&scenario.body)
if world.errors.empty?
@listeners.each { |l| l.scenario_succeeded(scenario.story.title, scenario.name) }
@@ -19,8 +25,10 @@ module Spec
@listeners.each { |l| l.scenario_pending(scenario.story.title, scenario.name, e.message) }
else
@listeners.each { |l| l.scenario_failed(scenario.story.title, scenario.name, e) }
+ return false
end
end
+ true
end
def add_listener(listener)
diff --git a/vendor/plugins/rspec/lib/spec/story/runner/story_mediator.rb b/vendor/plugins/rspec/lib/spec/story/runner/story_mediator.rb
index 1f4744b9f..826f322ee 100644
--- a/vendor/plugins/rspec/lib/spec/story/runner/story_mediator.rb
+++ b/vendor/plugins/rspec/lib/spec/story/runner/story_mediator.rb
@@ -64,7 +64,7 @@
title = @title
narrative = @narrative
scenarios = @scenarios.collect { |scenario| scenario.to_proc }
- options = @options.merge(:steps => @step_group)
+ options = @options.merge(:steps_for => @step_group)
lambda do
Story title, narrative, options do
scenarios.each { |scenario| instance_eval(&scenario) }
diff --git a/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb b/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb
index f9eeb9ac1..a63479783 100644
--- a/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb
+++ b/vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb
@@ -36,6 +36,7 @@ module Spec
def run_stories
return if @stories.empty?
@listeners.each { |l| l.run_started(scenarios.size) }
+ success = true
@stories.each do |story|
story.assign_steps_to(World)
@current_story = story
@@ -45,7 +46,7 @@ module Spec
type = story[:type] || Object
args = story[:args] || []
world = @world_creator.create(type, *args)
- @scenario_runner.run(scenario, world)
+ success = success & @scenario_runner.run(scenario, world)
end
@listeners.each { |l| l.story_ended(story.title, story.narrative) }
World.step_mother.clear
@@ -53,6 +54,7 @@ module Spec
unique_steps = (World.step_names.collect {|n| Regexp === n ? n.source : n.to_s}).uniq.sort
@listeners.each { |l| l.collected_steps(unique_steps) }
@listeners.each { |l| l.run_ended }
+ return success
end
def add_listener(listener)
diff --git a/vendor/plugins/rspec/lib/spec/story/step.rb b/vendor/plugins/rspec/lib/spec/story/step.rb
index 1d596e92c..5cd8765d6 100644
--- a/vendor/plugins/rspec/lib/spec/story/step.rb
+++ b/vendor/plugins/rspec/lib/spec/story/step.rb
@@ -1,8 +1,8 @@
module Spec
module Story
class Step
- PARAM_PATTERN = /(\$\w*)/
- PARAM_OR_GROUP_PATTERN = /(\$\w*)|\(.*?\)/
+ PARAM_PATTERN = /([^\\]|^)(\$(?!\$)\w*)/
+ PARAM_OR_GROUP_PATTERN = /(\$(?!\$)\w*)|\(.*?\)/
attr_reader :name
def initialize(name, &block)
@@ -39,18 +39,20 @@ module Spec
private
- def assign_expression(name)
- expression = name.dup
- if String === expression
+ def assign_expression(string_or_regexp)
+ if String === string_or_regexp
+ expression = string_or_regexp.dup
expression.gsub! '(', '\('
expression.gsub! ')', '\)'
- while expression =~ PARAM_PATTERN
- expression.gsub!($1, "(.*?)")
- end
+ elsif Regexp === string_or_regexp
+ expression = string_or_regexp.source
+ end
+ while expression =~ PARAM_PATTERN
+ expression.gsub!($2, "(.*?)")
end
@expression = Regexp.new("^#{expression}$")
end
end
end
-end \ No newline at end of file
+end
diff --git a/vendor/plugins/rspec/lib/spec/story/story.rb b/vendor/plugins/rspec/lib/spec/story/story.rb
index 112e9414b..9cd1a0fec 100644
--- a/vendor/plugins/rspec/lib/spec/story/story.rb
+++ b/vendor/plugins/rspec/lib/spec/story/story.rb
@@ -19,17 +19,14 @@ module Spec
end
def assign_steps_to(assignee)
- if @params[:steps]
- assignee.use(@params[:steps])
- else
- case keys = @params[:steps_for]
- when Symbol
- keys = [keys]
- when nil
- keys = []
- end
- keys.each do |key|
- assignee.use(steps_for(key))
+ if steps=@params[:steps_for]
+ steps = [steps] unless steps.is_a?(Array)
+ steps.each do |step|
+ if step.is_a?(StepGroup)
+ assignee.use(step)
+ else
+ assignee.use(steps_for(step))
+ end
end
end
end
diff --git a/vendor/plugins/rspec/lib/spec/story/world.rb b/vendor/plugins/rspec/lib/spec/story/world.rb
index 6296537b8..a27d3dda9 100644
--- a/vendor/plugins/rspec/lib/spec/story/world.rb
+++ b/vendor/plugins/rspec/lib/spec/story/world.rb
@@ -1,4 +1,3 @@
-require 'rubygems'
require 'spec/expectations'
require 'spec/matchers'
require 'spec/example/pending'
@@ -70,6 +69,7 @@ module Spec
# story_server/prototype/rspec_stories.html (generated by rake stories)
args = step.parse_args(name) if args.empty?
begin
+ listeners.each { |l| l.step_upcoming(type, step_name, *args) }
step.perform(world, *args) unless ::Spec::Story::Runner.dry_run
listeners.each { |l| l.step_succeeded(type, step_name, *args) }
rescue Exception => e
diff --git a/vendor/plugins/rspec/lib/spec/version.rb b/vendor/plugins/rspec/lib/spec/version.rb
index f83a4c697..959bf5189 100644
--- a/vendor/plugins/rspec/lib/spec/version.rb
+++ b/vendor/plugins/rspec/lib/spec/version.rb
@@ -1,22 +1,22 @@
-module Spec
- module VERSION
- unless defined? MAJOR
- MAJOR = 1
- MINOR = 1
- TINY = 2
- RELEASE_CANDIDATE = nil
-
- BUILD_TIME_UTC = 20080114022430
-
- STRING = [MAJOR, MINOR, TINY].join('.')
- TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')
- FULL_VERSION = "#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('.')} (build #{BUILD_TIME_UTC})"
-
- NAME = "RSpec"
- URL = "http://rspec.rubyforge.org/"
-
- DESCRIPTION = "#{NAME}-#{FULL_VERSION} - BDD for Ruby\n#{URL}"
- end
- end
-end
-
+module Spec
+ module VERSION
+ unless defined? MAJOR
+ MAJOR = 1
+ MINOR = 1
+ TINY = 4
+ RELEASE_CANDIDATE = nil
+
+ BUILD_TIME_UTC = 20080526202855
+
+ STRING = [MAJOR, MINOR, TINY].join('.')
+ TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')
+ FULL_VERSION = "#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('.')} (build #{BUILD_TIME_UTC})"
+
+ NAME = "RSpec"
+ URL = "http://rspec.rubyforge.org/"
+
+ DESCRIPTION = "#{NAME}-#{FULL_VERSION} - BDD for Ruby\n#{URL}"
+ end
+ end
+end
+
diff --git a/vendor/plugins/rspec/plugins/mock_frameworks/rspec.rb b/vendor/plugins/rspec/plugins/mock_frameworks/rspec.rb
index ce215ace2..f831cb2ba 100644
--- a/vendor/plugins/rspec/plugins/mock_frameworks/rspec.rb
+++ b/vendor/plugins/rspec/plugins/mock_frameworks/rspec.rb
@@ -1,4 +1,6 @@
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "spec", "mocks"))
+require 'spec/mocks/framework'
+require 'spec/mocks/extensions'
module Spec
module Plugins
diff --git a/vendor/plugins/rspec/spec/README.jruby b/vendor/plugins/rspec/spec/README.jruby
index 0b31d1877..7eddb5671 100644
--- a/vendor/plugins/rspec/spec/README.jruby
+++ b/vendor/plugins/rspec/spec/README.jruby
@@ -7,6 +7,7 @@ ant
# put JRuby's bin dir on your PATH
jruby -S gem install rake --no-ri --no-rdoc
jruby -S gem install diff-lcs
+jruby -S gem install syntax
cd ../testsuites/rspec
mkdir target
jruby -S rake checkout_code
diff --git a/vendor/plugins/rspec/spec/autotest/rspec_spec.rb b/vendor/plugins/rspec/spec/autotest/rspec_spec.rb
index 64c020de9..3abe3fdd5 100644
--- a/vendor/plugins/rspec/spec/autotest/rspec_spec.rb
+++ b/vendor/plugins/rspec/spec/autotest/rspec_spec.rb
@@ -49,7 +49,7 @@ HERE
describe Rspec, "selection of rspec command" do
include AutotestHelper
- before :each do
+ before(:each) do
common_setup
@rspec_autotest = Rspec.new
end
@@ -83,16 +83,15 @@ HERE
describe Rspec, "selection of rspec command (windows compatibility issues)" do
include AutotestHelper
- before :each do
+ before(:each) do
common_setup
end
it "should use the ALT_SEPARATOR if it is non-nil" do
- pending("autotest got re-worked so this is failing for the moment")
@rspec_autotest = Rspec.new
spec_command = File.expand_path("#{File.dirname(__FILE__)}/../../bin/spec")
@rspec_autotest.stub!(:spec_commands).and_return [spec_command]
- @rspec_autotest.spec_command.should == spec_command.gsub('/', '\\')
+ @rspec_autotest.spec_command(@windows_alt_separator).should == spec_command.gsub('/', @windows_alt_separator)
end
it "should not use the ALT_SEPATOR if it is nil" do
@@ -105,7 +104,7 @@ HERE
end
describe Rspec, "adding spec.opts --options" do
- before :each do
+ before(:each) do
@rspec_autotest = Rspec.new
end
@@ -121,7 +120,7 @@ HERE
end
describe Rspec do
- before :each do
+ before(:each) do
@rspec_autotest = Rspec.new
@rspec_autotest.stub!(:ruby).and_return "ruby"
@rspec_autotest.stub!(:add_options_if_present).and_return "-O spec/spec.opts"
@@ -143,121 +142,55 @@ HERE
end
end
- describe Rspec, "test mappings" do
- before :each do
- @rspec_autotest = Rspec.new
- @rspec_autotest.hook :initialize
- end
-
- it "should map all filenames in spec/ which end in .rb" do
- @rspec_autotest.instance_eval{@test_mappings}.should have_key(%r%^spec/.*\.rb$%)
- end
-
- it "should map all names in lib which end in .rb to the corresponding ones in spec/" do
- @rspec_autotest.instance_eval{@test_mappings}.should have_key(%r%^lib/(.*)\.rb$%)
- end
-
- it "should find all files in spec/shares/* and the spec helper in spec/spec_helper" do
- @rspec_autotest.instance_eval{@test_mappings}.should have_key(%r%^spec/(spec_helper|shared/.*)\.rb$%)
- end
- end
-
- describe Rspec, "handling results" do
- include AutotestHelper
-
- before :each do
- common_setup
- @rspec_autotest = Rspec.new
- @rspec_autotest.stub!(:hook)
-
- @results = mock String
- @results.stub!(:scan).and_return ""
- end
-
- it "should call hook(:red) if there are failures" do
- @rspec_autotest.stub!(:consolidate_failures).and_return ["spec/some_spec.rb"]
-
- @rspec_autotest.should_receive(:hook).with(:red)
- @rspec_autotest.handle_results(@results)
- end
+ describe Rspec, "mappings" do
- it "should call hook(:green) if there are no failures" do
- @rspec_autotest.stub!(:consolidate_failures).and_return []
- @rspec_autotest.should_receive(:hook).with(:green)
- @rspec_autotest.handle_results(@results)
- end
- end
-
- describe Rspec, "handling failed results" do
- include AutotestHelper
-
- before :each do
- common_setup
- end
-
- it %(should scan the output into a multi-dimensional array,
- consisting of the failing spec's name as the first element,
- and the failure as the second) do
- @rspec_autotest = Rspec.new
- @rspec_autotest.failed_results(@rspec_output).should == [
- [
- "false should be false",
- "expected: true,\n got: false (using ==)\n./spec/autotest/rspec_spec.rb:203:"
- ]
- ]
- end
- end
-
- describe Rspec, "specs for a given file" do
- before :each do
+ before(:each) do
@lib_file = "lib/something.rb"
@spec_file = "spec/something_spec.rb"
@rspec_autotest = Rspec.new
@rspec_autotest.hook :initialize
-
- @rspec_autotest.instance_variable_set("@files", {@lib_file => Time.now, @spec_file => Time.now})
- @rspec_autotest.stub!(:find_files_to_test).and_return true
end
it "should find the spec file for a given lib file" do
- @rspec_autotest.specs_for_file(@lib_file).should == [@spec_file]
+ @rspec_autotest.should map_specs([@spec_file]).to(@lib_file)
end
it "should find the spec file if given a spec file" do
- @rspec_autotest.specs_for_file(@spec_file).should == [@spec_file]
+ @rspec_autotest.should map_specs([@spec_file]).to(@spec_file)
end
it "should only find the file if the file is being tracked (in @file)" do
- @other_file = "lib/some_non_tracked_file"
- @rspec_autotest.specs_for_file(@other_file).should == []
+ @rspec_autotest.should map_specs([]).to("lib/untracked_file")
end
end
describe Rspec, "consolidating failures" do
include AutotestHelper
- before :each do
+ before(:each) do
common_setup
@rspec_autotest = Rspec.new
- @spec_file = "./spec/autotest/rspec_spec.rb"
+ @spec_file = "spec/autotest/rspec_spec.rb"
@rspec_autotest.instance_variable_set("@files", {@spec_file => Time.now})
@rspec_autotest.stub!(:find_files_to_test).and_return true
end
it "should return no failures if no failures were given in the output" do
- @rspec_autotest.stub!(:failed_results).and_return [[]]
- @rspec_autotest.consolidate_failures(@rspec_autotest.failed_results).should == {}
+ @rspec_autotest.consolidate_failures([[]]).should == {}
end
it "should return a hash with the spec filename => spec name for each failure or error" do
- @rspec_autotest.stub!(:failed_results).and_return([
+ @rspec_autotest.stub!(:test_files_for).and_return "spec/autotest/rspec_spec.rb"
+ failures = [
[
"false should be false",
- "expected: true,\n got: false (using ==)\n./spec/autotest/rspec_spec.rb:203:"
+ "expected: true,\n got: false (using ==)\n#{@spec_file}:203:"
]
- ])
- @rspec_autotest.consolidate_failures(@rspec_autotest.failed_results).should == {@spec_file => ["false should be false"]}
+ ]
+ @rspec_autotest.consolidate_failures(failures).should == {
+ @spec_file => ["false should be false"]
+ }
end
end
diff --git a/vendor/plugins/rspec/spec/autotest_helper.rb b/vendor/plugins/rspec/spec/autotest_helper.rb
index 6d994eaa2..1b6c6002b 100644
--- a/vendor/plugins/rspec/spec/autotest_helper.rb
+++ b/vendor/plugins/rspec/spec/autotest_helper.rb
@@ -2,4 +2,5 @@ require "rubygems"
require 'autotest'
dir = File.dirname(__FILE__)
require "#{dir}/spec_helper"
-require File.expand_path("#{dir}/../lib/autotest/rspec") \ No newline at end of file
+require File.expand_path("#{dir}/../lib/autotest/rspec")
+require "#{dir}/autotest_matchers"
diff --git a/vendor/plugins/rspec/spec/autotest_matchers.rb b/vendor/plugins/rspec/spec/autotest_matchers.rb
new file mode 100644
index 000000000..5e23452e2
--- /dev/null
+++ b/vendor/plugins/rspec/spec/autotest_matchers.rb
@@ -0,0 +1,47 @@
+module Spec
+ module Matchers
+ class AutotestMappingMatcher
+ def initialize(specs)
+ @specs = specs
+ end
+
+ def to(file)
+ @file = file
+ self
+ end
+
+ def matches?(autotest)
+ @autotest = prepare autotest
+ @actual = autotest.test_files_for(@file)
+ @actual == @specs
+ end
+
+ def failure_message
+ "expected #{@autotest.class} to map #{@specs.inspect} to #{@file.inspect}\ngot #{@actual.inspect}"
+ end
+
+ private
+ def prepare autotest
+ stub_found_files autotest
+ stub_find_order autotest
+ autotest
+ end
+
+ def stub_found_files autotest
+ found_files = @specs.inject({}){|h,f| h[f] = Time.at(0)}
+ autotest.stub!(:find_files).and_return(found_files)
+ end
+
+ def stub_find_order autotest
+ find_order = @specs.dup << @file
+ autotest.instance_eval { @find_order = find_order }
+ end
+
+ end
+
+ def map_specs(specs)
+ AutotestMappingMatcher.new(specs)
+ end
+
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec/spec/rspec_suite.rb b/vendor/plugins/rspec/spec/rspec_suite.rb
index ae076bbf1..abd016a6d 100644
--- a/vendor/plugins/rspec/spec/rspec_suite.rb
+++ b/vendor/plugins/rspec/spec/rspec_suite.rb
@@ -1,6 +1,6 @@
if __FILE__ == $0
dir = File.dirname(__FILE__)
- Dir["#{dir}/**/*_spec.rb"].each do |file|
+ Dir["#{dir}/**/*_spec.rb"].reverse.each do |file|
# puts "require '#{file}'"
require file
end
diff --git a/vendor/plugins/rspec/spec.opts b/vendor/plugins/rspec/spec/spec.opts
index 48e51f93b..48e51f93b 100644
--- a/vendor/plugins/rspec/spec.opts
+++ b/vendor/plugins/rspec/spec/spec.opts
diff --git a/vendor/plugins/rspec/spec/spec/example/example_group/described_module_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_group/described_module_spec.rb
new file mode 100644
index 000000000..55b02f53f
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/example/example_group/described_module_spec.rb
@@ -0,0 +1,20 @@
+require File.dirname(__FILE__) + "/../../../spec_helper"
+
+module Spec
+ module Example
+ module AModule; end
+ class AClass; end
+
+ describe "With", AModule do
+ it "should have the described_type as 'AModule'" do
+ self.class.described_module.should == AModule
+ end
+ end
+
+ describe "With", AClass do
+ it "should have the described_module as nil" do
+ self.class.described_module.should be_nil
+ end
+ end
+ end
+end
diff --git a/vendor/plugins/rspec/spec/spec/example/example_group/warning_messages_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_group/warning_messages_spec.rb
new file mode 100644
index 000000000..79ac3722a
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/example/example_group/warning_messages_spec.rb
@@ -0,0 +1,76 @@
+require File.dirname(__FILE__) + "/../../../spec_helper"
+
+module Spec
+ module Example
+ module AModuleAutomaticallyIncluded
+ def call_method
+ @method_called = true
+ return "a string"
+ end
+
+ def method_called?
+ @method_called ? true : false
+ end
+ end
+
+ describe "Including modules in an example group" do
+ describe AModuleAutomaticallyIncluded do
+ before :each do
+ Kernel.stub!(:warn)
+ end
+
+ it "should return the correct values" do
+ self.method_called?.should be_false
+ self.call_method.should eql("a string")
+ self.method_called?.should be_true
+ end
+
+ it "should respond_to? the methods from the module" do
+ self.should respond_to(:method_called?)
+ self.should respond_to(:call_method)
+ end
+
+ it "should not respond_to? methods which do not come from the module (or are in Spec::ExampleGroup)" do
+ self.should_not respond_to(:adsfadfadadf_a_method_which_does_not_exist)
+ end
+
+ it "should respond_to? a method in Spec::ExampleGroup" do
+ self.should respond_to(:describe)
+ end
+
+ it "should issue a warning with Kernel.warn" do
+ Kernel.should_receive(:warn)
+ self.call_method
+ end
+
+ it "should issue a warning when the example calls the method which is automatically included" do
+ Kernel.should_receive(:warn).with("Modules will no longer be automatically included in RSpec version 1.1.4. Called from #{__FILE__}:#{__LINE__+1}")
+ self.method_called?
+ end
+
+ it "should issue a warning with the correct file and line numbers" do
+ Kernel.should_receive(:warn).with("Modules will no longer be automatically included in RSpec version 1.1.4. Called from #{__FILE__}:#{__LINE__+1}")
+ self.method_called?
+ end
+ end
+
+ describe AModuleAutomaticallyIncluded, "which is also manually included" do
+ include AModuleAutomaticallyIncluded
+
+ before :each do
+ Kernel.stub!(:warn)
+ end
+
+ it "should respond to the methods since it is included" do
+ self.should respond_to(:method_called?)
+ self.should respond_to(:call_method)
+ end
+
+ it "should not issue a warning, since the module is manually included" do
+ Kernel.should_not_receive(:warn)
+ self.method_called?
+ end
+ end
+ end
+ end
+end
diff --git a/vendor/plugins/rspec/spec/spec/example/example_group_factory_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_group_factory_spec.rb
index 3b50011f7..da461cdfc 100644
--- a/vendor/plugins/rspec/spec/spec/example/example_group_factory_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/example/example_group_factory_spec.rb
@@ -1,128 +1,143 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
module Spec
module Example
- describe ExampleGroupFactory, "with :foobar registered as custom type" do
+ describe ExampleGroupFactory do
+ describe "#get" do
+ attr_reader :example_group
+ before do
+ @example_group = Class.new(ExampleGroup)
+ ExampleGroupFactory.register(:registered_type, @example_group)
+ end
- before do
- @example_group = Class.new(ExampleGroup)
- ExampleGroupFactory.register(:foobar, @example_group)
- end
+ after do
+ ExampleGroupFactory.reset
+ end
- after do
- ExampleGroupFactory.reset
- end
+ it "should #get the default ExampleGroup type when passed nil" do
+ ExampleGroupFactory.get(nil).should == ExampleGroup
+ end
- it "should #get the default ExampleGroup type when passed nil" do
- ExampleGroupFactory.get(nil).should == ExampleGroup
- end
+ it "should #get the default ExampleGroup for unregistered non-nil values" do
+ ExampleGroupFactory.get(:does_not_exist).should == ExampleGroup
+ end
- it "should #get the default ExampleGroup for unregistered non-nil values" do
- ExampleGroupFactory.get(:does_not_exist).should == ExampleGroup
- end
+ it "should #get custom type for :registered_type" do
+ ExampleGroupFactory.get(:registered_type).should == @example_group
+ end
- it "should #get custom type for :foobar" do
- ExampleGroupFactory.get(:foobar).should == @example_group
- end
+ it "should #get the actual type when that is passed in" do
+ ExampleGroupFactory.get(@example_group).should == @example_group
+ end
- it "should #get the actual type when that is passed in" do
- ExampleGroupFactory.get(@example_group).should == @example_group
+ it "should get the custom type after setting the default" do
+ @example_group2 = Class.new(ExampleGroup)
+ ExampleGroupFactory.default(@example_group2)
+ ExampleGroupFactory.get(:registered_type).should == @example_group
+ end
end
- end
+ describe "#create_example_group" do
+ attr_reader :parent_example_group
+ before do
+ @parent_example_group = Class.new(ExampleGroup) do
+ def initialize(*args, &block)
+ ;
+ end
+ end
+ end
- describe ExampleGroupFactory, "#create_example_group" do
- it "should create a uniquely named class" do
- example_group = Spec::Example::ExampleGroupFactory.create_example_group("example_group") {}
- example_group.name.should =~ /Spec::Example::ExampleGroup::Subclass_\d+/
- end
+ it "should create a uniquely named class" do
+ example_group = Spec::Example::ExampleGroupFactory.create_example_group("example_group") {}
+ example_group.name.should =~ /Spec::Example::ExampleGroup::Subclass_\d+/
+ end
- it "should create a Spec::Example::Example subclass by default" do
- example_group = Spec::Example::ExampleGroupFactory.create_example_group("example_group") {}
- example_group.superclass.should == Spec::Example::ExampleGroup
- end
+ it "should create a Spec::Example::Example subclass by default" do
+ example_group = Spec::Example::ExampleGroupFactory.create_example_group("example_group") {}
+ example_group.superclass.should == Spec::Example::ExampleGroup
+ end
- it "should create a Spec::Example::Example when :type => :default" do
- example_group = Spec::Example::ExampleGroupFactory.create_example_group(
- "example_group", :type => :default
- ) {}
- example_group.superclass.should == Spec::Example::ExampleGroup
- end
+ describe "when :type => :default" do
+ it "should create a Spec::Example::Example" do
+ example_group = Spec::Example::ExampleGroupFactory.create_example_group(
+ "example_group", :type => :default
+ ) {}
+ example_group.superclass.should == Spec::Example::ExampleGroup
+ end
+
+ it "should create a Spec::Example::Example" do
+ example_group = Spec::Example::ExampleGroupFactory.create_example_group(
+ "example_group", :type => :default
+ ) {}
+ example_group.superclass.should == Spec::Example::ExampleGroup
+ end
+ end
- it "should create a Spec::Example::Example when :type => :default" do
- example_group = Spec::Example::ExampleGroupFactory.create_example_group(
- "example_group", :type => :default
- ) {}
- example_group.superclass.should == Spec::Example::ExampleGroup
- end
+ describe "when :type => :something_other_than_default" do
+ it "should create specified type" do
+ Spec::Example::ExampleGroupFactory.register(:something_other_than_default, parent_example_group)
+ non_default_example_group = Spec::Example::ExampleGroupFactory.create_example_group(
+ "example_group", :type => :something_other_than_default
+ ) {}
+ non_default_example_group.superclass.should == parent_example_group
+ end
+ end
- it "should create specified type when :type => :something_other_than_default" do
- klass = Class.new(ExampleGroup) do
- def initialize(*args, &block); end
+ it "should create a type indicated by :spec_path" do
+ Spec::Example::ExampleGroupFactory.register(:something_other_than_default, parent_example_group)
+ custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group(
+ "example_group", :spec_path => "./spec/something_other_than_default/some_spec.rb"
+ ) {}
+ custom_example_group.superclass.should == parent_example_group
end
- Spec::Example::ExampleGroupFactory.register(:something_other_than_default, klass)
- example_group = Spec::Example::ExampleGroupFactory.create_example_group(
- "example_group", :type => :something_other_than_default
- ) {}
- example_group.superclass.should == klass
- end
-
- it "should create a type indicated by :spec_path" do
- klass = Class.new(ExampleGroup) do
- def initialize(*args, &block); end
- end
- Spec::Example::ExampleGroupFactory.register(:something_other_than_default, klass)
- example_group = Spec::Example::ExampleGroupFactory.create_example_group(
- "example_group", :spec_path => "./spec/something_other_than_default/some_spec.rb"
- ) {}
- example_group.superclass.should == klass
- end
-
- it "should create a type indicated by :spec_path (with spec_path generated by caller on windows)" do
- klass = Class.new(ExampleGroup) do
- def initialize(*args, &block); end
- end
- Spec::Example::ExampleGroupFactory.register(:something_other_than_default, klass)
- example_group = Spec::Example::ExampleGroupFactory.create_example_group(
- "example_group", :spec_path => "./spec\\something_other_than_default\\some_spec.rb"
- ) {}
- example_group.superclass.should == klass
- end
-
- it "should create and register a Spec::Example::Example if :shared => true" do
- shared_example_group = Spec::Example::ExampleGroupFactory.create_example_group(
- "name", :spec_path => '/blah/spec/models/blah.rb', :type => :controller, :shared => true
- ) {}
- shared_example_group.should be_an_instance_of(Spec::Example::SharedExampleGroup)
- SharedExampleGroup.shared_example_groups.should include(shared_example_group)
- end
- it "should favor the :type over the :spec_path" do
- klass = Class.new(ExampleGroup) do
- def initialize(*args, &block); end
+ it "should create a type indicated by :spec_path (with spec_path generated by caller on windows)" do
+ Spec::Example::ExampleGroupFactory.register(:something_other_than_default, parent_example_group)
+ custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group(
+ "example_group",
+ :spec_path => "./spec\\something_other_than_default\\some_spec.rb"
+ ) {}
+ custom_example_group.superclass.should == parent_example_group
end
- Spec::Example::ExampleGroupFactory.register(:something_other_than_default, klass)
- example_group = Spec::Example::ExampleGroupFactory.create_example_group(
- "name", :spec_path => '/blah/spec/models/blah.rb', :type => :something_other_than_default
- ) {}
- example_group.superclass.should == klass
- end
- it "should register ExampleGroup by default" do
- example_group = Spec::Example::ExampleGroupFactory.create_example_group("The ExampleGroup") do
+ describe "when :shared => true" do
+ attr_reader :shared_example_group
+ before do
+ @shared_example_group = Spec::Example::ExampleGroupFactory.create_example_group(
+ "name", :spec_path => '/blah/spec/models/blah.rb', :type => :controller, :shared => true
+ ) {}
+ end
+
+ it "should create and register a Spec::Example::Example" do
+ shared_example_group.should be_an_instance_of(Spec::Example::SharedExampleGroup)
+ SharedExampleGroup.shared_example_groups.should include(shared_example_group)
+ end
end
- rspec_options.example_groups.should include(example_group)
- end
- it "should enable unregistering of ExampleGroups" do
- example_group = Spec::Example::ExampleGroupFactory.create_example_group("The ExampleGroup") do
- unregister
+ it "should favor the :type over the :spec_path" do
+ Spec::Example::ExampleGroupFactory.register(:something_other_than_default, parent_example_group)
+ custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group(
+ "name", :spec_path => '/blah/spec/models/blah.rb', :type => :something_other_than_default
+ ) {}
+ custom_example_group.superclass.should == parent_example_group
+ end
+
+ it "should register ExampleGroup by default" do
+ example_group = Spec::Example::ExampleGroupFactory.create_example_group("The ExampleGroup") do
+ end
+ rspec_options.example_groups.should include(example_group)
+ end
+
+ it "should enable unregistering of ExampleGroups" do
+ example_group = Spec::Example::ExampleGroupFactory.create_example_group("The ExampleGroup") do
+ unregister
+ end
+ rspec_options.example_groups.should_not include(example_group)
+ end
+
+ after(:each) do
+ Spec::Example::ExampleGroupFactory.reset
end
- rspec_options.example_groups.should_not include(example_group)
- end
-
- after(:each) do
- Spec::Example::ExampleGroupFactory.reset
end
end
end
diff --git a/vendor/plugins/rspec/spec/spec/example/example_group_methods_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_group_methods_spec.rb
index fa08e6fca..55c746ece 100644
--- a/vendor/plugins/rspec/spec/spec/example/example_group_methods_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/example/example_group_methods_spec.rb
@@ -24,26 +24,53 @@ module Spec
ExampleGroup.reset
end
- describe "#describe" do
- attr_reader :child_example_group
- before do
- @child_example_group = @example_group.describe("Another ExampleGroup") do
- it "should pass" do
- true.should be_true
+ ["describe","context"].each do |method|
+ describe "#{method}" do
+ describe "when creating an ExampleGroup" do
+ attr_reader :child_example_group
+ before do
+ @child_example_group = @example_group.send method, "Another ExampleGroup" do
+ it "should pass" do
+ true.should be_true
+ end
+ end
+ end
+
+ it "should create a subclass of the ExampleGroup when passed a block" do
+ child_example_group.superclass.should == @example_group
+ @options.example_groups.should include(child_example_group)
+ end
+
+ it "should not inherit examples" do
+ child_example_group.examples.length.should == 1
end
end
- end
- it "should create a subclass of the ExampleGroup when passed a block" do
- child_example_group.superclass.should == @example_group
- @options.example_groups.should include(child_example_group)
- end
+ describe "when creating a SharedExampleGroup" do
+ attr_reader :name, :shared_example_group
+ before do
+ @name = "A Shared ExampleGroup"
+ @shared_example_group = @example_group.send method, name, :shared => true do
+ it "should pass" do
+ true.should be_true
+ end
+ end
+ end
+
+ after do
+ SharedExampleGroup.shared_example_groups.delete_if do |registered_shared_example_group|
+ registered_shared_example_group == shared_example_group
+ end
+ end
+
+ it "should create a SharedExampleGroup" do
+ SharedExampleGroup.find_shared_example_group(name).should == shared_example_group
+ end
+ end
- it "should not inherit examples" do
- child_example_group.examples.length.should == 1
end
end
-
+
describe "#it" do
it "should should create an example instance" do
lambda {
@@ -52,20 +79,25 @@ module Spec
end
end
- describe "#xit" do
+ describe "#xit and #xspecify" do
before(:each) do
Kernel.stub!(:warn)
end
- it "should NOT should create an example instance" do
+ it "should NOT create an example instance" do
lambda {
@example_group.xit("")
}.should_not change(@example_group.examples, :length)
+
+ lambda {
+ @example_group.xspecify("")
+ }.should_not change(@example_group.examples, :length)
end
it "should warn that it is disabled" do
- Kernel.should_receive(:warn).with("Example disabled: foo")
+ Kernel.should_receive(:warn).with("Example disabled: foo").twice
@example_group.xit("foo")
+ @example_group.xspecify("foo")
end
end
@@ -395,6 +427,7 @@ module Spec
it "should have accessible class methods from included module" do
mod1_method_called = false
mod1 = Module.new do
+ extend Spec::MetaClass
class_methods = Module.new do
define_method :mod1_method do
mod1_method_called = true
@@ -410,6 +443,7 @@ module Spec
mod2_method_called = false
mod2 = Module.new do
+ extend Spec::MetaClass
class_methods = Module.new do
define_method :mod2_method do
mod2_method_called = true
@@ -459,14 +493,16 @@ module Spec
describe '#register' do
it "should add ExampleGroup to set of ExampleGroups to be run" do
- example_group.register
+ options.example_groups.delete(example_group)
+ options.example_groups.should_not include(example_group)
+
+ example_group.register {}
options.example_groups.should include(example_group)
end
end
describe '#unregister' do
before do
- example_group.register
options.example_groups.should include(example_group)
end
@@ -475,6 +511,13 @@ module Spec
options.example_groups.should_not include(example_group)
end
end
+
+ describe "#registration_backtrace" do
+ it "returns the backtrace of where the ExampleGroup was registered" do
+ example_group = Class.new(ExampleGroup)
+ example_group.registration_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-1}")
+ end
+ end
end
end
end \ No newline at end of file
diff --git a/vendor/plugins/rspec/spec/spec/example/example_group_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_group_spec.rb
index 93e558a97..36e1cdf0d 100644
--- a/vendor/plugins/rspec/spec/spec/example/example_group_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/example/example_group_spec.rb
@@ -673,6 +673,10 @@ module Spec
end
describe Enumerable do
+ before(:each) do
+ Kernel.stub!(:warn)
+ end
+
def each(&block)
["4", "2", "1"].each(&block)
end
@@ -683,6 +687,10 @@ module Spec
end
describe "An", Enumerable, "as a second argument" do
+ before(:each) do
+ Kernel.stub!(:warn)
+ end
+
def each(&block)
["4", "2", "1"].each(&block)
end
@@ -694,6 +702,10 @@ module Spec
describe Enumerable do
describe "as the parent of nested example groups" do
+ before(:each) do
+ Kernel.stub!(:warn)
+ end
+
it "should be included in examples because it is a module" do
pending("need to make sure nested groups know the described type") do
map{|e| e.to_i}.should == [4,2,1]
@@ -703,7 +715,7 @@ module Spec
end
describe String do
- it"should not be included in examples because it is not a module" do
+ it "should not be included in examples because it is not a module" do
lambda{self.map}.should raise_error(NoMethodError, /undefined method `map' for/)
end
end
diff --git a/vendor/plugins/rspec/spec/spec/example/example_methods_spec.rb b/vendor/plugins/rspec/spec/spec/example/example_methods_spec.rb
index ce688a7f9..dd33c57f0 100644
--- a/vendor/plugins/rspec/spec/spec/example/example_methods_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/example/example_methods_spec.rb
@@ -14,76 +14,111 @@ module Spec
end
end
- describe "ExampleMethods with an included module that is reopened" do
- it "should have repoened methods" do
- method(:module_that_is_reopened_method).should_not be_nil
- end
- end
-
- describe ExampleMethods, "lifecycle" do
- before do
- @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new)
- @options.formatters << mock("formatter", :null_object => true)
- @options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true)
- @reporter = FakeReporter.new(@options)
- @options.reporter = @reporter
-
- ExampleMethods.before_all_parts.should == []
- ExampleMethods.before_each_parts.should == []
- ExampleMethods.after_each_parts.should == []
- ExampleMethods.after_all_parts.should == []
- def ExampleMethods.count
- @count ||= 0
- @count = @count + 1
- @count
+ describe ExampleMethods do
+ describe "with an included module that is reopened" do
+ it "should have repoened methods" do
+ method(:module_that_is_reopened_method).should_not be_nil
end
end
- after do
- ExampleMethods.instance_variable_set("@before_all_parts", [])
- ExampleMethods.instance_variable_set("@before_each_parts", [])
- ExampleMethods.instance_variable_set("@after_each_parts", [])
- ExampleMethods.instance_variable_set("@after_all_parts", [])
- end
+ describe "lifecycle" do
+ before do
+ @original_rspec_options = $rspec_options
+ @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new)
+ $rspec_options = @options
+ @options.formatters << mock("formatter", :null_object => true)
+ @options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true)
+ @reporter = FakeReporter.new(@options)
+ @options.reporter = @reporter
- it "should pass before and after callbacks to all ExampleGroup subclasses" do
- ExampleMethods.before(:all) do
- ExampleMethods.count.should == 1
+ ExampleMethods.before_all_parts.should == []
+ ExampleMethods.before_each_parts.should == []
+ ExampleMethods.after_each_parts.should == []
+ ExampleMethods.after_all_parts.should == []
+ def ExampleMethods.count
+ @count ||= 0
+ @count = @count + 1
+ @count
+ end
end
- ExampleMethods.before(:each) do
- ExampleMethods.count.should == 2
+ after do
+ $rspec_options = @original_rspec_options
+ ExampleMethods.instance_variable_set("@before_all_parts", [])
+ ExampleMethods.instance_variable_set("@before_each_parts", [])
+ ExampleMethods.instance_variable_set("@after_each_parts", [])
+ ExampleMethods.instance_variable_set("@after_all_parts", [])
end
- ExampleMethods.after(:each) do
- ExampleMethods.count.should == 3
- end
+ it "should pass before and after callbacks to all ExampleGroup subclasses" do
+ ExampleMethods.before(:suite) do
+ ExampleMethods.count.should == 1
+ end
+
+ ExampleMethods.before(:all) do
+ ExampleMethods.count.should == 2
+ end
+
+ ExampleMethods.before(:each) do
+ ExampleMethods.count.should == 3
+ end
+
+ ExampleMethods.after(:each) do
+ ExampleMethods.count.should == 4
+ end
+
+ ExampleMethods.after(:all) do
+ ExampleMethods.count.should == 5
+ end
+
+ ExampleMethods.after(:suite) do
+ ExampleMethods.count.should == 6
+ end
- ExampleMethods.after(:all) do
- ExampleMethods.count.should == 4
+ @example_group = Class.new(ExampleGroup) do
+ it "should use ExampleMethods callbacks" do
+ end
+ end
+ @options.run_examples
+ ExampleMethods.count.should == 7
end
- @example_group = Class.new(ExampleGroup) do
- it "should use ExampleMethods callbacks" do
+ describe "run_with_description_capturing" do
+ before(:each) do
+ @example_group = Class.new(ExampleGroup) do end
+ @example = @example_group.new("foo", &(lambda { 2.should == 2 }))
+ @example.run_with_description_capturing
+ end
+
+ it "should provide the generated description" do
+ @example.instance_eval { @_matcher_description }.should == "should == 2"
+ end
+
+ it "should clear the global generated_description" do
+ Spec::Matchers.generated_description.should == nil
end
end
- @example_group.run
- ExampleMethods.count.should == 5
end
-
- describe "run_with_description_capturing" do
- before(:each) do
- @example_group = Class.new(ExampleGroup) do end
- @example = @example_group.new("foo", &(lambda { 2.should == 2 }))
- @example.run_with_description_capturing
- end
-
- it "should provide the generated description" do
- @example.instance_eval { @_matcher_description }.should == "should == 2"
+
+ describe "#implementation_backtrace" do
+ it "returns the backtrace of where the implementation was defined" do
+ example_group = Class.new(ExampleGroup) do
+ it "should use ExampleMethods callbacks" do
+ end
+ end
+ example = example_group.examples.first
+ example.implementation_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-4}")
end
-
- it "should clear the global generated_description" do
- Spec::Matchers.generated_description.should == nil
+ end
+
+ describe "#__full_description" do
+ it "should return the full description of the ExampleGroup and Example" do
+ example_group = Class.new(ExampleGroup).describe("An ExampleGroup") do
+ it "should do something" do
+ end
+ end
+ example = example_group.examples.first
+ example.__full_description.should == "An ExampleGroup should do something"
end
end
end
diff --git a/vendor/plugins/rspec/spec/spec/example/nested_example_group_spec.rb b/vendor/plugins/rspec/spec/spec/example/nested_example_group_spec.rb
index 35e8a9890..559467d6d 100644
--- a/vendor/plugins/rspec/spec/spec/example/nested_example_group_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/example/nested_example_group_spec.rb
@@ -55,5 +55,17 @@ module Spec
end
end
end
+
+ describe "Nested Example Groups" do
+ describe "description options", :other_options => "other options" do
+ it "should have a spec_path" do
+ self.class.description_options[:spec_path].should match(/#{__FILE__}/)
+ end
+
+ it "should pass other options" do
+ self.class.description_options[:other_options].should == "other options"
+ end
+ end
+ end
end
end
diff --git a/vendor/plugins/rspec/spec/spec/expectations/differs/default_spec.rb b/vendor/plugins/rspec/spec/spec/expectations/differs/default_spec.rb
index ea720846b..ba76cbd47 100644
--- a/vendor/plugins/rspec/spec/spec/expectations/differs/default_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/expectations/differs/default_spec.rb
@@ -28,7 +28,25 @@ describe "Diff" do
it "should output unified diff of two strings" do
expected="foo\nbar\nzap\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nline\n"
actual="foo\nzap\nbar\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nanother\nline\n"
- expected_diff="\n\n@@ -1,6 +1,6 @@\n foo\n-bar\n zap\n+bar\n this\n is\n soo\n@@ -9,5 +9,6 @@\n equal\n insert\n a\n+another\n line\n"
+ expected_diff= <<'EOD'
+
+
+@@ -1,6 +1,6 @@
+ foo
+-zap
+ bar
++zap
+ this
+ is
+ soo
+@@ -9,6 +9,5 @@
+ equal
+ insert
+ a
+-another
+ line
+EOD
+
diff = @differ.diff_as_string(expected, actual)
diff.should eql(expected_diff)
end
@@ -44,11 +62,11 @@ describe "Diff" do
:metasyntactic,
"variable",
:delta,
-- "charlie",
-+ "tango",
+- "tango",
++ "charlie",
:width,
-- "quite wide"]
-+ "very wide"]
+- "very wide"]
++ "quite wide"]
EOD
@@ -65,8 +83,8 @@ EOD
@@ -1,5 +1,5 @@
<Animal
name=bob,
-- species=giraffe
-+ species=tortoise
+- species=tortoise
++ species=giraffe
>
EOD
@@ -94,12 +112,12 @@ describe "Diff in context format" do
*** 1,5 ****
<Animal
name=bob,
-! species=giraffe
+! species=tortoise
>
--- 1,5 ----
<Animal
name=bob,
-! species=tortoise
+! species=giraffe
>
EOD
diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_fails.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_fails.rb
new file mode 100644
index 000000000..d6f5564bf
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_fails.rb
@@ -0,0 +1,10 @@
+rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib"
+$:.unshift rspec_lib unless $:.include?(rspec_lib)
+require 'test/unit'
+require 'spec'
+
+describe "example group with failures" do
+ it "should fail" do
+ false.should be_true
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_passes.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_passes.rb
new file mode 100644
index 000000000..ccd2488bc
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_that_passes.rb
@@ -0,0 +1,10 @@
+rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib"
+$:.unshift rspec_lib unless $:.include?(rspec_lib)
+require 'test/unit'
+require 'spec'
+
+describe "example group with passing examples" do
+ it "should pass" do
+ true.should be_true
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_with_errors.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_with_errors.rb
new file mode 100644
index 000000000..71427dbaa
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/spec_with_errors.rb
@@ -0,0 +1,10 @@
+rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib"
+$:.unshift rspec_lib unless $:.include?(rspec_lib)
+require 'test/unit'
+require 'spec'
+
+describe "example group with errors" do
+ it "should raise errors" do
+ raise "error raised in example group with errors"
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_fails.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_fails.rb
new file mode 100644
index 000000000..3fb6515a8
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_fails.rb
@@ -0,0 +1,10 @@
+rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib"
+$:.unshift rspec_lib unless $:.include?(rspec_lib)
+require 'test/unit'
+require 'spec'
+
+class TestCaseThatFails < Test::Unit::TestCase
+ def test_that_fails
+ false.should be_true
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_passes.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_passes.rb
new file mode 100644
index 000000000..69239c0b5
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_that_passes.rb
@@ -0,0 +1,10 @@
+rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib"
+$:.unshift rspec_lib unless $:.include?(rspec_lib)
+require 'test/unit'
+require 'spec'
+
+class TestCaseThatPasses < Test::Unit::TestCase
+ def test_that_passes
+ true.should be_true
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_with_errors.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_with_errors.rb
new file mode 100644
index 000000000..35dcb6b2e
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/test_case_with_errors.rb
@@ -0,0 +1,10 @@
+rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib"
+$:.unshift rspec_lib unless $:.include?(rspec_lib)
+require 'test/unit'
+require 'spec'
+
+class TestCaseWithErrors < Test::Unit::TestCase
+ def test_with_error
+ raise "error raised in TestCaseWithErrors"
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb
new file mode 100644
index 000000000..0c2167a99
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb
@@ -0,0 +1,38 @@
+rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib"
+$:.unshift rspec_lib unless $:.include?(rspec_lib)
+require "test/unit"
+require "spec"
+
+module Test
+ module Unit
+ describe TestSuiteAdapter do
+ def create_adapter(group)
+ TestSuiteAdapter.new(group)
+ end
+
+ describe "#size" do
+ it "should return the number of examples in the example group" do
+ group = Class.new(Spec::ExampleGroup) do
+ describe("some examples")
+ it("bar") {}
+ it("baz") {}
+ end
+ adapter = create_adapter(group)
+ adapter.size.should == 2
+ end
+ end
+
+ describe "#delete" do
+ it "should do nothing" do
+ group = Class.new(Spec::ExampleGroup) do
+ describe("Some Examples")
+ it("does something") {}
+ end
+ adapter = create_adapter(group)
+ adapter.delete(adapter.examples.first)
+ adapter.should be_empty
+ end
+ end
+ end
+ end
+end
diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/spec_spec.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/spec_spec.rb
new file mode 100644
index 000000000..8a1e1300c
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/spec_spec.rb
@@ -0,0 +1,45 @@
+require File.dirname(__FILE__) + '/test_unit_spec_helper'
+
+describe "ExampleGroup with test/unit/interop" do
+ include TestUnitSpecHelper
+
+ before(:each) do
+ @dir = File.dirname(__FILE__) + "/resources"
+ end
+
+ describe "with passing examples" do
+ it "should output 0 failures" do
+ output = ruby("#{@dir}/spec_that_passes.rb")
+ output.should include("1 example, 0 failures")
+ end
+
+ it "should return an exit code of 0" do
+ ruby("#{@dir}/spec_that_passes.rb")
+ $?.should == 0
+ end
+ end
+
+ describe "with failing examples" do
+ it "should output 1 failure" do
+ output = ruby("#{@dir}/spec_that_fails.rb")
+ output.should include("1 example, 1 failure")
+ end
+
+ it "should return an exit code of 256" do
+ ruby("#{@dir}/spec_that_fails.rb")
+ $?.should == 256
+ end
+ end
+
+ describe "with example that raises an error" do
+ it "should output 1 failure" do
+ output = ruby("#{@dir}/spec_with_errors.rb")
+ output.should include("1 example, 1 failure")
+ end
+
+ it "should return an exit code of 256" do
+ ruby("#{@dir}/spec_with_errors.rb")
+ $?.should == 256
+ end
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/testcase_spec.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/testcase_spec.rb
index 3e10ba7b5..f40111a58 100644
--- a/vendor/plugins/rspec/spec/spec/interop/test/unit/testcase_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/testcase_spec.rb
@@ -2,9 +2,44 @@ require File.dirname(__FILE__) + '/test_unit_spec_helper'
describe "Test::Unit::TestCase" do
include TestUnitSpecHelper
- it "should pass" do
- dir = File.dirname(__FILE__)
- output = run_script("#{dir}/testcase_spec_with_test_unit.rb")
- output.should include("3 examples, 0 failures")
+
+ before(:each) do
+ @dir = File.dirname(__FILE__) + "/resources"
+ end
+
+ describe "with passing test case" do
+ it "should output 0 failures" do
+ output = ruby("#{@dir}/test_case_that_passes.rb")
+ output.should include("1 example, 0 failures")
+ end
+
+ it "should return an exit code of 0" do
+ ruby("#{@dir}/test_case_that_passes.rb")
+ $?.should == 0
+ end
+ end
+
+ describe "with failing test case" do
+ it "should output 1 failure" do
+ output = ruby("#{@dir}/test_case_that_fails.rb")
+ output.should include("1 example, 1 failure")
+ end
+
+ it "should return an exit code of 256" do
+ ruby("#{@dir}/test_case_that_fails.rb")
+ $?.should == 256
+ end
+ end
+
+ describe "with test case that raises an error" do
+ it "should output 1 failure" do
+ output = ruby("#{@dir}/test_case_with_errors.rb")
+ output.should include("1 example, 1 failure")
+ end
+
+ it "should return an exit code of 256" do
+ ruby("#{@dir}/test_case_with_errors.rb")
+ $?.should == 256
+ end
end
end \ No newline at end of file
diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/testcase_spec_with_test_unit.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/testcase_spec_with_test_unit.rb
deleted file mode 100644
index 52afd8e4c..000000000
--- a/vendor/plugins/rspec/spec/spec/interop/test/unit/testcase_spec_with_test_unit.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require "test/unit"
-require File.dirname(__FILE__) + '/../../../../spec_helper.rb'
-
-describe "TestCase#method_name" do
- it "should equal the description of the example" do
- @method_name.should == "should equal the description of the example"
- end
-
- def test_this
- true.should be_true
- end
-
- def testThis
- true.should be_true
- end
-
- def testament
- raise "testament is not a test"
- end
-end
diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec.rb
index bcb25b36c..722126bc9 100644
--- a/vendor/plugins/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec.rb
@@ -4,6 +4,6 @@ describe "TestSuiteAdapter" do
include TestUnitSpecHelper
it "should pass" do
dir = File.dirname(__FILE__)
- run_script "#{dir}/testsuite_adapter_spec_with_test_unit.rb"
+ run_script "#{dir}/resources/testsuite_adapter_spec_with_test_unit.rb"
end
end \ No newline at end of file
diff --git a/vendor/plugins/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec_with_test_unit.rb b/vendor/plugins/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec_with_test_unit.rb
deleted file mode 100644
index 8088ef50e..000000000
--- a/vendor/plugins/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec_with_test_unit.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require "test/unit"
-require File.dirname(__FILE__) + '/../../../../spec_helper.rb'
-
-module TestSuiteAdapterSpecHelper
- def create_adapter(group)
- Test::Unit::TestSuiteAdapter.new(group)
- end
-end
-
-describe "TestSuiteAdapter#size" do
- include TestSuiteAdapterSpecHelper
- it "should return the number of examples in the example group" do
- group = Class.new(Spec::ExampleGroup) do
- describe("some examples")
- it("bar") {}
- it("baz") {}
- end
- adapter = create_adapter(group)
- adapter.size.should == 2
- end
-end
-
-describe "TestSuiteAdapter#delete" do
- include TestSuiteAdapterSpecHelper
- it "should do nothing" do
- group = Class.new(Spec::ExampleGroup) do
- describe("Some Examples")
- it("does something") {}
- end
- adapter = create_adapter(group)
- adapter.delete(adapter.examples.first)
- adapter.should be_empty
- end
-end
diff --git a/vendor/plugins/rspec/spec/spec/matchers/be_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/be_spec.rb
index d40036c79..ba2a0f165 100644
--- a/vendor/plugins/rspec/spec/spec/matchers/be_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/matchers/be_spec.rb
@@ -222,3 +222,27 @@ describe "should be(value)" do
lambda { 5.should be(6) }.should fail_with("expected 6, got 5")
end
end
+
+
+describe "arbitrary predicate with DelegateClass" do
+ it "should access methods defined in the delegating class (LH[#48])" do
+ pending(%{
+ Looks like DelegateClass is delegating #should to the
+ delegate. Not sure how to fix this one. Or if we even should."
+ })
+ require 'delegate'
+ class ArrayDelegate < DelegateClass(Array)
+ def initialize(array)
+ @internal_array = array
+ super(@internal_array)
+ end
+
+ def large?
+ @internal_array.size >= 5
+ end
+ end
+
+ delegate = ArrayDelegate.new([1,2,3,4,5,6])
+ delegate.should be_large
+ end
+end
diff --git a/vendor/plugins/rspec/spec/spec/matchers/has_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/has_spec.rb
index 47f048ebf..648ad8653 100644
--- a/vendor/plugins/rspec/spec/spec/matchers/has_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/matchers/has_spec.rb
@@ -16,6 +16,14 @@ describe "should have_sym(*args)" do
Object.new.should have_key(:a)
}.should raise_error(NoMethodError)
end
+
+ it "should reraise an exception thrown in #has_sym?(*args)" do
+ o = Object.new
+ def o.has_sym?(*args)
+ raise "Funky exception"
+ end
+ lambda { o.should have_sym(:foo) }.should raise_error("Funky exception")
+ end
end
describe "should_not have_sym(*args)" do
@@ -34,4 +42,12 @@ describe "should_not have_sym(*args)" do
Object.new.should have_key(:a)
}.should raise_error(NoMethodError)
end
+
+ it "should reraise an exception thrown in #has_sym?(*args)" do
+ o = Object.new
+ def o.has_sym?(*args)
+ raise "Funky exception"
+ end
+ lambda { o.should_not have_sym(:foo) }.should raise_error("Funky exception")
+ end
end
diff --git a/vendor/plugins/rspec/spec/spec/matchers/raise_error_spec.rb b/vendor/plugins/rspec/spec/spec/matchers/raise_error_spec.rb
index f33fba903..a500d3b50 100644
--- a/vendor/plugins/rspec/spec/spec/matchers/raise_error_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/matchers/raise_error_spec.rb
@@ -28,6 +28,9 @@ describe "should raise_error(message)" do
it "should pass if RuntimeError is raised with the right message" do
lambda {raise 'blah'}.should raise_error('blah')
end
+ it "should pass if RuntimeError is raised with a matching message" do
+ lambda {raise 'blah'}.should raise_error(/blah/)
+ end
it "should pass if any other error is raised with the right message" do
lambda {raise NameError.new('blah')}.should raise_error('blah')
end
@@ -73,11 +76,17 @@ describe "should raise_error(NamedError)" do
}.should fail_with("expected NameError but nothing was raised")
end
- it "should fail if another error is raised" do
+ it "should fail if another error is raised (NameError)" do
lambda {
lambda { raise }.should raise_error(NameError)
}.should fail_with("expected NameError, got RuntimeError")
end
+
+ it "should fail if another error is raised (NameError)" do
+ lambda {
+ lambda { load "non/existent/file" }.should raise_error(NameError)
+ }.should fail_with(/expected NameError, got #<LoadError/)
+ end
end
describe "should_not raise_error(NamedError)" do
@@ -120,6 +129,127 @@ describe "should raise_error(NamedError, error_message) with String" do
end
end
+describe "should raise_error(NamedError, error_message) { |err| ... }" do
+ it "should yield exception if named error is raised with same message" do
+ ran = false
+
+ lambda {
+ raise "example message"
+ }.should raise_error(RuntimeError, "example message") { |err|
+ ran = true
+ err.class.should == RuntimeError
+ err.message.should == "example message"
+ }
+
+ ran.should == true
+ end
+
+ it "yielded block should be able to fail on it's own right" do
+ ran, passed = false, false
+
+ lambda {
+ lambda {
+ raise "example message"
+ }.should raise_error(RuntimeError, "example message") { |err|
+ ran = true
+ 5.should == 4
+ passed = true
+ }
+ }.should fail_with(/expected: 4/m)
+
+ ran.should == true
+ passed.should == false
+ end
+
+ it "should NOT yield exception if no error was thrown" do
+ ran = false
+
+ lambda {
+ lambda {}.should raise_error(RuntimeError, "example message") { |err|
+ ran = true
+ }
+ }.should fail_with("expected RuntimeError with \"example message\" but nothing was raised")
+
+ ran.should == false
+ end
+
+ it "should not yield exception if error class is not matched" do
+ ran = false
+
+ lambda {
+ lambda {
+ raise "example message"
+ }.should raise_error(SyntaxError, "example message") { |err|
+ ran = true
+ }
+ }.should fail_with("expected SyntaxError with \"example message\", got #<RuntimeError: example message>")
+
+ ran.should == false
+ end
+
+ it "should NOT yield exception if error message is not matched" do
+ ran = false
+
+ lambda {
+ lambda {
+ raise "example message"
+ }.should raise_error(RuntimeError, "different message") { |err|
+ ran = true
+ }
+ }.should fail_with("expected RuntimeError with \"different message\", got #<RuntimeError: example message>")
+
+ ran.should == false
+ end
+end
+
+describe "should_not raise_error(NamedError, error_message) { |err| ... }" do
+ it "should pass if nothing is raised" do
+ ran = false
+
+ lambda {}.should_not raise_error(RuntimeError, "example message") { |err|
+ ran = true
+ }
+
+ ran.should == false
+ end
+
+ it "should pass if a different error is raised" do
+ ran = false
+
+ lambda { raise }.should_not raise_error(NameError, "example message") { |err|
+ ran = true
+ }
+
+ ran.should == false
+ end
+
+ it "should pass if same error is raised with different message" do
+ ran = false
+
+ lambda {
+ raise RuntimeError.new("not the example message")
+ }.should_not raise_error(RuntimeError, "example message") { |err|
+ ran = true
+ }
+
+ ran.should == false
+ end
+
+ it "should fail if named error is raised with same message" do
+ ran = false
+
+ lambda {
+ lambda {
+ raise "example message"
+ }.should_not raise_error(RuntimeError, "example message") { |err|
+ ran = true
+ }
+ }.should fail_with("expected no RuntimeError with \"example message\", got #<RuntimeError: example message>")
+
+ ran.should == false
+ end
+end
+
describe "should_not raise_error(NamedError, error_message) with String" do
it "should pass if nothing is raised" do
lambda {}.should_not raise_error(RuntimeError, "example message")
diff --git a/vendor/plugins/rspec/spec/spec/mocks/bug_report_10263.rb b/vendor/plugins/rspec/spec/spec/mocks/bug_report_10263_spec.rb
index f82180c09..e32192257 100644
--- a/vendor/plugins/rspec/spec/spec/mocks/bug_report_10263.rb
+++ b/vendor/plugins/rspec/spec/spec/mocks/bug_report_10263_spec.rb
@@ -16,7 +16,7 @@ describe "Mock" do
@mock.rspec_verify
begin
@mock.foobar
- rescue => e
+ rescue Exception => e
e.message.should == "Mock 'test mock' received unexpected message :foobar with (no args)"
end
end
diff --git a/vendor/plugins/rspec/spec/spec/mocks/bug_report_11545_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/bug_report_11545_spec.rb
index 8a334afa5..212a50e9f 100644
--- a/vendor/plugins/rspec/spec/spec/mocks/bug_report_11545_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/mocks/bug_report_11545_spec.rb
@@ -1,6 +1,8 @@
require File.dirname(__FILE__) + '/../../spec_helper.rb'
class LiarLiarPantsOnFire
+ include Spec::MetaClass
+ extend Spec::MetaClass
def respond_to?(sym)
true
end
diff --git a/vendor/plugins/rspec/spec/spec/mocks/failing_mock_argument_constraints_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/failing_mock_argument_constraints_spec.rb
index db6dcea34..3993cbfc6 100644
--- a/vendor/plugins/rspec/spec/spec/mocks/failing_mock_argument_constraints_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/mocks/failing_mock_argument_constraints_spec.rb
@@ -75,6 +75,14 @@ module Spec
@mock.msg(37)
end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (no args) but received it with (37)")
end
+
+ it "should fail hash_including with missing key" do
+ lambda do
+ @mock.should_receive(:msg).with(hash_including(:a => 1))
+ @mock.msg({})
+ end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (hash_including(:a=>1)) but received it with ({})")
+ end
+
end
describe "failing deprecated MockArgumentConstraints" do
diff --git a/vendor/plugins/rspec/spec/spec/mocks/hash_including_matcher_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/hash_including_matcher_spec.rb
new file mode 100644
index 000000000..29fae3101
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/mocks/hash_including_matcher_spec.rb
@@ -0,0 +1,32 @@
+require File.dirname(__FILE__) + '/../../spec_helper.rb'
+
+module Spec
+ module Mocks
+ describe HashIncludingConstraint do
+
+ it "should match the same hash" do
+ hash_including(:a => 1).matches?(:a => 1).should be_true
+ end
+
+ it "should not match a non-hash" do
+ hash_including(:a => 1).matches?(1).should_not be_true
+ end
+
+ it "should match a hash with extra stuff" do
+ hash_including(:a => 1).matches?(:a => 1, :b => 2).should be_true
+ end
+
+ it "should not match a hash with a missing key" do
+ hash_including(:a => 1).matches?(:b => 2).should_not be_true
+ end
+
+ it "should not match a hash with an incorrect value" do
+ hash_including(:a => 1, :b => 2).matches?(:a => 1, :b => 3).should_not be_true
+ end
+
+ it "should describe itself properly" do
+ HashIncludingConstraint.new(:a => 1).description.should == "hash_including(:a=>1)"
+ end
+ end
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec/spec/spec/mocks/mock_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/mock_spec.rb
index 85a71e327..f6d377f7d 100644
--- a/vendor/plugins/rspec/spec/spec/mocks/mock_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/mocks/mock_spec.rb
@@ -37,18 +37,16 @@ module Spec
it "should fail when receiving message specified as not to be received" do
@mock.should_not_receive(:not_expected)
- @mock.not_expected
lambda {
- @mock.rspec_verify
+ @mock.not_expected
violated
- }.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (any args) 0 times, but received it once")
+ }.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
end
it "should fail when receiving message specified as not to be received with args" do
@mock.should_not_receive(:not_expected).with("unexpected text")
- @mock.not_expected("unexpected text")
lambda {
- @mock.rspec_verify
+ @mock.not_expected("unexpected text")
violated
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (\"unexpected text\") 0 times, but received it once")
end
@@ -77,7 +75,7 @@ module Spec
@mock.rspec_verify
end
- it "should raise exception if args dont match when method called" do
+ it "should raise exception if args don't match when method called" do
@mock.should_receive(:something).with("a","b","c").and_return("booh")
lambda {
@mock.something("a","d","c")
@@ -85,6 +83,24 @@ module Spec
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")")
end
+ it "should raise exception if args don't match when method called even when the method is stubbed" do
+ @mock.stub!(:something)
+ @mock.should_receive(:something).with("a","b","c")
+ lambda {
+ @mock.something("a","d","c")
+ @mock.rspec_verify
+ }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")")
+ end
+
+ it "should raise exception if args don't match when method called even when using null_object" do
+ @mock = mock("test mock", :null_object => true)
+ @mock.should_receive(:something).with("a","b","c")
+ lambda {
+ @mock.something("a","d","c")
+ @mock.rspec_verify
+ }.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")")
+ end
+
it "should fail if unexpected method called" do
lambda {
@mock.something("a","b","c")
@@ -110,23 +126,19 @@ module Spec
end
it "should fail right away when method defined as never is received" do
- pending "Used to pass (false positive). Which one is wrong, the spec or the actual behavior?"
-
@mock.should_receive(:not_expected).never
lambda {
@mock.not_expected
- }.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected 0 times, but received it 1 times")
+ }.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
end
it "should eventually fail when method defined as never is received" do
@mock.should_receive(:not_expected).never
- @mock.not_expected
-
lambda {
- @mock.rspec_verify
- }.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (any args) 0 times, but received it once")
+ @mock.not_expected
+ }.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
end
-
+
it "should raise when told to" do
@mock.should_receive(:something).and_raise(RuntimeError)
lambda do
@@ -186,14 +198,20 @@ module Spec
@mock.something 1
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (no args) but received it with (1)")
end
-
+
it "should fail when args are expected but none are received" do
@mock.should_receive(:something).with(1)
lambda {
@mock.something
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (1) but received it with (no args)")
end
-
+
+ it "should return value from block by default" do
+ @mock.stub!(:method_that_yields).and_yield
+ @mock.method_that_yields { :returned_obj }.should == :returned_obj
+ @mock.rspec_verify
+ end
+
it "should yield 0 args to blocks that take a variable number of arguments" do
@mock.should_receive(:yield_back).with(no_args()).once.and_yield
a = nil
@@ -238,7 +256,7 @@ module Spec
a.should == [99, 27, "go"]
@mock.rspec_verify
end
-
+
it "should yield many args 3 times consecutively to blocks that take a variable number of arguments" do
@mock.should_receive(:yield_back).once.with(no_args()).once.and_yield(99, :green, "go").
and_yield("wait", :amber).
@@ -347,7 +365,7 @@ module Spec
mock.rspec_reset
mock.rspec_verify #should throw if reset didn't work
end
-
+
it "should work even after method_missing starts raising NameErrors instead of NoMethodErrors" do
# Object#method_missing throws either NameErrors or NoMethodErrors.
#
@@ -376,7 +394,7 @@ module Spec
lambda { @mock.foobar }.should_not raise_error(NameError)
lambda { @mock.foobar }.should raise_error(MockExpectationError)
end
-
+
it "should temporarily replace a method stub on a mock" do
@mock.stub!(:msg).and_return(:stub_value)
@mock.should_receive(:msg).with(:arg).and_return(:mock_value)
@@ -385,7 +403,7 @@ module Spec
@mock.msg.should equal(:stub_value)
@mock.rspec_verify
end
-
+
it "should temporarily replace a method stub on a non-mock" do
non_mock = Object.new
non_mock.stub!(:msg).and_return(:stub_value)
@@ -400,8 +418,9 @@ module Spec
mock = Mock.new('name', :message => :response)
mock.message.should == :response
end
+
end
-
+
describe "a mock message receiving a block" do
before(:each) do
@mock = mock("mock")
@@ -414,60 +433,60 @@ module Spec
it "should call the block after #should_receive" do
@mock.should_receive(:foo) { add_call }
-
+
@mock.foo
-
+
@calls.should == 1
end
-
+
it "should call the block after #once" do
@mock.should_receive(:foo).once { add_call }
-
+
@mock.foo
-
+
@calls.should == 1
end
-
+
it "should call the block after #twice" do
@mock.should_receive(:foo).twice { add_call }
-
+
@mock.foo
@mock.foo
-
+
@calls.should == 2
end
-
+
it "should call the block after #times" do
@mock.should_receive(:foo).exactly(10).times { add_call }
(1..10).each { @mock.foo }
-
+
@calls.should == 10
end
-
+
it "should call the block after #any_number_of_times" do
@mock.should_receive(:foo).any_number_of_times { add_call }
(1..7).each { @mock.foo }
-
+
@calls.should == 7
end
-
+
it "should call the block after #with" do
@mock.should_receive(:foo).with(:arg) { add_call }
@mock.foo(:arg)
-
+
@calls.should == 1
end
-
+
it "should call the block after #ordered" do
@mock.should_receive(:foo).ordered { add_call }
@mock.should_receive(:bar).ordered { add_call }
@mock.foo
@mock.bar
-
+
@calls.should == 2
end
end
diff --git a/vendor/plugins/rspec/spec/spec/mocks/partial_mock_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/partial_mock_spec.rb
index d7e5944c4..25472557f 100644
--- a/vendor/plugins/rspec/spec/spec/mocks/partial_mock_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/mocks/partial_mock_spec.rb
@@ -21,11 +21,11 @@ module Spec
end
it "should_not_receive should mock out the method" do
+ pending("example raises the expected error, yet fails")
@object.should_not_receive(:fuhbar)
- @object.fuhbar
lambda do
- @object.rspec_verify
- end.should raise_error(Spec::Mocks::MockExpectationError)
+ @object.fuhbar
+ end.should raise_error(MockExpectationError, "Mock 'Object' expected :fuhbar with (no args) 0 times, but received it once")
end
it "should_not_receive should return a negative message expectation" do
@@ -66,10 +66,10 @@ module Spec
end
it "should_not_receive should also take a String argument" do
+ pending("example raises the expected error, yet fails")
@object.should_not_receive('foobar')
- @object.foobar
lambda do
- @object.rspec_verify
+ @object.foobar
end.should raise_error(Spec::Mocks::MockExpectationError)
end
@@ -102,5 +102,41 @@ module Spec
lambda { o.stub!(:bar) }.should_not raise_error(NoMethodError)
end
end
+
+ describe "Method visibility when using partial mocks" do
+ class MockableClass
+ def public_method
+ private_method
+ protected_method
+ end
+ protected
+ def protected_method; end
+ private
+ def private_method; end
+ end
+
+ before(:each) do
+ @object = MockableClass.new
+ end
+
+ it 'should keep public methods public' do
+ @object.should_receive(:public_method)
+ @object.public_methods.should include('public_method')
+ @object.public_method
+ end
+
+ it 'should keep private methods private' do
+ @object.should_receive(:private_method)
+ @object.private_methods.should include('private_method')
+ @object.public_method
+ end
+
+ it 'should keep protected methods protected' do
+ @object.should_receive(:protected_method)
+ @object.protected_methods.should include('protected_method')
+ @object.public_method
+ end
+
+ end
end
end
diff --git a/vendor/plugins/rspec/spec/spec/mocks/passing_mock_argument_constraints_spec.rb b/vendor/plugins/rspec/spec/spec/mocks/passing_mock_argument_constraints_spec.rb
index 6de0a58f4..057af44fa 100644
--- a/vendor/plugins/rspec/spec/spec/mocks/passing_mock_argument_constraints_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/mocks/passing_mock_argument_constraints_spec.rb
@@ -109,6 +109,12 @@ module Spec
@mock.should_receive(:random_call).with(no_args)
@mock.random_call()
end
+
+ it "should match hash with hash_including same hash" do
+ @mock.should_receive(:random_call).with(hash_including(:a => 1))
+ @mock.random_call(:a => 1)
+ end
+
end
describe Methods, "handling non-constraint arguments" do
diff --git a/vendor/plugins/rspec/spec/spec/runner/command_line_spec.rb b/vendor/plugins/rspec/spec/spec/runner/command_line_spec.rb
index 8b9e912a7..3c3be8cea 100644
--- a/vendor/plugins/rspec/spec/spec/runner/command_line_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/runner/command_line_spec.rb
@@ -12,7 +12,7 @@ module Spec
it "should run directory" do
file = File.dirname(__FILE__) + '/../../../examples/pure'
- Spec::Runner::CommandLine.run(OptionParser.parse([file], @err, @out))
+ Spec::Runner::CommandLine.run(OptionParser.parse([file,"-p","**/*.rb"], @err, @out))
@out.rewind
@out.read.should =~ /\d+ examples, 0 failures, 3 pending/n
@@ -35,8 +35,9 @@ module Spec
end
it "should return true when in --generate-options mode" do
+ # NOTE - this used to say /dev/null but jruby hangs on that for some reason
Spec::Runner::CommandLine.run(
- OptionParser.parse(['--generate-options', '/dev/null'], @err, @out)
+ OptionParser.parse(['--generate-options', '/tmp/foo'], @err, @out)
).should be_true
end
diff --git a/vendor/plugins/rspec/spec/spec/runner/execution_context_spec.rb b/vendor/plugins/rspec/spec/spec/runner/execution_context_spec.rb
index 82e7447c1..2c8c23f18 100644
--- a/vendor/plugins/rspec/spec/spec/runner/execution_context_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/runner/execution_context_spec.rb
@@ -7,7 +7,13 @@ describe "ExecutionContext" do
dt.should be_an_instance_of(Spec::Mocks::DuckTypeArgConstraint)
dt.matches?([]).should be_true
end
-
+
+ it "should provide hash_including" do
+ hi = hash_including(:a => 1)
+ hi.should be_an_instance_of(Spec::Mocks::HashIncludingConstraint)
+ hi.matches?(:a => 1).should be_true
+ end
+
it "should violate when violated()" do
lambda do
violated
diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb
index a08b6e86d..e54cdb09f 100644
--- a/vendor/plugins/rspec/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb
@@ -20,9 +20,10 @@ module Spec
formatter.add_example_group(Class.new(ExampleGroup).describe("b 2"))
formatter.example_failed("e 2", nil, Reporter::Failure.new(nil, RuntimeError.new))
formatter.example_failed("e 3", nil, Reporter::Failure.new(nil, RuntimeError.new))
- io.string.should == "b 1\nb 2\n"
+ io.string.should include("b 1")
+ io.string.should include("b 2")
end
-
+
it "should delimit ExampleGroup superclass descriptions with :" do
parent_example_group = Class.new(example_group).describe("Parent")
child_example_group = Class.new(parent_example_group).describe("#child_method")
diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html
new file mode 100644
index 000000000..466621865
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html
@@ -0,0 +1,381 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>RSpec results</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="Expires" content="-1" />
+ <meta http-equiv="Pragma" content="no-cache" />
+ <style type="text/css">
+ body {
+ margin: 0;
+ padding: 0;
+ background: #fff;
+ font-size: 80%;
+ }
+ </style>
+</head>
+<body>
+<div class="rspec-report">
+ <script type="text/javascript">
+ // <![CDATA[
+function moveProgressBar(percentDone) {
+ document.getElementById("rspec-header").style.width = percentDone +"%";
+}
+function makeRed(element_id) {
+ document.getElementById(element_id).style.background = '#C40D0D';
+ document.getElementById(element_id).style.color = '#FFFFFF';
+}
+
+function makeYellow(element_id) {
+ if (element_id == "rspec-header" && document.getElementById(element_id).style.background != '#C40D0D')
+ {
+ document.getElementById(element_id).style.background = '#FAF834';
+ document.getElementById(element_id).style.color = '#000000';
+ }
+ else
+ {
+ document.getElementById(element_id).style.background = '#FAF834';
+ document.getElementById(element_id).style.color = '#000000';
+ }
+}
+
+ // ]]>
+ </script>
+ <style type="text/css">
+#rspec-header {
+ background: #65C400; color: #fff;
+}
+
+.rspec-report h1 {
+ margin: 0px 10px 0px 10px;
+ padding: 10px;
+ font-family: "Lucida Grande", Helvetica, sans-serif;
+ font-size: 1.8em;
+}
+
+#summary {
+ margin: 0; padding: 5px 10px;
+ font-family: "Lucida Grande", Helvetica, sans-serif;
+ text-align: right;
+ position: absolute;
+ top: 0px;
+ right: 0px;
+}
+
+#summary p {
+ margin: 0 0 0 2px;
+}
+
+#summary #totals {
+ font-size: 1.2em;
+}
+
+.example_group {
+ margin: 0 10px 5px;
+ background: #fff;
+}
+
+dl {
+ margin: 0; padding: 0 0 5px;
+ font: normal 11px "Lucida Grande", Helvetica, sans-serif;
+}
+
+dt {
+ padding: 3px;
+ background: #65C400;
+ color: #fff;
+ font-weight: bold;
+}
+
+dd {
+ margin: 5px 0 5px 5px;
+ padding: 3px 3px 3px 18px;
+}
+
+dd.spec.passed {
+ border-left: 5px solid #65C400;
+ border-bottom: 1px solid #65C400;
+ background: #DBFFB4; color: #3D7700;
+}
+
+dd.spec.failed {
+ border-left: 5px solid #C20000;
+ border-bottom: 1px solid #C20000;
+ color: #C20000; background: #FFFBD3;
+}
+
+dd.spec.not_implemented {
+ border-left: 5px solid #FAF834;
+ border-bottom: 1px solid #FAF834;
+ background: #FCFB98; color: #131313;
+}
+
+dd.spec.pending_fixed {
+ border-left: 5px solid #0000C2;
+ border-bottom: 1px solid #0000C2;
+ color: #0000C2; background: #D3FBFF;
+}
+
+.backtrace {
+ color: #000;
+ font-size: 12px;
+}
+
+a {
+ color: #BE5C00;
+}
+
+/* Ruby code, style similar to vibrant ink */
+.ruby {
+ font-size: 12px;
+ font-family: monospace;
+ color: white;
+ background-color: black;
+ padding: 0.1em 0 0.2em 0;
+}
+
+.ruby .keyword { color: #FF6600; }
+.ruby .constant { color: #339999; }
+.ruby .attribute { color: white; }
+.ruby .global { color: white; }
+.ruby .module { color: white; }
+.ruby .class { color: white; }
+.ruby .string { color: #66FF00; }
+.ruby .ident { color: white; }
+.ruby .method { color: #FFCC00; }
+.ruby .number { color: white; }
+.ruby .char { color: white; }
+.ruby .comment { color: #9933CC; }
+.ruby .symbol { color: white; }
+.ruby .regex { color: #44B4CC; }
+.ruby .punct { color: white; }
+.ruby .escape { color: white; }
+.ruby .interp { color: white; }
+.ruby .expr { color: white; }
+
+.ruby .offending { background-color: gray; }
+.ruby .linenum {
+ width: 75px;
+ padding: 0.1em 1em 0.2em 0;
+ color: #000000;
+ background-color: #FFFBD3;
+}
+
+ </style>
+
+<div id="rspec-header">
+ <h1>RSpec Results</h1>
+
+ <div id="summary">
+ <p id="totals">&nbsp;</p>
+ <p id="duration">&nbsp;</p>
+ </div>
+</div>
+
+<div class="results">
+<div class="example_group">
+ <dl>
+ <dt id="example_group_1">Mocker</dt>
+ <script type="text/javascript">moveProgressBar('5.8');</script>
+ <dd class="spec passed"><span class="passed_spec_name">should be able to call mock()</span></dd>
+ <script type="text/javascript">makeRed('rspec-header');</script>
+ <script type="text/javascript">makeRed('example_group_1');</script>
+ <script type="text/javascript">moveProgressBar('11.7');</script>
+ <dd class="spec failed">
+ <span class="failed_spec_name">should fail when expected message not received</span>
+ <div class="failure" id="failure_1">
+ <div class="message"><pre>Mock 'poke me' expected :poke with (any args) once, but received it 0 times</pre></div>
+ <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:13:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:28:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `chdir'
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `instance_eval'</pre></div>
+ <pre class="ruby"><code><span class="linenum">11</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">should fail when expected message not received</span><span class="punct">&quot;</span> <span class="keyword">do</span>
+<span class="linenum">12</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">(&quot;</span><span class="string">poke me</span><span class="punct">&quot;)</span>
+<span class="offending"><span class="linenum">13</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span>
+<span class="linenum">14</span> <span class="keyword">end</span>
+<span class="linenum">15</span> </code></pre>
+ </div>
+ </dd>
+ <script type="text/javascript">moveProgressBar('17.6');</script>
+ <dd class="spec failed">
+ <span class="failed_spec_name">should fail when messages are received out of order</span>
+ <div class="failure" id="failure_2">
+ <div class="message"><pre>Mock 'one two three' received :three out of order</pre></div>
+ <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:22:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:16:in `instance_eval'
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:28:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `chdir'
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `instance_eval'</pre></div>
+ <pre class="ruby"><code><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span>
+<span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span>
+<span class="offending"><span class="linenum">22</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span>
+<span class="linenum">23</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">two</span>
+<span class="linenum">24</span> <span class="keyword">end</span></code></pre>
+ </div>
+ </dd>
+ <script type="text/javascript">moveProgressBar('23.5');</script>
+ <dd class="spec failed">
+ <span class="failed_spec_name">should get yelled at when sending unexpected messages</span>
+ <div class="failure" id="failure_3">
+ <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (any args) 0 times, but received it once</pre></div>
+ <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:28:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:28:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `chdir'
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `instance_eval'</pre></div>
+ <pre class="ruby"><code><span class="linenum">26</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">should get yelled at when sending unexpected messages</span><span class="punct">&quot;</span> <span class="keyword">do</span>
+<span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">(&quot;</span><span class="string">don't talk to me</span><span class="punct">&quot;)</span>
+<span class="offending"><span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span></span>
+<span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span>
+<span class="linenum">30</span> <span class="keyword">end</span></code></pre>
+ </div>
+ </dd>
+ <script type="text/javascript">moveProgressBar('29.4');</script>
+ <dd class="spec pending_fixed">
+ <span class="failed_spec_name">has a bug we need to fix</span>
+ <div class="failure" id="failure_4">
+ <div class="message"><pre>Expected pending 'here is the bug' to fail. No Error was raised.</pre></div>
+ <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:33:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/mocking_example.rb:33:in `instance_eval'
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:28:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `chdir'
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `instance_eval'</pre></div>
+ <pre class="ruby"><code><span class="linenum">31</span>
+<span class="linenum">32</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">has a bug we need to fix</span><span class="punct">&quot;</span> <span class="keyword">do</span>
+<span class="offending"><span class="linenum">33</span> <span class="ident">pending</span> <span class="punct">&quot;</span><span class="string">here is the bug</span><span class="punct">&quot;</span> <span class="keyword">do</span></span>
+<span class="linenum">34</span> <span class="comment"># Actually, no. It's fixed. This will fail because it passes :-)</span>
+<span class="linenum">35</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">(&quot;</span><span class="string">Bug</span><span class="punct">&quot;)</span></code></pre>
+ </div>
+ </dd>
+ </dl>
+</div>
+<div class="example_group">
+ <dl>
+ <dt id="example_group_2">Running specs with --diff</dt>
+ <script type="text/javascript">makeRed('example_group_2');</script>
+ <script type="text/javascript">moveProgressBar('35.2');</script>
+ <dd class="spec failed">
+ <span class="failed_spec_name">should print diff of different strings</span>
+ <div class="failure" id="failure_5">
+ <div class="message"><pre>expected: &quot;RSpec is a\nbehaviour driven development\nframework for Ruby\n&quot;,
+ got: &quot;RSpec is a\nbehavior driven development\nframework for Ruby\n&quot; (using ==)
+Diff:
+@@ -1,4 +1,4 @@
+ RSpec is a
+-behavior driven development
++behaviour driven development
+ framework for Ruby
+</pre></div>
+ <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/diffing_spec.rb:13:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/diffing_spec.rb:2:in `instance_eval'
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:28:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `chdir'
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `instance_eval'</pre></div>
+ <pre class="ruby"><code><span class="linenum">11</span><span class="ident">framework</span> <span class="keyword">for</span> <span class="constant">Ruby</span>
+<span class="linenum">12</span><span class="constant">EOF</span>
+<span class="offending"><span class="linenum">13</span> <span class="ident">usa</span><span class="punct">.</span><span class="ident">should</span> <span class="punct">==</span> <span class="ident">uk</span></span>
+<span class="linenum">14</span> <span class="keyword">end</span></code></pre>
+ </div>
+ </dd>
+ <script type="text/javascript">moveProgressBar('41.1');</script>
+ <dd class="spec failed">
+ <span class="failed_spec_name">should print diff of different objects' pretty representation</span>
+ <div class="failure" id="failure_6">
+ <div class="message"><pre>expected &lt;Animal
+name=bob,
+species=tortoise
+&gt;
+, got &lt;Animal
+name=bob,
+species=giraffe
+&gt;
+ (using .eql?)
+Diff:
+@@ -1,5 +1,5 @@
+ &lt;Animal
+ name=bob,
+-species=giraffe
++species=tortoise
+ &gt;
+</pre></div>
+ <div class="backtrace"><pre>/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/diffing_spec.rb:34:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./failing_examples/diffing_spec.rb:31:in `instance_eval'
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:28:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `chdir'
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:
+/Users/david/projects/ruby/jruby/testsuites/rspec/target/rspec/./spec/spec/runner/formatter/html_formatter_spec.rb:24:in `instance_eval'</pre></div>
+ <pre class="ruby"><code><span class="linenum">32</span> <span class="ident">expected</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">&quot;</span><span class="string">bob</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">giraffe</span><span class="punct">&quot;</span>
+<span class="linenum">33</span> <span class="ident">actual</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">&quot;</span><span class="string">bob</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">tortoise</span><span class="punct">&quot;</span>
+<span class="offending"><span class="linenum">34</span> <span class="ident">expected</span><span class="punct">.</span><span class="ident">should</span> <span class="ident">eql</span><span class="punct">(</span><span class="ident">actual</span><span class="punct">)</span></span>
+<span class="linenum">35</span> <span class="keyword">end</span>
+<span class="linenum">36</span><span class="keyword">end</span></code></pre>
+ </div>
+ </dd>
+ </dl>
+</div>
+<div class="example_group">
+ <dl>
+ <dt id="example_group_3">A consumer of a stub</dt>
+ <script type="text/javascript">moveProgressBar('47.0');</script>
+ <dd class="spec passed"><span class="passed_spec_name">should be able to stub methods on any Object</span></dd>
+ </dl>
+</div>
+<div class="example_group">
+ <dl>
+ <dt id="example_group_4">A stubbed method on a class</dt>
+ <script type="text/javascript">moveProgressBar('52.9');</script>
+ <dd class="spec passed"><span class="passed_spec_name">should return the stubbed value</span></dd>
+ <script type="text/javascript">moveProgressBar('58.8');</script>
+ <dd class="spec passed"><span class="passed_spec_name">should revert to the original method after each spec</span></dd>
+ <script type="text/javascript">moveProgressBar('64.7');</script>
+ <dd class="spec passed"><span class="passed_spec_name">can stub! and mock the same message</span></dd>
+ </dl>
+</div>
+<div class="example_group">
+ <dl>
+ <dt id="example_group_5">A mock</dt>
+ <script type="text/javascript">moveProgressBar('70.5');</script>
+ <dd class="spec passed"><span class="passed_spec_name">can stub!</span></dd>
+ <script type="text/javascript">moveProgressBar('76.4');</script>
+ <dd class="spec passed"><span class="passed_spec_name">can stub! and mock</span></dd>
+ <script type="text/javascript">moveProgressBar('82.3');</script>
+ <dd class="spec passed"><span class="passed_spec_name">can stub! and mock the same message</span></dd>
+ </dl>
+</div>
+<div class="example_group">
+ <dl>
+ <dt id="example_group_6">pending example (using pending method)</dt>
+ <script type="text/javascript">makeYellow('example_group_6');</script>
+ <script type="text/javascript">moveProgressBar('88.2');</script>
+ <dd class="spec not_implemented"><span class="not_implemented_spec_name">should be reported as &quot;PENDING: for some reason&quot; (PENDING: for some reason)</span></dd>
+ </dl>
+</div>
+<div class="example_group">
+ <dl>
+ <dt id="example_group_7">pending example (with no block)</dt>
+ <script type="text/javascript">makeYellow('example_group_7');</script>
+ <script type="text/javascript">moveProgressBar('94.1');</script>
+ <dd class="spec not_implemented"><span class="not_implemented_spec_name">should be reported as &quot;PENDING: Not Yet Implemented&quot; (PENDING: Not Yet Implemented)</span></dd>
+ </dl>
+</div>
+<div class="example_group">
+ <dl>
+ <dt id="example_group_8">pending example (with block for pending)</dt>
+ <script type="text/javascript">makeYellow('example_group_8');</script>
+ <script type="text/javascript">moveProgressBar('100.0');</script>
+ <dd class="spec not_implemented"><span class="not_implemented_spec_name">should have a failing block, passed to pending, reported as &quot;PENDING: for some reason&quot; (PENDING: for some reason)</span></dd>
+ </dl>
+</div>
+<script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>x seconds</strong>";</script>
+<script type="text/javascript">document.getElementById('totals').innerHTML = "17 examples, 6 failures, 3 pending";</script>
+</div>
+</div>
+</body>
+</html>
diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6.html b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6.html
index 511495bcd..bc6637583 100644
--- a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6.html
+++ b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatted-1.8.6.html
@@ -189,9 +189,9 @@ a {
<div class="failure" id="failure_1">
<div class="message"><pre>Mock 'poke me' expected :poke with (any args) once, but received it 0 times</pre></div>
<div class="backtrace"><pre>./failing_examples/mocking_example.rb:13:
-./spec/spec/runner/formatter/html_formatter_spec.rb:18:
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:in `chdir'
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:</pre></div>
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
<pre class="ruby"><code><span class="linenum">11</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">should fail when expected message not received</span><span class="punct">&quot;</span> <span class="keyword">do</span>
<span class="linenum">12</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">(&quot;</span><span class="string">poke me</span><span class="punct">&quot;)</span>
<span class="offending"><span class="linenum">13</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span>
@@ -205,9 +205,9 @@ a {
<div class="failure" id="failure_2">
<div class="message"><pre>Mock 'one two three' received :three out of order</pre></div>
<div class="backtrace"><pre>./failing_examples/mocking_example.rb:22:
-./spec/spec/runner/formatter/html_formatter_spec.rb:18:
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:in `chdir'
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:</pre></div>
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
<pre class="ruby"><code><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span>
<span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span>
<span class="offending"><span class="linenum">22</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span>
@@ -219,15 +219,14 @@ a {
<dd class="spec failed">
<span class="failed_spec_name">should get yelled at when sending unexpected messages</span>
<div class="failure" id="failure_3">
- <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (any args) 0 times, but received it once</pre></div>
- <div class="backtrace"><pre>./failing_examples/mocking_example.rb:28:
-./spec/spec/runner/formatter/html_formatter_spec.rb:18:
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:in `chdir'
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:</pre></div>
- <pre class="ruby"><code><span class="linenum">26</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">should get yelled at when sending unexpected messages</span><span class="punct">&quot;</span> <span class="keyword">do</span>
-<span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">(&quot;</span><span class="string">don't talk to me</span><span class="punct">&quot;)</span>
-<span class="offending"><span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span></span>
-<span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span>
+ <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (no args) 0 times, but received it once</pre></div>
+ <div class="backtrace"><pre>./failing_examples/mocking_example.rb:29:
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
+ <pre class="ruby"><code><span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">(&quot;</span><span class="string">don't talk to me</span><span class="punct">&quot;)</span>
+<span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span>
+<span class="offending"><span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span></span>
<span class="linenum">30</span> <span class="keyword">end</span></code></pre>
</div>
</dd>
@@ -236,7 +235,10 @@ a {
<span class="failed_spec_name">has a bug we need to fix</span>
<div class="failure" id="failure_4">
<div class="message"><pre>Expected pending 'here is the bug' to fail. No Error was raised.</pre></div>
-
+ <div class="backtrace"><pre>./failing_examples/mocking_example.rb:33:
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
<pre class="ruby"><code><span class="linenum">31</span>
<span class="linenum">32</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">has a bug we need to fix</span><span class="punct">&quot;</span> <span class="keyword">do</span>
<span class="offending"><span class="linenum">33</span> <span class="ident">pending</span> <span class="punct">&quot;</span><span class="string">here is the bug</span><span class="punct">&quot;</span> <span class="keyword">do</span></span>
@@ -259,11 +261,14 @@ a {
Diff:
@@ -1,4 +1,4 @@
RSpec is a
--behavior driven development
-+behaviour driven development
+-behaviour driven development
++behavior driven development
framework for Ruby
</pre></div>
-
+ <div class="backtrace"><pre>./failing_examples/diffing_spec.rb:13:
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
<pre class="ruby"><code><span class="linenum">11</span><span class="ident">framework</span> <span class="keyword">for</span> <span class="constant">Ruby</span>
<span class="linenum">12</span><span class="constant">EOF</span>
<span class="offending"><span class="linenum">13</span> <span class="ident">usa</span><span class="punct">.</span><span class="ident">should</span> <span class="punct">==</span> <span class="ident">uk</span></span>
@@ -287,14 +292,14 @@ Diff:
@@ -1,5 +1,5 @@
&lt;Animal
name=bob,
--species=giraffe
-+species=tortoise
+-species=tortoise
++species=giraffe
&gt;
</pre></div>
- <div class="backtrace"><pre>./failing_examples/mocking_example.rb:33:
-./spec/spec/runner/formatter/html_formatter_spec.rb:18:
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:in `chdir'
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:</pre></div>
+ <div class="backtrace"><pre>./failing_examples/diffing_spec.rb:34:
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
+/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
<pre class="ruby"><code><span class="linenum">32</span> <span class="ident">expected</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">&quot;</span><span class="string">bob</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">giraffe</span><span class="punct">&quot;</span>
<span class="linenum">33</span> <span class="ident">actual</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">&quot;</span><span class="string">bob</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">tortoise</span><span class="punct">&quot;</span>
<span class="offending"><span class="linenum">34</span> <span class="ident">expected</span><span class="punct">.</span><span class="ident">should</span> <span class="ident">eql</span><span class="punct">(</span><span class="ident">actual</span><span class="punct">)</span></span>
diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatter_spec.rb
index 5ba39f0e9..f6388267f 100644
--- a/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatter_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/runner/formatter/html_formatter_spec.rb
@@ -17,9 +17,6 @@ module Spec
expected_file = File.dirname(__FILE__) + "/html_formatted-#{::VERSION}#{suffix}.html"
raise "There is no HTML file with expected content for this platform: #{expected_file}" unless File.file?(expected_file)
expected_html = File.read(expected_file)
- unless jruby?
- raise "There should be no absolute paths in html_formatted.html!!" if (expected_html =~ /\/Users/n || expected_html =~ /\/home/n)
- end
Dir.chdir(root) do
args = ['failing_examples/mocking_example.rb', 'failing_examples/diffing_spec.rb', 'examples/pure/stubbing_example.rb', 'examples/pure/pending_example.rb', '--format', 'html', opt]
diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/nested_text_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/nested_text_formatter_spec.rb
new file mode 100644
index 000000000..3a627451e
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/runner/formatter/nested_text_formatter_spec.rb
@@ -0,0 +1,333 @@
+require File.dirname(__FILE__) + '/../../../spec_helper.rb'
+require 'spec/runner/formatter/nested_text_formatter'
+
+module Spec
+ module Runner
+ module Formatter
+ describe NestedTextFormatter do
+ it_should_behave_like "sandboxed rspec_options"
+ attr_reader :io, :options, :formatter, :example_group
+ before(:each) do
+ @io = StringIO.new
+ options.stub!(:dry_run).and_return(false)
+ options.stub!(:colour).and_return(false)
+ @formatter = NestedTextFormatter.new(options, io)
+ @example_group = ::Spec::Example::ExampleGroup.describe("ExampleGroup") do
+ specify "example" do
+ end
+ end
+ end
+
+ describe "where ExampleGroup has no superclasss with a description" do
+ before do
+ add_example_group
+ end
+
+ def add_example_group
+ formatter.add_example_group(example_group)
+ end
+
+ describe "#dump_summary" do
+ it "should produce standard summary without pending when pending has a 0 count" do
+ formatter.dump_summary(3, 2, 1, 0)
+ expected_output = <<-OUT
+ ExampleGroup
+
+ Finished in 3 seconds
+
+ 2 examples, 1 failure
+ OUT
+
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+
+ it "should produce standard summary" do
+ formatter.dump_summary(3, 2, 1, 4)
+ expected_output = <<-OUT
+ ExampleGroup
+
+ Finished in 3 seconds
+
+ 2 examples, 1 failure, 4 pending
+ OUT
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+ end
+
+ describe "#add_example_group" do
+ describe "when ExampleGroup has description_args" do
+ before do
+ example_group.description_args.should_not be_nil
+ end
+
+ describe "when ExampleGroup has no parents with description args" do
+ before do
+ example_group.superclass.description_args.should be_nil
+ end
+
+ it "should push ExampleGroup name" do
+ io.string.should eql("ExampleGroup\n")
+ end
+ end
+
+ describe "when ExampleGroup has one parent with description args" do
+ attr_reader :child_example_group
+ def add_example_group
+ example_group.description_args.should_not be_nil
+ @child_example_group = Class.new(example_group).describe("Child ExampleGroup")
+ end
+
+ describe "and parent ExampleGroups have not been printed" do
+ before do
+ formatter.add_example_group(child_example_group)
+ end
+
+ it "should push ExampleGroup name with two spaces of indentation" do
+ expected_output = <<-OUT
+ ExampleGroup
+ Child ExampleGroup
+ OUT
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+ end
+
+ describe "and parent ExampleGroups have been printed" do
+ before do
+ formatter.add_example_group(example_group)
+ io.string = ""
+ formatter.add_example_group(child_example_group)
+ end
+
+ it "should print only the indented ExampleGroup" do
+ expected_output = <<-OUT
+ Child ExampleGroup
+ OUT
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+ end
+ end
+
+ describe "when ExampleGroup has two parents with description args" do
+ attr_reader :child_example_group, :grand_child_example_group
+ def add_example_group
+ example_group.description_args.should_not be_nil
+ @child_example_group = Class.new(example_group).describe("Child ExampleGroup")
+ @grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup")
+ end
+
+ describe "and parent ExampleGroups have not been printed" do
+ before do
+ formatter.add_example_group(grand_child_example_group)
+ end
+
+ it "should print the entire nested ExampleGroup heirarchy" do
+ expected_output = <<-OUT
+ ExampleGroup
+ Child ExampleGroup
+ GrandChild ExampleGroup
+ OUT
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+ end
+
+ describe "and parent ExampleGroups have been printed" do
+ before do
+ formatter.add_example_group(child_example_group)
+ io.string = ""
+ formatter.add_example_group(grand_child_example_group)
+ end
+
+ it "should print only the indented ExampleGroup" do
+ expected_output = <<-OUT
+ GrandChild ExampleGroup
+ OUT
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+ end
+ end
+ end
+
+ describe "when ExampleGroup description_args is nil" do
+ attr_reader :child_example_group
+
+ describe "and parent ExampleGroups have not been printed" do
+ def add_example_group
+ @child_example_group = Class.new(example_group)
+ child_example_group.description_args.should be_nil
+ formatter.add_example_group(child_example_group)
+ end
+
+ it "should render only the parent ExampleGroup" do
+ expected_output = <<-OUT
+ ExampleGroup
+ OUT
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+ end
+
+ describe "and parent ExampleGroups have been printed" do
+ def add_example_group
+ @child_example_group = Class.new(example_group)
+ child_example_group.description_args.should be_nil
+ formatter.add_example_group(example_group)
+ io.string = ""
+ formatter.add_example_group(child_example_group)
+ end
+
+ it "should not render anything" do
+ io.string.should == ""
+ end
+ end
+ end
+
+ describe "when ExampleGroup description_args is empty" do
+ def add_example_group
+ example_group.set_description
+ example_group.description_args.should be_empty
+ super
+ end
+
+ it "should not render anything" do
+ io.string.should == ""
+ end
+ end
+ end
+
+ describe "#example_failed" do
+ describe "where ExampleGroup has no superclasss with a description" do
+ describe "when having an error" do
+ it "should push failing spec name and failure number" do
+ formatter.example_failed(
+ example_group.it("spec"),
+ 98,
+ Reporter::Failure.new("c s", RuntimeError.new)
+ )
+ expected_output = <<-OUT
+ ExampleGroup
+ spec (ERROR - 98)
+ OUT
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+ end
+
+ describe "when having an expectation failure" do
+ it "should push failing spec name and failure number" do
+ formatter.example_failed(
+ example_group.it("spec"),
+ 98,
+ Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)
+ )
+ expected_output = <<-OUT
+ ExampleGroup
+ spec (FAILED - 98)
+ OUT
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+ end
+ end
+
+ describe "where ExampleGroup has two superclasses with a description" do
+ attr_reader :child_example_group, :grand_child_example_group
+
+ def add_example_group
+ @child_example_group = Class.new(example_group).describe("Child ExampleGroup")
+ @grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup")
+ formatter.add_example_group(grand_child_example_group)
+ end
+
+ describe "when having an error" do
+ it "should push failing spec name and failure number" do
+ formatter.example_failed(
+ grand_child_example_group.it("spec"),
+ 98,
+ Reporter::Failure.new("c s", RuntimeError.new)
+ )
+ expected_output = <<-OUT
+ ExampleGroup
+ Child ExampleGroup
+ GrandChild ExampleGroup
+ spec (ERROR - 98)
+ OUT
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+ end
+
+ describe "when having an expectation" do
+ it "should push failing spec name and failure number" do
+ formatter.example_failed(
+ grand_child_example_group.it("spec"),
+ 98,
+ Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)
+ )
+ expected_output = <<-OUT
+ ExampleGroup
+ Child ExampleGroup
+ GrandChild ExampleGroup
+ spec (FAILED - 98)
+ OUT
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+ end
+ end
+ end
+
+ describe "#start" do
+ it "should push nothing on start" do
+ formatter.start(5)
+ expected_output = <<-OUT
+ ExampleGroup
+ OUT
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+ end
+
+ describe "#start_dump" do
+ it "should push nothing on start dump" do
+ formatter.start_dump
+ expected_output = <<-OUT
+ ExampleGroup
+ OUT
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+ end
+
+ describe "#example_passed" do
+ it "should push passing spec name" do
+ formatter.example_passed(example_group.it("spec"))
+ expected_output = <<-OUT
+ ExampleGroup
+ spec
+ OUT
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+ end
+
+ describe "#example_pending" do
+ it "should push pending example name and message" do
+ formatter.example_pending(example_group.examples.first, 'reason')
+ expected_output = <<-OUT
+ ExampleGroup
+ example (PENDING: reason)
+ OUT
+ io.string.should == expected_output.gsub(/^ /, '')
+ end
+
+ it "should dump pending" do
+ formatter.example_pending(example_group.examples.first, 'reason')
+ io.rewind
+ formatter.dump_pending
+ io.string.should =~ /Pending\:\nExampleGroup example \(reason\)\n/
+ end
+ end
+
+ def have_single_level_example_group_output(expected_output)
+ expected = "ExampleGroup\n #{expected_output}"
+ ::Spec::Matchers::SimpleMatcher.new(expected) do |actual|
+ actual == expected
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_spec.rb
index 127a617c1..64e11b1a5 100644
--- a/vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_spec.rb
@@ -24,7 +24,12 @@ module Spec
end
it "should produce standard summary" do
- @formatter.example_pending("example_group", ExampleGroup.new("example"), "message")
+ example_group = ExampleGroup.describe("example_group") do
+ specify "example" do
+ end
+ end
+ example = example_group.examples.first
+ @formatter.example_pending(example, "message")
@io.rewind
@formatter.dump_summary(3, 2, 1, 1)
@io.string.should eql(%Q|
@@ -84,7 +89,12 @@ EOE
end
it "should dump pending" do
- @formatter.example_pending("example_group", ExampleGroup.new("example"), "message")
+ example_group = ExampleGroup.describe("example_group") do
+ specify "example" do
+ end
+ end
+ example = example_group.examples.first
+ @formatter.example_pending(example, "message")
@formatter.dump_pending
@io.string.should =~ /Pending\:\nexample_group example \(message\)\n/
end
diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb
index e782254e2..da1b69f79 100644
--- a/vendor/plugins/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb
@@ -50,10 +50,10 @@ module Spec
# Spec::Runner::CommandLine.run(
# ::Spec::Runner::OptionParser.parse(args, err, out)
# )
- #
+ #
# seconds = /\d+\.\d+ seconds/
# html = out.string.gsub seconds, 'x seconds'
- #
+ #
# File.open(expected_file, 'w') {|io| io.write(html)}
# end
# end
diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/specdoc_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/specdoc_formatter_spec.rb
index 79995309d..3974f9533 100644
--- a/vendor/plugins/rspec/spec/spec/runner/formatter/specdoc_formatter_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/runner/formatter/specdoc_formatter_spec.rb
@@ -12,71 +12,137 @@ module Spec
options.stub!(:dry_run).and_return(false)
options.stub!(:colour).and_return(false)
@formatter = SpecdocFormatter.new(options, io)
- @example_group = Class.new(::Spec::Example::ExampleGroup).describe("ExampleGroup")
+ @example_group = ::Spec::Example::ExampleGroup.describe("ExampleGroup") do
+ specify "example" do
+ end
+ end
end
describe "where ExampleGroup has no superclasss with a description" do
before do
- formatter.add_example_group(example_group)
+ add_example_group
end
- it "should produce standard summary without pending when pending has a 0 count" do
- formatter.dump_summary(3, 2, 1, 0)
- io.string.should have_example_group_output("\nFinished in 3 seconds\n\n2 examples, 1 failure\n")
+ def add_example_group
+ formatter.add_example_group(example_group)
end
- it "should produce standard summary" do
- formatter.dump_summary(3, 2, 1, 4)
- io.string.should have_example_group_output("\nFinished in 3 seconds\n\n2 examples, 1 failure, 4 pending\n")
- end
+ describe "#dump_summary" do
+ it "should produce standard summary without pending when pending has a 0 count" do
+ formatter.dump_summary(3, 2, 1, 0)
+ io.string.should have_example_group_output("\nFinished in 3 seconds\n\n2 examples, 1 failure\n")
+ end
- it "should push ExampleGroup name" do
- io.string.should eql("\nExampleGroup\n")
+ it "should produce standard summary" do
+ formatter.dump_summary(3, 2, 1, 4)
+ io.string.should have_example_group_output("\nFinished in 3 seconds\n\n2 examples, 1 failure, 4 pending\n")
+ end
end
- it "when having an error, should push failing spec name and failure number" do
- formatter.example_failed(
- example_group.it("spec"),
- 98,
- Reporter::Failure.new("c s", RuntimeError.new)
- )
- io.string.should have_example_group_output("- spec (ERROR - 98)\n")
+ describe "#add_example_group" do
+ it "should push ExampleGroup name" do
+ io.string.should eql("\nExampleGroup\n")
+ end
end
- it "when having an expectation failure, should push failing spec name and failure number" do
- formatter.example_failed(
- example_group.it("spec"),
- 98,
- Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)
- )
- io.string.should have_example_group_output("- spec (FAILED - 98)\n")
- end
+ describe "#example_failed" do
+ describe "where ExampleGroup has no superclasss with a description" do
+ describe "when having an error" do
+ it "should push failing spec name and failure number" do
+ formatter.example_failed(
+ example_group.it("spec"),
+ 98,
+ Reporter::Failure.new("c s", RuntimeError.new)
+ )
+ io.string.should have_example_group_output("- spec (ERROR - 98)\n")
+ end
+ end
+
+ describe "when having an expectation failure" do
+ it "should push failing spec name and failure number" do
+ formatter.example_failed(
+ example_group.it("spec"),
+ 98,
+ Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)
+ )
+ io.string.should have_example_group_output("- spec (FAILED - 98)\n")
+ end
+ end
+ end
- it "should push nothing on start" do
- formatter.start(5)
- io.string.should have_example_group_output("")
+ describe "where ExampleGroup has two superclasses with a description" do
+ attr_reader :child_example_group, :grand_child_example_group
+
+ def add_example_group
+ @child_example_group = Class.new(example_group).describe("Child ExampleGroup")
+ @grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup")
+ formatter.add_example_group(grand_child_example_group)
+ end
+
+ describe "when having an error" do
+ it "should push failing spec name and failure number" do
+ formatter.example_failed(
+ example_group.it("spec"),
+ 98,
+ Reporter::Failure.new("c s", RuntimeError.new)
+ )
+ io.string.should have_nested_example_group_output("- spec (ERROR - 98)\n")
+ end
+ end
+
+ describe "when having an expectation" do
+ it "should push failing spec name and failure number" do
+ formatter.example_failed(
+ example_group.it("spec"),
+ 98,
+ Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)
+ )
+ io.string.should have_nested_example_group_output("- spec (FAILED - 98)\n")
+ end
+ end
+
+ def have_nested_example_group_output(expected_output)
+ expected_full_output = "\nExampleGroup Child ExampleGroup GrandChild ExampleGroup\n#{expected_output}"
+ ::Spec::Matchers::SimpleMatcher.new(expected_full_output) do |actual|
+ actual == expected_full_output
+ end
+ end
+ end
end
- it "should push nothing on start dump" do
- formatter.start_dump
- io.string.should have_example_group_output("")
+ describe "#start" do
+ it "should push nothing on start" do
+ formatter.start(5)
+ io.string.should have_example_group_output("")
+ end
end
-
- it "should push passing spec name" do
- formatter.example_passed(example_group.it("spec"))
- io.string.should have_example_group_output("- spec\n")
+
+ describe "#start_dump" do
+ it "should push nothing on start dump" do
+ formatter.start_dump
+ io.string.should have_example_group_output("")
+ end
end
- it "should push pending example name and message" do
- formatter.example_pending('example_group', ExampleGroup.new("example"), 'reason')
- io.string.should have_example_group_output("- example (PENDING: reason)\n")
+ describe "#example_passed" do
+ it "should push passing spec name" do
+ formatter.example_passed(example_group.it("spec"))
+ io.string.should have_example_group_output("- spec\n")
+ end
end
- it "should dump pending" do
- formatter.example_pending('example_group', ExampleGroup.new("example"), 'reason')
- io.rewind
- formatter.dump_pending
- io.string.should =~ /Pending\:\nexample_group example \(reason\)\n/
+ describe "#example_pending" do
+ it "should push pending example name and message" do
+ formatter.example_pending(example_group.examples.first, 'reason')
+ io.string.should have_example_group_output("- example (PENDING: reason)\n")
+ end
+
+ it "should dump pending" do
+ formatter.example_pending(example_group.examples.first, 'reason')
+ io.rewind
+ formatter.dump_pending
+ io.string.should =~ /Pending\:\nExampleGroup example \(reason\)\n/
+ end
end
def have_example_group_output(expected_output)
@@ -86,40 +152,6 @@ module Spec
end
end
end
-
- describe "where ExampleGroup has two superclasses with a description" do
- attr_reader :child_example_group, :grand_child_example_group
- before do
- @child_example_group = Class.new(example_group).describe("Child ExampleGroup")
- @grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup")
- formatter.add_example_group(grand_child_example_group)
- end
-
- specify "when having an error, should push failing spec name and failure number" do
- formatter.example_failed(
- example_group.it("spec"),
- 98,
- Reporter::Failure.new("c s", RuntimeError.new)
- )
- io.string.should have_nested_example_group_output("- spec (ERROR - 98)\n")
- end
-
- specify "when having an expectation failure, should push failing spec name and failure number" do
- formatter.example_failed(
- example_group.it("spec"),
- 98,
- Reporter::Failure.new("c s", Spec::Expectations::ExpectationNotMetError.new)
- )
- io.string.should have_nested_example_group_output("- spec (FAILED - 98)\n")
- end
-
- def have_nested_example_group_output(expected_output)
- expected_full_output = "\nExampleGroup Child ExampleGroup GrandChild ExampleGroup\n#{expected_output}"
- ::Spec::Matchers::SimpleMatcher.new(expected_full_output) do |actual|
- actual == expected_full_output
- end
- end
- end
end
end
end
diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb
index 27e184b0f..626ec4628 100644
--- a/vendor/plugins/rspec/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb
@@ -16,7 +16,7 @@ module Spec
@options.stub!(:backtrace_tweaker).and_return(@tweaker)
@formatter = PlainTextFormatter.new(@options, @out)
end
-
+
it 'should summarize the number of scenarios when the run ends' do
# when
@formatter.run_started(3)
@@ -27,11 +27,11 @@ module Spec
@formatter.scenario_started(nil, nil)
@formatter.scenario_succeeded('story', 'scenario3')
@formatter.run_ended
-
+
# then
@out.string.should include('3 scenarios')
end
-
+
it 'should summarize the number of successful scenarios when the run ends' do
# when
@formatter.run_started(3)
@@ -42,11 +42,11 @@ module Spec
@formatter.scenario_started(nil, nil)
@formatter.scenario_succeeded('story', 'scenario3')
@formatter.run_ended
-
+
# then
@out.string.should include('3 scenarios: 3 succeeded')
end
-
+
it 'should summarize the number of failed scenarios when the run ends' do
# when
@formatter.run_started(3)
@@ -57,33 +57,33 @@ module Spec
@formatter.scenario_started(nil, nil)
@formatter.scenario_failed('story', 'scenario3', exception_from { raise RuntimeError, 'oops' })
@formatter.run_ended
-
+
# then
@out.string.should include("3 scenarios: 1 succeeded, 2 failed")
end
-
+
it 'should end cleanly (no characters on the last line) with successes' do
# when
@formatter.run_started(1)
@formatter.scenario_started(nil, nil)
@formatter.scenario_succeeded('story', 'scenario')
@formatter.run_ended
-
+
# then
@out.string.should =~ /\n\z/
end
-
+
it 'should end cleanly (no characters on the last line) with failures' do
# when
@formatter.run_started(1)
@formatter.scenario_started(nil, nil)
@formatter.scenario_failed('story', 'scenario', exception_from { raise RuntimeError, 'oops' })
@formatter.run_ended
-
+
# then
@out.string.should =~ /\n\z/
end
-
+
it 'should end cleanly (no characters on the last line) with pending steps' do
# when
@formatter.run_started(1)
@@ -91,11 +91,11 @@ module Spec
@formatter.step_pending(:then, 'do pend')
@formatter.scenario_pending('story', 'scenario', exception_from { raise RuntimeError, 'oops' })
@formatter.run_ended
-
+
# then
@out.string.should =~ /\n\z/
end
-
+
it 'should summarize the number of pending scenarios when the run ends' do
# when
@formatter.run_started(3)
@@ -106,11 +106,11 @@ module Spec
@formatter.scenario_started(nil, nil)
@formatter.scenario_pending('story', 'scenario3', 'message')
@formatter.run_ended
-
+
# then
@out.string.should include("3 scenarios: 1 succeeded, 0 failed, 2 pending")
end
-
+
it "should only count the first failure in one scenario" do
# when
@formatter.run_started(3)
@@ -122,11 +122,11 @@ module Spec
@formatter.scenario_started(nil, nil)
@formatter.scenario_failed('story', 'scenario3', exception_from { raise RuntimeError, 'oops' })
@formatter.run_ended
-
+
# then
@out.string.should include("3 scenarios: 1 succeeded, 2 failed")
end
-
+
it "should only count the first pending in one scenario" do
# when
@formatter.run_started(3)
@@ -138,11 +138,11 @@ module Spec
@formatter.scenario_started(nil, nil)
@formatter.scenario_pending('story', 'scenario3', 'because ...')
@formatter.run_ended
-
+
# then
@out.string.should include("3 scenarios: 1 succeeded, 0 failed, 2 pending")
end
-
+
it "should only count a failure before the first pending in one scenario" do
# when
@formatter.run_started(3)
@@ -154,11 +154,11 @@ module Spec
@formatter.scenario_started(nil, nil)
@formatter.scenario_failed('story', 'scenario3', exception_from { raise RuntimeError, 'oops' })
@formatter.run_ended
-
+
# then
@out.string.should include("3 scenarios: 1 succeeded, 1 failed, 1 pending")
end
-
+
it 'should produce details of the first failure each failed scenario when the run ends' do
# when
@formatter.run_started(3)
@@ -170,7 +170,7 @@ module Spec
@formatter.scenario_started(nil, nil)
@formatter.scenario_failed('story', 'scenario3', exception_from { raise RuntimeError, 'oops3' })
@formatter.run_ended
-
+
# then
@out.string.should include("FAILURES:\n")
@out.string.should include("1) story (scenario2) FAILED")
@@ -179,7 +179,7 @@ module Spec
@out.string.should include("2) story (scenario3) FAILED")
@out.string.should include("RuntimeError: oops3")
end
-
+
it 'should produce details of each pending step when the run ends' do
# when
@formatter.run_started(2)
@@ -190,139 +190,243 @@ module Spec
@formatter.scenario_started('story 2', 'scenario 2')
@formatter.step_pending(:given, 'todo 2', [])
@formatter.run_ended
-
+
# then
@out.string.should include("Pending Steps:\n")
@out.string.should include("1) story 1 (scenario 1): todo 1")
@out.string.should include("2) story 2 (scenario 2): todo 2")
end
-
+
it 'should document a story title and narrative' do
# when
@formatter.story_started 'story', 'narrative'
-
+
# then
@out.string.should include("Story: story\n\n narrative")
end
-
+
it 'should document a scenario name' do
# when
@formatter.scenario_started 'story', 'scenario'
-
+
# then
@out.string.should include("\n\n Scenario: scenario")
end
-
+
it 'should document a step by sentence-casing its name' do
# when
@formatter.step_succeeded :given, 'a context'
@formatter.step_succeeded :when, 'an event'
@formatter.step_succeeded :then, 'an outcome'
-
+
# then
@out.string.should include("\n\n Given a context\n\n When an event\n\n Then an outcome")
end
-
+
it 'should document additional givens using And' do
# when
@formatter.step_succeeded :given, 'step 1'
@formatter.step_succeeded :given, 'step 2'
@formatter.step_succeeded :given, 'step 3'
-
+
# then
@out.string.should include(" Given step 1\n And step 2\n And step 3")
end
-
+
it 'should document additional events using And' do
# when
@formatter.step_succeeded :when, 'step 1'
@formatter.step_succeeded :when, 'step 2'
@formatter.step_succeeded :when, 'step 3'
-
+
# then
@out.string.should include(" When step 1\n And step 2\n And step 3")
end
-
+
it 'should document additional outcomes using And' do
# when
@formatter.step_succeeded :then, 'step 1'
@formatter.step_succeeded :then, 'step 2'
@formatter.step_succeeded :then, 'step 3'
-
+
# then
@out.string.should include(" Then step 1\n And step 2\n And step 3")
end
-
+
it 'should document a GivenScenario followed by a Given using And' do
# when
@formatter.step_succeeded :'given scenario', 'a scenario'
@formatter.step_succeeded :given, 'a context'
-
+
# then
@out.string.should include(" Given scenario a scenario\n And a context")
end
-
+
it 'should document steps with replaced params' do
@formatter.step_succeeded :given, 'a $coloured dog with $n legs', 'pink', 21
@out.string.should include(" Given a pink dog with 21 legs")
end
-
+
+ it 'should document steps that include dollar signs ($)' do
+ @formatter.step_succeeded :given, 'kicks that cost $$amount', 50
+ @out.string.should include("Given kicks that cost $50")
+ end
+
it 'should document regexp steps with replaced params' do
@formatter.step_succeeded :given, /a (pink|blue) dog with (.*) legs/, 'pink', 21
@out.string.should include(" Given a pink dog with 21 legs")
end
-
+
+ it 'should document regex steps that include dollar signs ($)' do
+ @formatter.step_succeeded :given, /kicks that cost \$(\d+)/, 50
+ @out.string.should include("Given kicks that cost $50")
+ end
+
it "should append PENDING for the first pending step" do
@formatter.scenario_started('','')
@formatter.step_pending(:given, 'a context')
-
+
@out.string.should include('Given a context (PENDING)')
end
-
+
it "should append PENDING for pending after already pending" do
@formatter.scenario_started('','')
@formatter.step_pending(:given, 'a context')
@formatter.step_pending(:when, 'I say hey')
-
+
@out.string.should include('When I say hey (PENDING)')
end
-
+
it "should append FAILED for the first failiure" do
@formatter.scenario_started('','')
@formatter.step_failed(:given, 'a context')
-
+
@out.string.should include('Given a context (FAILED)')
end
-
+
it "should append SKIPPED for the second failiure" do
@formatter.scenario_started('','')
@formatter.step_failed(:given, 'a context')
@formatter.step_failed(:when, 'I say hey')
-
+
@out.string.should include('When I say hey (SKIPPED)')
end
-
- it "should append SKIPPED for the a failiure after PENDING" do
+
+ it "should append SKIPPED for a failure after PENDING" do
@formatter.scenario_started('','')
@formatter.step_pending(:given, 'a context')
@formatter.step_failed(:when, 'I say hey')
-
+
@out.string.should include('When I say hey (SKIPPED)')
end
-
+
+ it "should print steps which succeeded in green" do
+ @out.stub!(:tty?).and_return(true)
+ @options.stub!(:colour).and_return(true)
+
+ @formatter.scenario_started('','')
+ @formatter.step_succeeded(:given, 'a context')
+
+ @out.string.should =~ /\e\[32m[\n\s]+Given a context\e\[0m/m
+ end
+
+ it "should print failed steps in red" do
+ @out.stub!(:tty?).and_return(true)
+ @options.stub!(:colour).and_return(true)
+
+ @formatter.scenario_started('','')
+ @formatter.step_failed(:given, 'a context')
+
+ @out.string.should =~ /\e\[31m[\n\s]+Given a context\e\[0m/m
+ end
+
+ it "should print ' (FAILED)' in red" do
+ @out.stub!(:tty?).and_return(true)
+ @options.stub!(:colour).and_return(true)
+
+ @formatter.scenario_started('','')
+ @formatter.step_failed(:given, 'a context')
+
+ @out.string.should =~ /\e\[31m \(FAILED\)\e\[0m/
+ end
+
+ it "should print pending steps in yellow" do
+ @out.stub!(:tty?).and_return(true)
+ @options.stub!(:colour).and_return(true)
+
+ @formatter.scenario_started('','')
+ @formatter.step_pending(:given, 'a context')
+
+ @out.string.should =~ /\e\[33m[\n\s]+Given a context\e\[0m/m
+ end
+
+ it "should print ' (PENDING)' in yellow" do
+ @out.stub!(:tty?).and_return(true)
+ @options.stub!(:colour).and_return(true)
+
+ @formatter.scenario_started('','')
+ @formatter.step_pending(:given, 'a context')
+
+ @out.string.should =~ /\e\[33m \(PENDING\)\e\[0m/
+ end
+
+ it "should print skipped steps in yellow if the scenario is already pending" do
+ @out.stub!(:tty?).and_return(true)
+ @options.stub!(:colour).and_return(true)
+
+ @formatter.scenario_started('','')
+ @formatter.step_pending(:given, 'a context')
+ @formatter.step_failed(:when, 'I say hey')
+
+ @out.string.should =~ /\e\[33m[\n\s]+When I say hey\e\[0m/m
+ end
+
+ it "should print ' (SKIPPED)' in yellow if the scenario is already pending" do
+ @out.stub!(:tty?).and_return(true)
+ @options.stub!(:colour).and_return(true)
+
+ @formatter.scenario_started('','')
+ @formatter.step_pending(:given, 'a context')
+ @formatter.step_failed(:when, 'I say hey')
+
+ @out.string.should =~ /\e\[33m \(SKIPPED\)\e\[0m/
+ end
+
+ it "should print skipped steps in red if the scenario has already failed" do
+ @out.stub!(:tty?).and_return(true)
+ @options.stub!(:colour).and_return(true)
+
+ @formatter.scenario_started('','')
+ @formatter.step_failed(:given, 'a context')
+ @formatter.step_failed(:when, 'I say hey')
+
+ @out.string.should =~ /\e\[31m[\n\s]+When I say hey\e\[0m/m
+ end
+
+ it "should print ' (SKIPPED)' in red if the scenario has already failed" do
+ @out.stub!(:tty?).and_return(true)
+ @options.stub!(:colour).and_return(true)
+
+ @formatter.scenario_started('','')
+ @formatter.step_failed(:given, 'a context')
+ @formatter.step_failed(:when, 'I say hey')
+
+ @out.string.should =~ /\e\[31m \(SKIPPED\)\e\[0m/m
+ end
+
it 'should print some white space after each story' do
# when
@formatter.story_ended 'title', 'narrative'
-
+
# then
@out.string.should include("\n\n")
end
-
+
it "should print nothing for collected_steps" do
@formatter.collected_steps(['Given a $coloured $animal', 'Given a $n legged eel'])
@out.string.should == ("")
end
-
+
it "should ignore messages it doesn't care about" do
lambda {
@formatter.this_method_does_not_exist
diff --git a/vendor/plugins/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html b/vendor/plugins/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html
index 8a2b12e7d..60f8d1e2e 100644
--- a/vendor/plugins/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html
+++ b/vendor/plugins/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html
+<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
@@ -188,10 +188,10 @@ a {
<span class="failed_spec_name">should fail when expected message not received</span>
<div class="failure" id="failure_1">
<div class="message"><pre>Mock 'poke me' expected :poke with (any args) once, but received it 0 times</pre></div>
- <div class="backtrace"><pre>./failing_examples/mocking_example.rb:13:
-./spec/spec/runner/formatter/html_formatter_spec.rb:18:
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:in `chdir'
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:</pre></div>
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/mocking_example.rb&line=13">./failing_examples/mocking_example.rb:13</a>
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a>
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir'
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div>
<pre class="ruby"><code><span class="linenum">11</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">should fail when expected message not received</span><span class="punct">&quot;</span> <span class="keyword">do</span>
<span class="linenum">12</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">(&quot;</span><span class="string">poke me</span><span class="punct">&quot;)</span>
<span class="offending"><span class="linenum">13</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span>
@@ -204,10 +204,10 @@ a {
<span class="failed_spec_name">should fail when messages are received out of order</span>
<div class="failure" id="failure_2">
<div class="message"><pre>Mock 'one two three' received :three out of order</pre></div>
- <div class="backtrace"><pre>./failing_examples/mocking_example.rb:22:
-./spec/spec/runner/formatter/html_formatter_spec.rb:18:
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:in `chdir'
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:</pre></div>
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/mocking_example.rb&line=22">./failing_examples/mocking_example.rb:22</a>
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a>
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir'
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div>
<pre class="ruby"><code><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span>
<span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span>
<span class="offending"><span class="linenum">22</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span>
@@ -219,15 +219,14 @@ a {
<dd class="spec failed">
<span class="failed_spec_name">should get yelled at when sending unexpected messages</span>
<div class="failure" id="failure_3">
- <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (any args) 0 times, but received it once</pre></div>
- <div class="backtrace"><pre>./failing_examples/mocking_example.rb:28:
-./spec/spec/runner/formatter/html_formatter_spec.rb:18:
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:in `chdir'
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:</pre></div>
- <pre class="ruby"><code><span class="linenum">26</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">should get yelled at when sending unexpected messages</span><span class="punct">&quot;</span> <span class="keyword">do</span>
-<span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">(&quot;</span><span class="string">don't talk to me</span><span class="punct">&quot;)</span>
-<span class="offending"><span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span></span>
-<span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span>
+ <div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (no args) 0 times, but received it once</pre></div>
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/mocking_example.rb&line=29">./failing_examples/mocking_example.rb:29</a>
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a>
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir'
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div>
+ <pre class="ruby"><code><span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">(&quot;</span><span class="string">don't talk to me</span><span class="punct">&quot;)</span>
+<span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span>
+<span class="offending"><span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span></span>
<span class="linenum">30</span> <span class="keyword">end</span></code></pre>
</div>
</dd>
@@ -236,7 +235,10 @@ a {
<span class="failed_spec_name">has a bug we need to fix</span>
<div class="failure" id="failure_4">
<div class="message"><pre>Expected pending 'here is the bug' to fail. No Error was raised.</pre></div>
-
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/mocking_example.rb&line=33">./failing_examples/mocking_example.rb:33</a>
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a>
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir'
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div>
<pre class="ruby"><code><span class="linenum">31</span>
<span class="linenum">32</span> <span class="ident">it</span> <span class="punct">&quot;</span><span class="string">has a bug we need to fix</span><span class="punct">&quot;</span> <span class="keyword">do</span>
<span class="offending"><span class="linenum">33</span> <span class="ident">pending</span> <span class="punct">&quot;</span><span class="string">here is the bug</span><span class="punct">&quot;</span> <span class="keyword">do</span></span>
@@ -259,11 +261,14 @@ a {
Diff:
@@ -1,4 +1,4 @@
RSpec is a
--behavior driven development
-+behaviour driven development
+-behaviour driven development
++behavior driven development
framework for Ruby
</pre></div>
-
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/diffing_spec.rb&line=13">./failing_examples/diffing_spec.rb:13</a>
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a>
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir'
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div>
<pre class="ruby"><code><span class="linenum">11</span><span class="ident">framework</span> <span class="keyword">for</span> <span class="constant">Ruby</span>
<span class="linenum">12</span><span class="constant">EOF</span>
<span class="offending"><span class="linenum">13</span> <span class="ident">usa</span><span class="punct">.</span><span class="ident">should</span> <span class="punct">==</span> <span class="ident">uk</span></span>
@@ -287,14 +292,14 @@ Diff:
@@ -1,5 +1,5 @@
&lt;Animal
name=bob,
--species=giraffe
-+species=tortoise
+-species=tortoise
++species=giraffe
&gt;
</pre></div>
- <div class="backtrace"><pre>./failing_examples/mocking_example.rb:33:
-./spec/spec/runner/formatter/html_formatter_spec.rb:18:
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:in `chdir'
-./spec/spec/runner/formatter/html_formatter_spec.rb:14:</pre></div>
+ <div class="backtrace"><pre><a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/failing_examples/diffing_spec.rb&line=34">./failing_examples/diffing_spec.rb:34</a>
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=50">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50</a>
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> :in `chdir'
+<a href="txmt://open?url=file:///Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb&line=46">/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46</a> </pre></div>
<pre class="ruby"><code><span class="linenum">32</span> <span class="ident">expected</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">&quot;</span><span class="string">bob</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">giraffe</span><span class="punct">&quot;</span>
<span class="linenum">33</span> <span class="ident">actual</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">&quot;</span><span class="string">bob</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string">tortoise</span><span class="punct">&quot;</span>
<span class="offending"><span class="linenum">34</span> <span class="ident">expected</span><span class="punct">.</span><span class="ident">should</span> <span class="ident">eql</span><span class="punct">(</span><span class="ident">actual</span><span class="punct">)</span></span>
diff --git a/vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb b/vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb
index 8c91ad19f..69212ff1b 100644
--- a/vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb
@@ -12,12 +12,17 @@ describe "OptionParser" do
@parser.parse(args)
@parser.options
end
-
+
+ it "should accept files to include" do
+ options = parse(["--pattern", "foo"])
+ options.filename_pattern.should == "foo"
+ end
+
it "should accept dry run option" do
options = parse(["--dry-run"])
options.dry_run.should be_true
end
-
+
it "should eval and use custom formatter when none of the builtins" do
options = parse(["--format", "Custom::Formatter"])
options.formatters[0].class.should be(Custom::Formatter)
@@ -35,17 +40,17 @@ describe "OptionParser" do
options.formatters[2].where.should eql("foo\\bar")
options.formatters[3].where.should eql("/foo/bar")
end
-
+
it "should not be verbose by default" do
options = parse([])
options.verbose.should be_nil
end
-
+
it "should not use colour by default" do
options = parse([])
options.colour.should == false
end
-
+
it "should print help to stdout if no args" do
pending 'A regression since 1.0.8' do
options = parse([])
@@ -53,13 +58,13 @@ describe "OptionParser" do
@out.read.should match(/Usage: spec \(FILE\|DIRECTORY\|GLOB\)\+ \[options\]/m)
end
end
-
+
it "should print help to stdout" do
options = parse(["--help"])
@out.rewind
@out.read.should match(/Usage: spec \(FILE\|DIRECTORY\|GLOB\)\+ \[options\]/m)
end
-
+
it "should print instructions about how to require missing formatter" do
lambda do
options = parse(["--format", "Custom::MissingFormatter"])
@@ -67,7 +72,7 @@ describe "OptionParser" do
end.should raise_error(NameError)
@err.string.should match(/Couldn't find formatter class Custom::MissingFormatter/n)
end
-
+
it "should print version to stdout" do
options = parse(["--version"])
@out.rewind
@@ -79,37 +84,37 @@ describe "OptionParser" do
parse(["--require", "whatever"])
end.should raise_error(LoadError)
end
-
+
it "should support c option" do
options = parse(["-c"])
options.colour.should be_true
end
-
+
it "should support queens colour option" do
options = parse(["--colour"])
options.colour.should be_true
end
-
+
it "should support us color option" do
options = parse(["--color"])
options.colour.should be_true
end
-
+
it "should support single example with -e option" do
options = parse(["-e", "something or other"])
options.examples.should eql(["something or other"])
end
-
+
it "should support single example with -s option (will be removed when autotest supports -e)" do
options = parse(["-s", "something or other"])
options.examples.should eql(["something or other"])
end
-
+
it "should support single example with --example option" do
options = parse(["--example", "something or other"])
options.examples.should eql(["something or other"])
end
-
+
it "should read several example names from file if --example is given an existing file name" do
options = parse(["--example", File.dirname(__FILE__) + '/examples.txt'])
options.examples.should eql([
@@ -121,27 +126,27 @@ describe "OptionParser" do
options = parse(["--example", File.dirname(__FILE__) + '/empty_file.txt'])
options.examples.should eql([])
end
-
+
it "should use html formatter when format is h" do
options = parse(["--format", "h"])
options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter)
end
-
+
it "should use html story formatter when format is h" do
options = parse(["--format", "h"])
options.story_formatters[0].class.should equal(Spec::Runner::Formatter::Story::HtmlFormatter)
end
-
+
it "should use html formatter when format is html" do
options = parse(["--format", "html"])
options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter)
end
-
+
it "should use html story formatter when format is html" do
options = parse(["--format", "html"])
options.story_formatters[0].class.should equal(Spec::Runner::Formatter::Story::HtmlFormatter)
end
-
+
it "should use html formatter with explicit output when format is html:test.html" do
FileUtils.rm 'test.html' if File.exist?('test.html')
options = parse(["--format", "html:test.html"])
@@ -151,127 +156,133 @@ describe "OptionParser" do
options.formatters[0].close
FileUtils.rm 'test.html'
end
-
+
it "should use noisy backtrace tweaker with b option" do
options = parse(["-b"])
options.backtrace_tweaker.should be_instance_of(Spec::Runner::NoisyBacktraceTweaker)
end
-
+
it "should use noisy backtrace tweaker with backtrace option" do
options = parse(["--backtrace"])
options.backtrace_tweaker.should be_instance_of(Spec::Runner::NoisyBacktraceTweaker)
end
-
+
it "should use quiet backtrace tweaker by default" do
options = parse([])
options.backtrace_tweaker.should be_instance_of(Spec::Runner::QuietBacktraceTweaker)
end
-
+
it "should use progress bar formatter by default" do
options = parse([])
options.formatters[0].class.should equal(Spec::Runner::Formatter::ProgressBarFormatter)
end
-
+
it "should use specdoc formatter when format is s" do
options = parse(["--format", "s"])
options.formatters[0].class.should equal(Spec::Runner::Formatter::SpecdocFormatter)
end
-
+
it "should use specdoc formatter when format is specdoc" do
options = parse(["--format", "specdoc"])
options.formatters[0].class.should equal(Spec::Runner::Formatter::SpecdocFormatter)
end
+ it "should use nested text formatter when format is s" do
+ options = parse(["--format", "n"])
+ options.formatters[0].class.should equal(Spec::Runner::Formatter::NestedTextFormatter)
+ end
+
+ it "should use nested text formatter when format is nested" do
+ options = parse(["--format", "nested"])
+ options.formatters[0].class.should equal(Spec::Runner::Formatter::NestedTextFormatter)
+ end
+
it "should support diff option when format is not specified" do
options = parse(["--diff"])
options.diff_format.should == :unified
end
-
+
it "should use unified diff format option when format is unified" do
options = parse(["--diff", "unified"])
options.diff_format.should == :unified
options.differ_class.should equal(Spec::Expectations::Differs::Default)
end
-
+
it "should use context diff format option when format is context" do
options = parse(["--diff", "context"])
options.diff_format.should == :context
options.differ_class.should == Spec::Expectations::Differs::Default
end
-
+
it "should use custom diff format option when format is a custom format" do
Spec::Expectations.differ.should_not be_instance_of(Custom::Differ)
-
+
options = parse(["--diff", "Custom::Differ"])
options.parse_diff "Custom::Differ"
options.diff_format.should == :custom
options.differ_class.should == Custom::Differ
Spec::Expectations.differ.should be_instance_of(Custom::Differ)
end
-
+
it "should print instructions about how to fix missing differ" do
lambda { parse(["--diff", "Custom::MissingFormatter"]) }.should raise_error(NameError)
@err.string.should match(/Couldn't find differ class Custom::MissingFormatter/n)
end
-
- it "should support --line to identify spec" do
- spec_parser = mock("spec_parser")
- @parser.instance_variable_set('@spec_parser', spec_parser)
-
- file_factory = mock("File")
- file_factory.should_receive(:file?).and_return(true)
- file_factory.should_receive(:open).and_return("fake_io")
- @parser.instance_variable_set('@file_factory', file_factory)
-
- spec_parser.should_receive(:spec_name_for).with("fake_io", 169).and_return("some spec")
-
- options = parse(["some file", "--line", "169"])
- options.examples.should eql(["some spec"])
- File.rspec_verify
- end
-
- it "should fail with error message if file is dir along with --line" do
- spec_parser = mock("spec_parser")
- @parser.instance_variable_set('@spec_parser', spec_parser)
-
- file_factory = mock("File")
- file_factory.should_receive(:file?).and_return(false)
- file_factory.should_receive(:directory?).and_return(true)
- @parser.instance_variable_set('@file_factory', file_factory)
-
- options = parse(["some file", "--line", "169"])
- @err.string.should match(/You must specify one file, not a directory when using the --line option/n)
- end
-
- it "should fail with error message if file does not exist along with --line" do
- spec_parser = mock("spec_parser")
- @parser.instance_variable_set('@spec_parser', spec_parser)
-
- file_factory = mock("File")
- file_factory.should_receive(:file?).and_return(false)
- file_factory.should_receive(:directory?).and_return(false)
- @parser.instance_variable_set('@file_factory', file_factory)
-
- options = parse(["some file", "--line", "169"])
- @err.string.should match(/some file does not exist/n)
- end
-
- it "should fail with error message if more than one files are specified along with --line" do
- spec_parser = mock("spec_parser")
- @parser.instance_variable_set('@spec_parser', spec_parser)
-
- options = parse(["some file", "some other file", "--line", "169"])
- @err.string.should match(/Only one file can be specified when using the --line option/n)
- end
-
- it "should fail with error message if --example and --line are used simultaneously" do
- spec_parser = mock("spec_parser")
- @parser.instance_variable_set('@spec_parser', spec_parser)
-
- options = parse(["some file", "--example", "some example", "--line", "169"])
- @err.string.should match(/You cannot use both --line and --example/n)
+
+ describe "when attempting a focussed spec" do
+ attr_reader :file, :dir
+ before do
+ @original_rspec_options = $rspec_options
+ @file = "#{File.dirname(__FILE__)}/spec_parser/spec_parser_fixture.rb"
+ @dir = File.dirname(file)
+ end
+
+ after do
+ $rspec_options = @original_rspec_options
+ end
+
+ def parse(args)
+ options = super
+ $rspec_options = options
+ options.filename_pattern = "*_fixture.rb"
+ options
+ end
+
+ it "should support --line to identify spec" do
+ options = parse([file, "--line", "13"])
+ options.line_number.should == 13
+ options.examples.should be_empty
+ options.run_examples
+ options.examples.should eql(["d"])
+ end
+
+ it "should fail with error message if file is dir along with --line" do
+ options = parse([dir, "--line", "169"])
+ options.line_number.should == 169
+ options.run_examples
+ @err.string.should match(/You must specify one file, not a directory when using the --line option/n)
+ end
+
+ it "should fail with error message if file does not exist along with --line" do
+ options = parse(["some file", "--line", "169"])
+ proc do
+ options.run_examples
+ end.should raise_error
+ end
+
+ it "should fail with error message if more than one files are specified along with --line" do
+ options = parse([file, file, "--line", "169"])
+ options.run_examples
+ @err.string.should match(/Only one file can be specified when using the --line option/n)
+ end
+
+ it "should fail with error message if --example and --line are used simultaneously" do
+ options = parse([file, "--example", "some example", "--line", "169"])
+ options.run_examples
+ @err.string.should match(/You cannot use both --line and --example/n)
+ end
end
-
+
if [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM}
it "should barf when --heckle is specified (and platform is windows)" do
lambda do
@@ -284,18 +295,24 @@ describe "OptionParser" do
options.heckle_runner.should be_instance_of(Spec::Runner::HeckleRunner)
end
end
-
+
it "should read options from file when --options is specified" do
options = parse(["--options", File.dirname(__FILE__) + "/spec.opts"])
options.diff_format.should_not be_nil
options.colour.should be_true
end
-
+
it "should default the formatter to ProgressBarFormatter when using options file" do
options = parse(["--options", File.dirname(__FILE__) + "/spec.opts"])
options.formatters.first.should be_instance_of(::Spec::Runner::Formatter::ProgressBarFormatter)
end
+ it "should run parse drb after parsing options" do
+ @parser.stub!(:parse_drb)
+ @parser.should_receive(:parse_drb).with(["--drb"]).and_return(true)
+ options = parse(["--options", File.dirname(__FILE__) + "/spec_drb.opts"])
+ end
+
it "should read spaced and multi-line options from file when --options is specified" do
options = parse(["--options", File.dirname(__FILE__) + "/spec_spaced.opts"])
options.diff_format.should_not be_nil
@@ -309,14 +326,14 @@ describe "OptionParser" do
IO.read('test.spec.opts').should == "--colour\n--diff\n"
FileUtils.rm 'test.spec.opts'
end
-
+
it "should save config to file when -G is specified" do
FileUtils.rm 'test.spec.opts' if File.exist?('test.spec.opts')
options = parse(["--colour", "-G", "test.spec.opts", "--diff"])
IO.read('test.spec.opts').should == "--colour\n--diff\n"
FileUtils.rm 'test.spec.opts'
end
-
+
it "when --drb is specified, calls DrbCommandLine all of the other ARGV arguments" do
options = Spec::Runner::OptionParser.parse([
"some/spec.rb", "--diff", "--colour"
@@ -330,7 +347,7 @@ describe "OptionParser" do
it "should reverse spec order when --reverse is specified" do
options = parse(["some/spec.rb", "--reverse"])
end
-
+
it "should set an mtime comparator when --loadby mtime" do
options = parse(["--loadby", 'mtime'])
runner = Spec::Runner::ExampleGroupRunner.new(options)
@@ -338,7 +355,7 @@ describe "OptionParser" do
with(options).
and_return(runner)
runner.should_receive(:load_files).with(["most_recent_spec.rb", "command_line_spec.rb"])
-
+
Dir.chdir(File.dirname(__FILE__)) do
options.files << 'command_line_spec.rb'
options.files << 'most_recent_spec.rb'
@@ -347,7 +364,7 @@ describe "OptionParser" do
FileUtils.rm "most_recent_spec.rb"
end
end
-
+
it "should use the standard runner by default" do
runner = ::Spec::Runner::ExampleGroupRunner.new(@parser.options)
::Spec::Runner::ExampleGroupRunner.should_receive(:new).
@@ -356,7 +373,7 @@ describe "OptionParser" do
options = parse([])
options.run_examples
end
-
+
it "should use a custom runner when given" do
runner = Custom::ExampleGroupRunner.new(@parser.options, nil)
Custom::ExampleGroupRunner.should_receive(:new).
@@ -365,7 +382,7 @@ describe "OptionParser" do
options = parse(["--runner", "Custom::ExampleGroupRunner"])
options.run_examples
end
-
+
it "should use a custom runner with extra options" do
runner = Custom::ExampleGroupRunner.new(@parser.options, 'something')
Custom::ExampleGroupRunner.should_receive(:new).
diff --git a/vendor/plugins/rspec/spec/spec/runner/options_spec.rb b/vendor/plugins/rspec/spec/spec/runner/options_spec.rb
index e4d01b05c..a64356b8c 100644
--- a/vendor/plugins/rspec/spec/spec/runner/options_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/runner/options_spec.rb
@@ -18,6 +18,76 @@ module Spec
@options.examples.should == []
end
end
+
+ describe "#include_pattern" do
+ it "should default to '**/*_spec.rb'" do
+ @options.filename_pattern.should == "**/*_spec.rb"
+ end
+ end
+
+ describe "#files_to_load" do
+
+ it "should load files not following pattern if named explicitly" do
+ file = File.expand_path(File.dirname(__FILE__) + "/resources/a_bar.rb")
+ @options.files << file
+ @options.files_to_load.should include(file)
+ end
+
+ describe "with default --pattern" do
+ it "should load files named _spec.rb" do
+ dir = File.expand_path(File.dirname(__FILE__) + "/resources/")
+ @options.files << dir
+ @options.files_to_load.should == ["#{dir}/a_spec.rb"]
+ end
+ end
+
+ describe "with explicit pattern (single)" do
+ before(:each) do
+ @options.filename_pattern = "**/*_foo.rb"
+ end
+
+ it "should load files following pattern" do
+ file = File.expand_path(File.dirname(__FILE__) + "/resources/a_foo.rb")
+ @options.files << file
+ @options.files_to_load.should include(file)
+ end
+
+ it "should load files in directories following pattern" do
+ dir = File.expand_path(File.dirname(__FILE__) + "/resources")
+ @options.files << dir
+ @options.files_to_load.should include("#{dir}/a_foo.rb")
+ end
+
+ it "should not load files in directories not following pattern" do
+ dir = File.expand_path(File.dirname(__FILE__) + "/resources")
+ @options.files << dir
+ @options.files_to_load.should_not include("#{dir}/a_bar.rb")
+ end
+ end
+
+ describe "with explicit pattern (comma,separated,values)" do
+
+ before(:each) do
+ @options.filename_pattern = "**/*_foo.rb,**/*_bar.rb"
+ end
+
+ it "should support comma separated values" do
+ dir = File.expand_path(File.dirname(__FILE__) + "/resources")
+ @options.files << dir
+ @options.files_to_load.should include("#{dir}/a_foo.rb")
+ @options.files_to_load.should include("#{dir}/a_bar.rb")
+ end
+
+ it "should support comma separated values with spaces" do
+ dir = File.expand_path(File.dirname(__FILE__) + "/resources")
+ @options.files << dir
+ @options.files_to_load.should include("#{dir}/a_foo.rb")
+ @options.files_to_load.should include("#{dir}/a_bar.rb")
+ end
+
+ end
+
+ end
describe "#backtrace_tweaker" do
it "should default to QuietBacktraceTweaker" do
@@ -223,39 +293,44 @@ module Spec
end
describe "#run_examples" do
- it "should use the standard runner by default" do
- runner = ::Spec::Runner::ExampleGroupRunner.new(@options)
- ::Spec::Runner::ExampleGroupRunner.should_receive(:new).
+ describe "when not given a custom runner" do
+ it "should use the standard" do
+ runner = ::Spec::Runner::ExampleGroupRunner.new(@options)
+ ::Spec::Runner::ExampleGroupRunner.should_receive(:new).
with(@options).
and_return(runner)
- @options.user_input_for_runner = nil
+ @options.user_input_for_runner = nil
- @options.run_examples
+ @options.run_examples
+ end
end
- it "should use a custom runner when given" do
- runner = Custom::ExampleGroupRunner.new(@options, nil)
- Custom::ExampleGroupRunner.should_receive(:new).
+ describe "when given a custom runner" do
+ it "should use the custom runner" do
+ runner = Custom::ExampleGroupRunner.new(@options, nil)
+ Custom::ExampleGroupRunner.should_receive(:new).
with(@options, nil).
and_return(runner)
- @options.user_input_for_runner = "Custom::ExampleGroupRunner"
+ @options.user_input_for_runner = "Custom::ExampleGroupRunner"
- @options.run_examples
- end
+ @options.run_examples
+ end
- it "should use a custom runner with extra options" do
- runner = Custom::ExampleGroupRunner.new(@options, 'something')
- Custom::ExampleGroupRunner.should_receive(:new).
+ it "should use the custom runner with extra options" do
+ runner = Custom::ExampleGroupRunner.new(@options, 'something')
+ Custom::ExampleGroupRunner.should_receive(:new).
with(@options, 'something').
and_return(runner)
- @options.user_input_for_runner = "Custom::ExampleGroupRunner:something"
+ @options.user_input_for_runner = "Custom::ExampleGroupRunner:something"
- @options.run_examples
+ @options.run_examples
+ end
end
- describe "#run_examples when there are example_group" do
+ describe "when there are examples" do
before(:each) do
- @options.add_example_group Class.new(::Spec::Example::ExampleGroup)
+ @example_group = Class.new(::Spec::Example::ExampleGroup)
+ @options.add_example_group @example_group
@options.formatters << Formatter::BaseTextFormatter.new(@options, @out)
end
@@ -269,9 +344,80 @@ module Spec
@options.run_examples
@options.examples_run?.should be_true
end
+
+ describe "and the suite passes" do
+ before do
+ @example_group.should_receive(:run).and_return(true)
+ end
+
+ it "invokes after_suite_parts with true" do
+ success_result = nil
+ @options.after_suite_parts << lambda do |success|
+ success_result = success
+ end
+
+ @options.run_examples
+ success_result.should be_true
+ end
+ end
+
+ describe "and the suite fails" do
+ before do
+ @example_group.should_receive(:run).and_return(false)
+ end
+
+ it "invokes after_suite_parts with false" do
+ success_result = nil
+ @options.after_suite_parts << lambda do |success|
+ success_result = success
+ end
+
+ @options.run_examples
+ success_result.should be_false
+ end
+ end
+
+ describe "when using heckle runner" do
+ before(:each) do
+ @heckle_runner_mock = mock("HeckleRunner")
+ @options.heckle_runner = @heckle_runner_mock
+ end
+
+ it "should heckle" do
+ @heckle_runner_mock.should_receive(:heckle_with)
+ @options.run_examples
+ end
+
+ it "shouldn't heckle recursively" do
+ heckled = false
+ @heckle_runner_mock.should_receive(:heckle_with) {
+ heckled.should == false
+ heckled = true
+ @options.run_examples
+ }
+ @options.run_examples
+ end
+
+ it "shouldn't load spec files twice" do
+ example_runner = mock("ExampleGroupRunner")
+ example_runner_inside_heckle = mock("ExampleGroupRunner inside Heckle")
+
+ ExampleGroupRunner.should_receive(:new).twice.and_return(
+ example_runner, example_runner_inside_heckle
+ )
+
+ example_runner.stub!(:run)
+ example_runner.should_receive(:load_files)
+ @heckle_runner_mock.stub!(:heckle_with).and_return { @options.run_examples }
+ example_runner_inside_heckle.stub!(:run)
+ example_runner_inside_heckle.should_not_receive(:load_files)
+
+ @options.run_examples
+ end
+ end
end
- describe "#run_examples when there are no example_group" do
+ describe "when there are no examples" do
before(:each) do
@options.formatters << Formatter::BaseTextFormatter.new(@options, @out)
end
@@ -287,6 +433,16 @@ module Spec
@options.run_examples
@options.examples_run?.should be_false
end
+
+ it "invokes after_suite_parts with true" do
+ success_result = nil
+ @options.after_suite_parts << lambda do |success|
+ success_result = success
+ end
+
+ @options.run_examples
+ success_result.should be_true
+ end
end
end
end
diff --git a/vendor/plugins/rspec/spec/spec/runner/reporter_spec.rb b/vendor/plugins/rspec/spec/spec/runner/reporter_spec.rb
index 52377e7f3..b02a4cf6f 100644
--- a/vendor/plugins/rspec/spec/spec/runner/reporter_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/runner/reporter_spec.rb
@@ -21,8 +21,10 @@ module Spec
end
def create_example_group(description_text)
- example_group = Class.new(Spec::Example::ExampleGroup)
- example_group.describe description_text
+ example_group = Spec::Example::ExampleGroup.describe(description_text) do
+ it "should do something" do
+ end
+ end
example_group
end
@@ -127,8 +129,9 @@ module Spec
describe Reporter, "reporting one failing example" do
it "should tell formatter that example failed" do
+ example = example_group.it("should do something") {}
formatter.should_receive(:example_failed)
- reporter.example_finished(example_group, RuntimeError.new)
+ reporter.example_finished(example, RuntimeError.new)
end
it "should delegate to backtrace tweaker" do
@@ -154,7 +157,7 @@ module Spec
describe Reporter, "reporting one pending example (ExamplePendingError)" do
it "should tell formatter example is pending" do
example = ExampleGroup.new("example")
- formatter.should_receive(:example_pending).with(example_group.description, example, "reason")
+ formatter.should_receive(:example_pending).with(example, "reason")
formatter.should_receive(:add_example_group).with(example_group)
reporter.add_example_group(example_group)
reporter.example_finished(example, Spec::Example::ExamplePendingError.new("reason"))
@@ -162,7 +165,7 @@ module Spec
it "should account for pending example in stats" do
example = ExampleGroup.new("example")
- formatter.should_receive(:example_pending).with(example_group.description, example, "reason")
+ formatter.should_receive(:example_pending).with(example, "reason")
formatter.should_receive(:start_dump)
formatter.should_receive(:dump_pending)
formatter.should_receive(:dump_summary).with(anything(), 1, 0, 1)
@@ -177,11 +180,11 @@ module Spec
describe Reporter, "reporting one pending example (PendingExampleFixedError)" do
it "should tell formatter pending example is fixed" do
formatter.should_receive(:example_failed) do |name, counter, failure|
- failure.header.should == "'example_group example' FIXED"
+ failure.header.should == "'example_group should do something' FIXED"
end
formatter.should_receive(:add_example_group).with(example_group)
reporter.add_example_group(example_group)
- reporter.example_finished(ExampleGroup.new("example"), Spec::Example::PendingExampleFixedError.new("reason"))
+ reporter.example_finished(example_group.examples.first, Spec::Example::PendingExampleFixedError.new("reason"))
end
end
end
diff --git a/vendor/plugins/rspec/spec/spec/runner/resources/a_bar.rb b/vendor/plugins/rspec/spec/spec/runner/resources/a_bar.rb
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/runner/resources/a_bar.rb
diff --git a/vendor/plugins/rspec/spec/spec/runner/resources/a_foo.rb b/vendor/plugins/rspec/spec/spec/runner/resources/a_foo.rb
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/runner/resources/a_foo.rb
diff --git a/vendor/plugins/rspec/spec/spec/runner/resources/a_spec.rb b/vendor/plugins/rspec/spec/spec/runner/resources/a_spec.rb
new file mode 100644
index 000000000..d9b67cc76
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/runner/resources/a_spec.rb
@@ -0,0 +1 @@
+# Empty - used by ../options_spec.rb \ No newline at end of file
diff --git a/vendor/plugins/rspec/spec/spec/runner/spec_drb.opts b/vendor/plugins/rspec/spec/spec/runner/spec_drb.opts
new file mode 100644
index 000000000..091e4c222
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/runner/spec_drb.opts
@@ -0,0 +1 @@
+--drb
diff --git a/vendor/plugins/rspec/spec/spec/runner/spec_parser/spec_parser_fixture.rb b/vendor/plugins/rspec/spec/spec/runner/spec_parser/spec_parser_fixture.rb
new file mode 100644
index 000000000..14602d934
--- /dev/null
+++ b/vendor/plugins/rspec/spec/spec/runner/spec_parser/spec_parser_fixture.rb
@@ -0,0 +1,70 @@
+require File.dirname(__FILE__) + '/../../../spec_helper.rb'
+
+describe "c" do
+
+ it "1" do
+ end
+
+ it "2" do
+ end
+
+end
+
+describe "d" do
+
+ it "3" do
+ end
+
+ it "4" do
+ end
+
+end
+
+class SpecParserSubject
+end
+
+describe SpecParserSubject do
+
+ it "5" do
+ end
+
+end
+
+describe SpecParserSubject, "described" do
+
+ it "6" do
+ end
+
+end
+
+describe SpecParserSubject, "described", :something => :something_else do
+
+ it "7" do
+ end
+
+end
+
+describe "described", :something => :something_else do
+
+ it "8" do
+ end
+
+end
+
+describe "e" do
+
+ it "9" do
+ end
+
+ it "10" do
+ end
+
+ describe "f" do
+ it "11" do
+ end
+
+ it "12" do
+ end
+ end
+
+end
diff --git a/vendor/plugins/rspec/spec/spec/runner/spec_parser_spec.rb b/vendor/plugins/rspec/spec/spec/runner/spec_parser_spec.rb
index 301155d04..7204ba3e6 100644
--- a/vendor/plugins/rspec/spec/spec/runner/spec_parser_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/runner/spec_parser_spec.rb
@@ -1,124 +1,85 @@
require File.dirname(__FILE__) + '/../../spec_helper.rb'
-describe "c" do
-
- it "1" do
- end
-
- it "2" do
- end
-
-end
-
-describe "d" do
-
- it "3" do
- end
-
- it "4" do
- end
-
-end
-
-class SpecParserSubject
-end
-
-describe SpecParserSubject do
-
- it "5" do
- end
-
-end
-
-describe SpecParserSubject, "described" do
-
- it "6" do
- end
-
-end
-
-describe SpecParserSubject, "described", :something => :something_else do
-
- it "7" do
- end
-
-end
-
-describe "described", :something => :something_else do
-
- it "8" do
- end
-
-end
-
-
describe "SpecParser" do
+ attr_reader :parser, :file
before(:each) do
- @p = Spec::Runner::SpecParser.new
+ @original_rspec_options = $rspec_options
+ $rspec_options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new)
+ @parser = Spec::Runner::SpecParser.new
+ @file = "#{File.dirname(__FILE__)}/spec_parser/spec_parser_fixture.rb"
+ load file
+ end
+
+ after do
+ $rspec_options = @original_rspec_options
end
it "should find spec name for 'specify' at same line" do
- @p.spec_name_for(File.open(__FILE__), 5).should == "c 1"
+ parser.spec_name_for(file, 5).should == "c 1"
end
it "should find spec name for 'specify' at end of spec line" do
- @p.spec_name_for(File.open(__FILE__), 6).should == "c 1"
+ parser.spec_name_for(file, 6).should == "c 1"
end
it "should find context for 'context' above all specs" do
- @p.spec_name_for(File.open(__FILE__), 4).should == "c"
+ parser.spec_name_for(file, 4).should == "c"
end
it "should find spec name for 'it' at same line" do
- @p.spec_name_for(File.open(__FILE__), 15).should == "d 3"
+ parser.spec_name_for(file, 15).should == "d 3"
end
it "should find spec name for 'it' at end of spec line" do
- @p.spec_name_for(File.open(__FILE__), 16).should == "d 3"
+ parser.spec_name_for(file, 16).should == "d 3"
end
it "should find context for 'describe' above all specs" do
- @p.spec_name_for(File.open(__FILE__), 14).should == "d"
+ parser.spec_name_for(file, 14).should == "d"
end
- it "should find nearest example name between examples" do
- @p.spec_name_for(File.open(__FILE__), 7).should == "c 1"
- end
+ it "should find nearest example name between examples" do
+ parser.spec_name_for(file, 7).should == "c 1"
+ end
it "should find nothing outside a context" do
- @p.spec_name_for(File.open(__FILE__), 2).should be_nil
+ parser.spec_name_for(file, 2).should be_nil
end
-
+
it "should find context name for type" do
- @p.spec_name_for(File.open(__FILE__), 26).should == "SpecParserSubject"
+ parser.spec_name_for(file, 26).should == "SpecParserSubject"
end
-
+
it "should find context and spec name for type" do
- @p.spec_name_for(File.open(__FILE__), 28).should == "SpecParserSubject 5"
+ parser.spec_name_for(file, 28).should == "SpecParserSubject 5"
end
it "should find context and description for type" do
- @p.spec_name_for(File.open(__FILE__), 33).should == "SpecParserSubject described"
+ parser.spec_name_for(file, 33).should == "SpecParserSubject described"
end
-
+
it "should find context and description and example for type" do
- @p.spec_name_for(File.open(__FILE__), 36).should == "SpecParserSubject described 6"
+ parser.spec_name_for(file, 36).should == "SpecParserSubject described 6"
end
it "should find context and description for type with modifications" do
- @p.spec_name_for(File.open(__FILE__), 40).should == "SpecParserSubject described"
+ parser.spec_name_for(file, 40).should == "SpecParserSubject described"
end
-
+
it "should find context and described and example for type with modifications" do
- @p.spec_name_for(File.open(__FILE__), 43).should == "SpecParserSubject described 7"
+ parser.spec_name_for(file, 43).should == "SpecParserSubject described 7"
end
-
+
it "should find example group" do
- @p.spec_name_for(File.open(__FILE__), 47).should == "described"
+ parser.spec_name_for(file, 47).should == "described"
end
-
+
it "should find example" do
- @p.spec_name_for(File.open(__FILE__), 50).should == "described 8"
+ parser.spec_name_for(file, 50).should == "described 8"
end
-
+
+ it "should find nested example" do
+ parser.spec_name_for(file, 63).should == "e f 11"
+ end
+
end
diff --git a/vendor/plugins/rspec/spec/spec/spec_classes.rb b/vendor/plugins/rspec/spec/spec/spec_classes.rb
index 73b0e33e8..c8900a789 100644
--- a/vendor/plugins/rspec/spec/spec/spec_classes.rb
+++ b/vendor/plugins/rspec/spec/spec/spec_classes.rb
@@ -122,6 +122,10 @@ module Custom
def initialize(options)
@options = options
end
+
+ def diff_as_object(target, expected)
+ ""
+ end
end
end
diff --git a/vendor/plugins/rspec/spec/spec/story/runner/plain_text_story_runner_spec.rb b/vendor/plugins/rspec/spec/spec/story/runner/plain_text_story_runner_spec.rb
index 1d5f2e0c3..91f5f9e9b 100644
--- a/vendor/plugins/rspec/spec/spec/story/runner/plain_text_story_runner_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/story/runner/plain_text_story_runner_spec.rb
@@ -22,28 +22,29 @@ module Spec
it "should parse a story file" do
runner = PlainTextStoryRunner.new("path")
-
during {
- runner.run
+ runner.run(mock('runner'))
}.expect {
@parser.should_receive(:parse).with(["this", "and that"])
}
end
it "should build up a mediator with its own steps and the singleton story_runner" do
+ @story_runner = mock('story runner', :null_object => true)
+
runner = PlainTextStoryRunner.new("path")
- Spec::Story::Runner.should_receive(:story_runner).and_return(story_runner = mock("story runner"))
- Spec::Story::Runner::StoryMediator.should_receive(:new).with(runner.steps, story_runner, {}).
- and_return(mediator = stub("mediator", :run_stories => nil))
- runner.run
+
+ Spec::Story::Runner::StoryMediator.should_receive(:new).with(
+ runner.steps, @story_runner, {}
+ ).and_return(mediator = stub("mediator", :run_stories => nil))
+ runner.run(@story_runner)
end
it "should build up a parser with the mediator" do
runner = PlainTextStoryRunner.new("path")
- Spec::Story::Runner.should_receive(:story_runner).and_return(story_runner = mock("story runner"))
Spec::Story::Runner::StoryMediator.should_receive(:new).and_return(mediator = stub("mediator", :run_stories => nil))
Spec::Story::Runner::StoryParser.should_receive(:new).with(mediator).and_return(@parser)
- runner.run
+ runner.run(stub("story_runner"))
end
it "should tell the mediator to run the stories" do
@@ -51,7 +52,7 @@ module Spec
mediator = mock("mediator")
Spec::Story::Runner::StoryMediator.should_receive(:new).and_return(mediator)
mediator.should_receive(:run_stories)
- runner.run
+ runner.run(mock('runner'))
end
it "should accept a block instead of a path" do
@@ -59,13 +60,13 @@ module Spec
runner.load("path/to/story")
end
File.should_receive(:read).with("path/to/story").and_return("this\nand that")
- runner.run
+ runner.run(mock('runner'))
end
it "should tell you if you try to run with no path set" do
runner = PlainTextStoryRunner.new
lambda {
- runner.run
+ runner.run(mock('runner'))
}.should raise_error(RuntimeError, "You must set a path to the file with the story. See the RDoc.")
end
@@ -74,7 +75,7 @@ module Spec
Spec::Story::Runner::StoryMediator.should_receive(:new).
with(anything, anything, :foo => :bar).
and_return(mediator = stub("mediator", :run_stories => nil))
- runner.run
+ runner.run(mock('runner'))
end
it "should provide access to its options" do
@@ -83,7 +84,7 @@ module Spec
Spec::Story::Runner::StoryMediator.should_receive(:new).
with(anything, anything, :foo => :bar).
and_return(mediator = stub("mediator", :run_stories => nil))
- runner.run
+ runner.run mock('runner')
end
end
diff --git a/vendor/plugins/rspec/spec/spec/story/runner/scenario_runner_spec.rb b/vendor/plugins/rspec/spec/spec/story/runner/scenario_runner_spec.rb
index a69ed4a99..c13c3d7f8 100644
--- a/vendor/plugins/rspec/spec/spec/story/runner/scenario_runner_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/story/runner/scenario_runner_spec.rb
@@ -70,71 +70,143 @@ module Spec
# then
end
-
- it 'should notify listeners when a scenario succeeds' do
- # given
- world = stub_everything('world')
- story = Story.new 'story', 'narrative' do end
- scenario = Scenario.new story, 'scenario1' do
- # succeeds
+ describe "when a scenario succeeds" do
+ before(:each) do
+ # given
+ @world = stub_everything('world')
+ @story = Story.new 'story', 'narrative' do end
+ @scenario = Scenario.new @story, 'scenario1' do
+ # succeeds
+ end
+ @scenario_runner = ScenarioRunner.new
end
- scenario_runner = ScenarioRunner.new
- mock_listener1 = stub_everything('listener1')
- mock_listener2 = stub_everything('listener2')
- scenario_runner.add_listener(mock_listener1)
- scenario_runner.add_listener(mock_listener2)
- # expect
- mock_listener1.should_receive(:scenario_succeeded).with('story', 'scenario1')
- mock_listener2.should_receive(:scenario_succeeded).with('story', 'scenario1')
-
- # when
- scenario_runner.run(scenario, world)
+ it 'should notify listeners' do
+ #given
+ mock_listener1 = stub_everything('listener1')
+ mock_listener2 = stub_everything('listener2')
+ @scenario_runner.add_listener(mock_listener1)
+ @scenario_runner.add_listener(mock_listener2)
+
+ # expect
+ mock_listener1.should_receive(:scenario_succeeded).with('story', 'scenario1')
+ mock_listener2.should_receive(:scenario_succeeded).with('story', 'scenario1')
+
+ # when
+ @scenario_runner.run(@scenario, @world)
+
+ # then
+ end
- # then
+ it "should return true" do
+ #when
+ success = @scenario_runner.run(@scenario, @world)
+
+ #then
+ success.should == true
+ end
end
-
- it 'should notify listeners ONCE when a scenario raises an error' do
- # given
- error = RuntimeError.new('oops')
- story = Story.new 'title', 'narrative' do end
- scenario = Scenario.new story, 'scenario1' do
+
+ describe "when a scenario raises an error (other than a pending error)" do
+ before(:each) do
+ # given
+ @error = RuntimeError.new('oops')
+ @story = Story.new 'title', 'narrative' do end
+ @scenario = Scenario.new @story, 'scenario1' do
+ end
+ @scenario_runner = ScenarioRunner.new
+ @world = stub_everything
+
+ # expect
+ @world.should_receive(:errors).twice.and_return([@error, @error])
end
- scenario_runner = ScenarioRunner.new
- mock_listener = stub_everything('listener')
- scenario_runner.add_listener(mock_listener)
- world = stub_everything
- # expect
- world.should_receive(:errors).twice.and_return([error, error])
- mock_listener.should_receive(:scenario_failed).with('title', 'scenario1', error).once
+ it 'should notify listeners ONCE' do
+ #given
+ mock_listener = stub_everything('listener')
+ @scenario_runner.add_listener(mock_listener)
+
+ #expect
+ mock_listener.should_receive(:scenario_failed).with('title', 'scenario1', @error).once
+
+ # when
+ @scenario_runner.run @scenario, @world
+
+ # then
+ end
+
+ it "should return false" do
+ # when
+ success = @scenario_runner.run @scenario, @world
+
+ # then
+ success.should == false
+ end
- # when
- scenario_runner.run scenario, world
- # then
end
- it 'should notify listeners when a scenario is pending' do
- # given
- pending_error = Spec::Example::ExamplePendingError.new('todo')
- story = Story.new 'title', 'narrative' do end
- scenario = Scenario.new story, 'scenario1' do
+ describe "when a scenario is pending" do
+ before(:each) do
+ # given
+ @pending_error = Spec::Example::ExamplePendingError.new('todo')
+ @story = Story.new 'title', 'narrative' do end
+ @scenario = Scenario.new @story, 'scenario1' do
+ end
+ @scenario_runner = ScenarioRunner.new
+ @world = stub_everything
+
+ # expect
+ @world.should_receive(:errors).twice.and_return([@pending_error, @pending_error])
end
- scenario_runner = ScenarioRunner.new
- mock_listener = mock('listener')
- scenario_runner.add_listener(mock_listener)
- world = stub_everything
- # expect
- world.should_receive(:errors).twice.and_return([pending_error, pending_error])
- mock_listener.should_receive(:scenario_started).with('title', 'scenario1')
- mock_listener.should_receive(:scenario_pending).with('title', 'scenario1', 'todo').once
-
- # when
- scenario_runner.run scenario, world
+ it 'should notify listeners' do
+ #given
+ mock_listener = mock('listener')
+ @scenario_runner.add_listener(mock_listener)
+
+ # expect
+ mock_listener.should_receive(:scenario_started).with('title', 'scenario1')
+ mock_listener.should_receive(:scenario_pending).with('title', 'scenario1', 'todo').once
+
+ # when
+ @scenario_runner.run @scenario, @world
+
+ # then
+ end
- # then
+ it "should return true" do
+ # when
+ success = @scenario_runner.run @scenario, @world
+
+ # then
+ success.should == true
+ end
+ end
+
+ describe "when a scenario has an empty body" do
+ before(:each) do
+ @story = Story.new 'title', 'narrative' do end
+ @scenario = Scenario.new @story, 'scenario'
+ @scenario_runner = ScenarioRunner.new
+ @world = stub_everything
+ end
+
+ it "should mark the scenario as pending" do
+ mock_listener = stub('listener', :scenario_started => true)
+ @scenario_runner.add_listener mock_listener
+
+ mock_listener.should_receive(:scenario_pending).with('title', 'scenario', '')
+ @scenario_runner.run @scenario, @world
+ end
+
+ it "should return true" do
+ # when
+ success = @scenario_runner.run @scenario, @world
+
+ # then
+ success.should == true
+ end
end
end
end
diff --git a/vendor/plugins/rspec/spec/spec/story/runner/story_mediator_spec.rb b/vendor/plugins/rspec/spec/spec/story/runner/story_mediator_spec.rb
index 4192e483a..32abe5e05 100644
--- a/vendor/plugins/rspec/spec/spec/story/runner/story_mediator_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/story/runner/story_mediator_spec.rb
@@ -47,7 +47,7 @@ module Spec
@runner.scenarios.first.name.should == "scenario name"
@runner.scenarios.first.story.should == @runner.stories.first
end
-
+
it "should create a given scenario step if one matches" do
pending("need to untangle the dark mysteries of the story runner - something needs to get stubbed here") do
story = @mediator.create_story "title", "narrative"
@@ -120,7 +120,7 @@ module Spec
it "should pass options to the stories it creates" do
@mediator = StoryMediator.new @step_group, @runner, :foo => :bar
@mediator.create_story "story title", "story narrative"
-
+
run_stories
@runner.stories.first[:foo].should == :bar
diff --git a/vendor/plugins/rspec/spec/spec/story/runner/story_runner_spec.rb b/vendor/plugins/rspec/spec/spec/story/runner/story_runner_spec.rb
index 0fc46405a..5bed6c562 100644
--- a/vendor/plugins/rspec/spec/spec/story/runner/story_runner_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/story/runner/story_runner_spec.rb
@@ -68,6 +68,44 @@ module Spec
worlds[0].should_not == worlds[1]
end
+ it "should return false if the scenario runner returns false ever" do
+ #given
+ stub_scenario_runner = stub_everything
+ story_runner = StoryRunner.new(stub_scenario_runner)
+ story_runner.Story 'story', 'narrative' do
+ Scenario 'scenario1' do end
+ Scenario 'scenario2' do end
+ end
+
+ # expect
+ stub_scenario_runner.should_receive(:run).once.and_return(false,true)
+
+ # when
+ success = story_runner.run_stories
+
+ #then
+ success.should == false
+ end
+
+ it "should return true if the scenario runner returns true for all scenarios" do
+ #given
+ stub_scenario_runner = stub_everything
+ story_runner = StoryRunner.new(stub_scenario_runner)
+ story_runner.Story 'story', 'narrative' do
+ Scenario 'scenario1' do end
+ Scenario 'scenario2' do end
+ end
+
+ # expect
+ stub_scenario_runner.should_receive(:run).once.and_return(true,true)
+
+ # when
+ success = story_runner.run_stories
+
+ #then
+ success.should == true
+ end
+
it 'should use the provided world creator to create worlds' do
# given
stub_scenario_runner = stub_everything
@@ -225,7 +263,7 @@ module Spec
steps1 = StepGroup.new
steps1.add :when, step1
- story_runner.Story 'title', 'narrative', :steps => steps1 do
+ story_runner.Story 'title', 'narrative', :steps_for => steps1 do
Scenario 'first scenario' do
When 'step'
end
@@ -237,7 +275,7 @@ module Spec
steps2 = StepGroup.new
steps2.add :when, step2
- story_runner.Story 'title2', 'narrative', :steps => steps2 do
+ story_runner.Story 'title2', 'narrative', :steps_for => steps2 do
Scenario 'second scenario' do
When 'step'
end
diff --git a/vendor/plugins/rspec/spec/spec/story/runner_spec.rb b/vendor/plugins/rspec/spec/spec/story/runner_spec.rb
index 81e852640..db1c40de5 100644
--- a/vendor/plugins/rspec/spec/spec/story/runner_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/story/runner_spec.rb
@@ -1,29 +1,19 @@
require File.dirname(__FILE__) + '/story_helper'
+require 'spec/runner/formatter/story/plain_text_formatter'
+require 'spec/runner/formatter/story/html_formatter'
module Spec
module Story
describe Runner, "module" do
- def dev_null
- io = StringIO.new
- def io.write(str)
- str.to_s.size
- end
- return io
- end
-
- before :each do
- Kernel.stub!(:at_exit)
- @stdout, $stdout = $stdout, dev_null
- @argv = Array.new(ARGV)
- @runner_module = Runner.dup
+ before(:each) do
@world_creator = World.dup
- @runner_module.module_eval { @run_options = @story_runner = @scenario_runner = @world_creator = nil }
+ @runner_module = Runner.dup
+ @runner_module.instance_eval {@story_runner = nil}
+ @runner_module.stub!(:register_exit_hook)
end
- after :each do
- $stdout = @stdout
- ARGV.replace @argv
- @runner_module.module_eval { @run_options = @story_runner = @scenario_runner = @world_creator = nil }
+ def create_options(args=[])
+ Spec::Runner::OptionParser.parse(args, StringIO.new, StringIO.new)
end
it 'should wire up a singleton StoryRunner' do
@@ -32,75 +22,72 @@ module Spec
it 'should set its options based on ARGV' do
# given
- ARGV << '--dry-run'
-
+ @runner_module.should_receive(:run_options).and_return(
+ create_options(['--dry-run'])
+ )
+
# when
options = @runner_module.run_options
# then
options.dry_run.should be_true
end
-
- it 'should add a reporter to the runner classes' do
- # given
- story_runner = mock('story runner', :null_object => true)
- scenario_runner = mock('scenario runner', :null_object => true)
- world_creator = mock('world', :null_object => true)
-
- @runner_module::class_eval { @world_creator = world_creator }
- @runner_module::StoryRunner.stub!(:new).and_return(story_runner)
- @runner_module::ScenarioRunner.stub!(:new).and_return(scenario_runner)
-
- # expect
- world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
- story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
- scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
-
- # when
- @runner_module.story_runner
- end
- it 'should add a documenter to the runner classes if one is specified' do
- # given
- ARGV << "--format" << "html"
- story_runner = mock('story runner', :null_object => true)
- scenario_runner = mock('scenario runner', :null_object => true)
- world_creator = mock('world', :null_object => true)
+ describe "initialization" do
- @runner_module::class_eval { @world_creator = world_creator }
- @runner_module::StoryRunner.stub!(:new).and_return(story_runner)
- @runner_module::ScenarioRunner.stub!(:new).and_return(scenario_runner)
+ before(:each) do
+ # given
+ @story_runner = mock('story runner', :null_object => true)
+ @scenario_runner = mock('scenario runner', :null_object => true)
+ @world_creator = mock('world', :null_object => true)
- # expect
- world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
- story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
- scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
+ @runner_module.stub!(:world_creator).and_return(@world_creator)
+ @runner_module.stub!(:create_story_runner).and_return(@story_runner)
+ @runner_module.stub!(:scenario_runner).and_return(@scenario_runner)
+ end
+
+ it 'should add a reporter to the runner classes' do
+ @runner_module.should_receive(:run_options).and_return(
+ create_options
+ )
- # when
- @runner_module.story_runner
- end
+ # expect
+ @world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
+ @story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
+ @scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::PlainTextFormatter))
+
+ # when
+ @runner_module.story_runner
+ end
- it 'should add any registered listener to the runner classes' do
- # given
- ARGV << "--format" << "html"
- story_runner = mock('story runner', :null_object => true)
- scenario_runner = mock('scenario runner', :null_object => true)
- world_creator = mock('world', :null_object => true)
+ it 'should add a documenter to the runner classes if one is specified' do
- @runner_module::class_eval { @world_creator = world_creator }
- @runner_module::StoryRunner.stub!(:new).and_return(story_runner)
- @runner_module::ScenarioRunner.stub!(:new).and_return(scenario_runner)
+ @runner_module.should_receive(:run_options).and_return(
+ create_options(["--format","html"])
+ )
+
+ # expect
+ @world_creator.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
+ @story_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
+ @scenario_runner.should_receive(:add_listener).with(an_instance_of(Spec::Runner::Formatter::Story::HtmlFormatter))
- listener = Object.new
+ # when
+ @runner_module.story_runner
+ end
+
+ it 'should add any registered listener to the runner classes' do
+ # given
+ listener = Object.new
- # expect
- world_creator.should_receive(:add_listener).with(listener)
- story_runner.should_receive(:add_listener).with(listener)
- scenario_runner.should_receive(:add_listener).with(listener)
+ # expect
+ @world_creator.should_receive(:add_listener).with(listener)
+ @story_runner.should_receive(:add_listener).with(listener)
+ @scenario_runner.should_receive(:add_listener).with(listener)
- # when
- @runner_module.register_listener listener
+ # when
+ @runner_module.register_listener listener
+ end
+ end
end
- end
end
end
diff --git a/vendor/plugins/rspec/spec/spec/story/step_spec.rb b/vendor/plugins/rspec/spec/spec/story/step_spec.rb
index ec6628809..2b523607a 100644
--- a/vendor/plugins/rspec/spec/spec/story/step_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/story/step_spec.rb
@@ -42,6 +42,16 @@ module Spec
step = Step.new("1 2 $three") {}
step.matches?("1 2 c").should be_true
end
+
+ it "should match a text string with a dollar sign ($)" do
+ step = Step.new("show me the $$money") {}
+ step.matches?("show me the $kwan").should be_true
+ end
+
+ it "should match a string with an escaped dollar sign" do
+ step = Step.new("show me the \$money") {}
+ step.matches?("show me the $kwan").should be_true
+ end
it "should not match a different string" do
step = Step.new("this text") {}
@@ -58,11 +68,21 @@ module Spec
step.matches?("this anything text").should be_true
end
+ it "should match a regexp with a named variable" do
+ step = Step.new(/this $variable text/) {}
+ step.matches?("this anything text").should be_true
+ end
+
it "should not match a non matching regexp" do
step = Step.new(/this (.*) text/) {}
step.matches?("other anything text").should be_false
end
+ it "should not match a non matching regexp with a named variable" do
+ step = Step.new(/this $variable text/) {}
+ step.matches?("other anything text").should be_false
+ end
+
it "should not get bogged down by parens in strings" do
step = Step.new("before () after") {}
step.matches?("before () after").should be_true
@@ -80,6 +100,27 @@ module Spec
step.parse_args("he is cool").should == ['he', 'cool']
end
+ it "should match alteration as well as a named variable" do
+ step = Step.new(/(he|she) is $adjective/) {}
+ step.matches?("he is cool").should be_true
+ step.parse_args("he is cool").should == ['he', 'cool']
+ end
+
+ it "should match alteration as well as a anonymous and named variable" do
+ step = Step.new(/(he|she) is (.*?) $adjective/) {}
+ step.matches?("he is very cool").should be_true
+ step.parse_args("he is very cool").should == ['he', 'very', 'cool']
+ end
+
+ it "should match a regex with a dollar sign ($)" do
+ step = Step.new(/show me the \$\d+/) {}
+ step.matches?("show me the $123").should be_true
+ end
+
+ it "should match a regex with a dollar sign and named variable" do
+ step = Step.new(/show me the \$$money/) {}
+ step.matches?("show me the $123").should be_true
+ end
end
describe Step do
diff --git a/vendor/plugins/rspec/spec/spec/story/story_spec.rb b/vendor/plugins/rspec/spec/spec/story/story_spec.rb
index 21257e9a7..f6bce544f 100644
--- a/vendor/plugins/rspec/spec/spec/story/story_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/story/story_spec.rb
@@ -28,7 +28,7 @@ module Spec
error.should be_nil
end
- it "should raise when error raised running in another object" do
+ it "should raise an error when an error is raised running in another object" do
#given
story = Story.new 'title', 'narrative' do
raise "this is raised in the story"
@@ -42,7 +42,7 @@ module Spec
end
it "should use the steps it is told to using a StepGroup" do
- story = Story.new("title", "narrative", :steps => steps = StepGroup.new) do end
+ story = Story.new("title", "narrative", :steps_for => steps = StepGroup.new) do end
assignee = mock("assignee")
assignee.should_receive(:use).with(steps)
story.assign_steps_to(assignee)
diff --git a/vendor/plugins/rspec/spec/spec/story/world_spec.rb b/vendor/plugins/rspec/spec/spec/story/world_spec.rb
index 85410f612..f5113dc42 100644
--- a/vendor/plugins/rspec/spec/spec/story/world_spec.rb
+++ b/vendor/plugins/rspec/spec/spec/story/world_spec.rb
@@ -298,12 +298,18 @@ module Spec
World.add_listener(mock_listener2)
# expect
+ mock_listener1.should_receive(:step_upcoming).with(:given, 'a context')
mock_listener1.should_receive(:step_succeeded).with(:given, 'a context')
+ mock_listener1.should_receive(:step_upcoming).with(:when, 'an event')
mock_listener1.should_receive(:step_succeeded).with(:when, 'an event')
+ mock_listener1.should_receive(:step_upcoming).with(:then, 'an outcome')
mock_listener1.should_receive(:step_succeeded).with(:then, 'an outcome')
+ mock_listener2.should_receive(:step_upcoming).with(:given, 'a context')
mock_listener2.should_receive(:step_succeeded).with(:given, 'a context')
+ mock_listener2.should_receive(:step_upcoming).with(:when, 'an event')
mock_listener2.should_receive(:step_succeeded).with(:when, 'an event')
+ mock_listener2.should_receive(:step_upcoming).with(:then, 'an outcome')
mock_listener2.should_receive(:step_succeeded).with(:then, 'an outcome')
# when
@@ -325,6 +331,7 @@ module Spec
world = World.create
# expect
+ mock_listener.should_receive(:step_upcoming).with(:given, 'a context')
mock_listener.should_receive(:step_succeeded).with(:given, 'a context')
# when
diff --git a/vendor/plugins/rspec/stories/all.rb b/vendor/plugins/rspec/stories/all.rb
index c2428fdf8..83f557032 100644
--- a/vendor/plugins/rspec/stories/all.rb
+++ b/vendor/plugins/rspec/stories/all.rb
@@ -1,5 +1,5 @@
require File.join(File.dirname(__FILE__), *%w[helper])
-["example_groups","interop"].each do |dir|
+%w[example_groups interop mock_framework_integration].each do |dir|
require File.join(File.dirname(__FILE__), "#{dir}/stories")
end
diff --git a/vendor/plugins/rspec/stories/example_groups/stories.rb b/vendor/plugins/rspec/stories/example_groups/stories.rb
index e45882a93..2def16b86 100644
--- a/vendor/plugins/rspec/stories/example_groups/stories.rb
+++ b/vendor/plugins/rspec/stories/example_groups/stories.rb
@@ -1,7 +1,8 @@
require File.join(File.dirname(__FILE__), *%w[.. helper])
with_steps_for :running_rspec do
- Dir["#{File.dirname(__FILE__)}/*"].each do |file|
- run file if File.file?(file) && !(file =~ /\.rb$/)
- end
+ run File.dirname(__FILE__) + "/nested_groups"
+ # Dir["#{File.dirname(__FILE__)}/*"].each do |file|
+ # run file if File.file?(file) && !(file =~ /\.rb$/)
+ # end
end \ No newline at end of file
diff --git a/vendor/plugins/rspec/stories/interop/test_case_with_should_methods b/vendor/plugins/rspec/stories/interop/test_case_with_should_methods
index 31f28d32e..d618c50e2 100644
--- a/vendor/plugins/rspec/stories/interop/test_case_with_should_methods
+++ b/vendor/plugins/rspec/stories/interop/test_case_with_should_methods
@@ -7,7 +7,7 @@ Story: Test::Unit::TestCase extended by rspec with should methods
Scenario: Run with ruby
Given the file test/test_case_with_should_methods.rb
When I run it with the ruby interpreter
- Then PENDING the exit code should be 256
+ Then the exit code should be 256
And the stdout should match "5 examples, 3 failures"
Scenario: Run with spec
diff --git a/vendor/plugins/rspec/stories/mock_framework_integration/stories.rb b/vendor/plugins/rspec/stories/mock_framework_integration/stories.rb
new file mode 100644
index 000000000..e45882a93
--- /dev/null
+++ b/vendor/plugins/rspec/stories/mock_framework_integration/stories.rb
@@ -0,0 +1,7 @@
+require File.join(File.dirname(__FILE__), *%w[.. helper])
+
+with_steps_for :running_rspec do
+ Dir["#{File.dirname(__FILE__)}/*"].each do |file|
+ run file if File.file?(file) && !(file =~ /\.rb$/)
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec/stories/mock_framework_integration/use_flexmock.story b/vendor/plugins/rspec/stories/mock_framework_integration/use_flexmock.story
new file mode 100644
index 000000000..083531067
--- /dev/null
+++ b/vendor/plugins/rspec/stories/mock_framework_integration/use_flexmock.story
@@ -0,0 +1,9 @@
+Story: Getting correct output
+
+ As an RSpec user who prefers flexmock
+ I want to be able to use flexmock without rspec mocks interfering
+
+ Scenario: Mock with flexmock
+ Given the file spec/spec_with_flexmock.rb
+ When I run it with the ruby interpreter
+ Then the exit code should be 0 \ No newline at end of file
diff --git a/vendor/plugins/rspec/stories/resources/spec/spec_with_flexmock.rb b/vendor/plugins/rspec/stories/resources/spec/spec_with_flexmock.rb
new file mode 100644
index 000000000..629bef212
--- /dev/null
+++ b/vendor/plugins/rspec/stories/resources/spec/spec_with_flexmock.rb
@@ -0,0 +1,18 @@
+$:.push File.join(File.dirname(__FILE__), *%w[.. .. .. lib])
+require "rubygems"
+require 'spec'
+
+Spec::Runner.configure do |config|
+ config.mock_with :flexmock
+end
+
+# This is to ensure that requiring spec/mocks/framework doesn't interfere w/ flexmock
+require 'spec/mocks/framework'
+
+describe "something" do
+ it "should receive some message" do
+ target = Object.new
+ flexmock(target).should_receive(:foo).once
+ lambda {flexmock_verify}.should raise_error
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/.gitignore b/vendor/plugins/rspec_on_rails/.gitignore
new file mode 100644
index 000000000..8c6c23dc2
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/.gitignore
@@ -0,0 +1,4 @@
+tmtags
+.DS_Store
+.emacs-project
+*~
diff --git a/vendor/plugins/rspec_on_rails/CHANGES b/vendor/plugins/rspec_on_rails/CHANGES
new file mode 100644
index 000000000..9a54a1c81
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/CHANGES
@@ -0,0 +1,21 @@
+== Version 1.1.4
+
+Maintenance release.
+
+* Moved mock_model and stub_model to their own module: Spec::Rails::Mocks
+* Setting mock_model object id with stubs hash - patch from Adam Meehan
+* Added as_new_record to stub_model e.g. stub_model(Foo).as_new_record
+* Improved stub_model such that new_record? does "the right thing"
+* Patch from Pat Maddox to get integrate_views to work in nested example groups.
+* Patch from Pat Maddox to get controller_name to work in nested example groups.
+* Patch from Corey Haines to add include_text matcher
+* Added stub_model method which creates a real model instance with :id stubbed and data access prohibited.
+* Applied patch from Pat Maddox to handle redirect_to w/ SSL. Closes #320.
+* Added #helper and #assigns to helper specs.
+* Applied patch from Bryan Helmkamp to tweak format of generated spec.opts to be more obvious. Closes #162.
+* Tweaked list of exceptions (ignores) for autotest
+* Applied patch from Rick Olson to get rspec_on_rails working with rails edge (>= 8862)
+* Applied patch from Wincent Colaiuta to invert sense of "spec --diff". Closes #281.
+* Allow any type of render in view specs. Closes #57.
+* Applied patch from Ian White to get rspec working with edge rails (8804). Closes #271.
+* Applied patch from Jon Strother to have spec_server reload fixtures. Closes #344. \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server b/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server
index 3787a39d9..1e839355f 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server
+++ b/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server
@@ -1,5 +1,4 @@
#!/usr/bin/env ruby
-$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
require 'rubygems'
require 'drb/drb'
@@ -23,20 +22,29 @@ module Spec
active_connections.delete(name)
end
end
- end
+ end
if ActionController.const_defined?(:Dispatcher)
dispatcher = ::ActionController::Dispatcher.new($stdout)
- dispatcher.cleanup_application(true)
+ dispatcher.cleanup_application
elsif ::Dispatcher.respond_to?(:reset_application!)
::Dispatcher.reset_application!
else
raise "Application reloading failed"
end
+ if Object.const_defined?(:Fixtures) && Fixtures.respond_to?(:reset_cache)
+ Fixtures.reset_cache
+ end
+
::Dependencies.mechanism = :load
require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
load File.dirname(__FILE__) + '/../spec/spec_helper.rb'
+ if in_memory_database?
+ load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default
+ ActiveRecord::Migrator.up('db/migrate') # use migrations
+ end
+
::Spec::Runner::CommandLine.run(
::Spec::Runner::OptionParser.parse(
argv,
@@ -45,6 +53,12 @@ module Spec
)
)
end
+
+ def in_memory_database?
+ ENV["RAILS_ENV"] == "test" and
+ ::ActiveRecord::Base.connection.class.to_s == "ActiveRecord::ConnectionAdapters::SQLite3Adapter" and
+ ::Rails::Configuration.new.database_configuration['test']['database'] == ':memory:'
+ end
end
end
end
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts b/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts
index 2144705ed..391705bf8 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts
+++ b/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts
@@ -1,7 +1,4 @@
--colour
---format
-progress
---loadby
-mtime
+--format progress
+--loadby mtime
--reverse
---backtrace \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb b/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb
index 210d9d196..938dd7b49 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb
@@ -28,6 +28,10 @@ Spec::Runner.configure do |config|
# If you declare global fixtures, be aware that they will be declared
# for all of your examples, even those that don't use them.
#
+ # You can also declare which fixtures to use (for example fixtures for test/fixtures):
+ #
+ # config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
+ #
# == Mock Framework
#
# RSpec uses it's own mocking framework by default. If you prefer to
@@ -36,4 +40,8 @@ Spec::Runner.configure do |config|
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
+ #
+ # == Notes
+ #
+ # For more information take a look at Spec::Example::Configuration and Spec::Runner
end
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb b/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb
index d21c2156a..933483054 100755
--- a/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb
@@ -1,5 +1,4 @@
require 'rails_generator/generators/components/controller/controller_generator'
-require File.join(File.dirname(__FILE__), *%w[.. helpers rails_identifier])
class RspecControllerGenerator < ControllerGenerator
@@ -16,7 +15,7 @@ class RspecControllerGenerator < ControllerGenerator
m.directory File.join('spec/helpers', class_path)
m.directory File.join('spec/views', class_path, file_name)
- if RailsIdentifier.using_legacy_templates?
+ if Rails::VERSION::STRING < "2.0.0"
@default_file_extension = "rhtml"
else
@default_file_extension = "html.erb"
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb
index e79549e2c..cb25fe777 100755
--- a/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
describe <%= class_name %>Controller do
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb
index e9dabcde9..11c650480 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb
@@ -1,11 +1,11 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
describe <%= class_name %>Helper do
#Delete this example and add some real ones or delete this file
- it "should include the <%= class_name %>Helper" do
- included_modules = self.metaclass.send :included_modules
+ it "should be included in the object returned by #helper" do
+ included_modules = (class << helper; self; end).send :included_modules
included_modules.should include(<%= class_name %>Helper)
end
-
+
end
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb
index 4d9e7dcf1..d550d6a1b 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
describe "/<%= class_name.underscore %>/<%= action %>" do
before(:each) do
@@ -7,6 +7,6 @@ describe "/<%= class_name.underscore %>/<%= action %>" do
#Delete this example and add some real ones or delete this file
it "should tell you where to find the file" do
- response.should have_tag('p', /Find me in app\/views\/<%= class_name.underscore %>\/<%= action %>/)
+ response.should have_tag('p', %r[Find me in app/views/<%= class_name.underscore %>/<%= action %>])
end
end
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb
index 83aa88bea..648908b4c 100755
--- a/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
describe <%= class_name %> do
before(:each) do
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb
index 19d09cb13..0dab8250b 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb
@@ -1,5 +1,3 @@
-require File.join(File.dirname(__FILE__), *%w[.. helpers rails_identifier])
-
class RspecScaffoldGenerator < Rails::Generator::NamedBase
default_options :skip_migration => false
@@ -30,7 +28,7 @@ class RspecScaffoldGenerator < Rails::Generator::NamedBase
@controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
end
- if RailsIdentifier.using_legacy_templates?
+ if Rails::VERSION::STRING < "2.0.0"
@resource_generator = "scaffold_resource"
@default_file_extension = "rhtml"
else
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb
index 748190743..ae7b1a701 100755
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
describe <%= controller_class_name %>Controller do
describe "handling GET /<%= table_name %>" do
@@ -36,8 +36,8 @@ describe <%= controller_class_name %>Controller do
describe "handling GET /<%= table_name %>.xml" do
before(:each) do
- @<%= file_name %> = mock_model(<%= class_name %>, :to_xml => "XML")
- <%= class_name %>.stub!(:find).and_return(@<%= file_name %>)
+ @<%= file_name.pluralize %> = mock("Array of <%= class_name.pluralize %>", :to_xml => "XML")
+ <%= class_name %>.stub!(:find).and_return(@<%= file_name.pluralize %>)
end
def do_get
@@ -51,12 +51,12 @@ describe <%= controller_class_name %>Controller do
end
it "should find all <%= table_name %>" do
- <%= class_name %>.should_receive(:find).with(:all).and_return([@<%= file_name %>])
+ <%= class_name %>.should_receive(:find).with(:all).and_return(@<%= file_name.pluralize %>)
do_get
end
it "should render the found <%= table_name %> as xml" do
- @<%= file_name %>.should_receive(:to_xml).and_return("XML")
+ @<%= file_name.pluralize %>.should_receive(:to_xml).and_return("XML")
do_get
response.body.should == "XML"
end
@@ -310,4 +310,4 @@ describe <%= controller_class_name %>Controller do
response.should redirect_to(<%= table_name %>_url)
end
end
-end \ No newline at end of file
+end
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb
index 931abf890..86e23a27e 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
describe "/<%= table_name %>/edit.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb
index 85cf795dc..900b027aa 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb
@@ -1,10 +1,10 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
describe <%= controller_class_name %>Helper do
#Delete this example and add some real ones or delete this file
- it "should include the <%= class_name %>Helper" do
- included_modules = self.metaclass.send :included_modules
+ it "should be included in the object returned by #helper" do
+ included_modules = (class << helper; self; end).send :included_modules
included_modules.should include(<%= controller_class_name %>Helper)
end
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb
index 9d61c6f4c..660c284f5 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
describe "/<%= table_name %>/index.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb
index 2ae085ad7..f0442e9b1 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
describe "/<%= table_name %>/new.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb
index a6da04901..ca53a7caa 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
describe <%= controller_class_name %>Controller do
describe "route generation" do
@@ -58,4 +58,4 @@ describe <%= controller_class_name %>Controller do
params_from(:delete, "/<%= table_name %>/1").should == {:controller => "<%= table_name %>", :action => "destroy", :id => "1"}
end
end
-end \ No newline at end of file
+end
diff --git a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb
index 53de98323..36dae5490 100644
--- a/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb
+++ b/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
+require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
describe "/<%= table_name %>/show.<%= default_file_extension %>" do
include <%= controller_class_name %>Helper
diff --git a/vendor/plugins/rspec_on_rails/lib/autotest/discover.rb b/vendor/plugins/rspec_on_rails/lib/autotest/discover.rb
new file mode 100644
index 000000000..8e6968e20
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/lib/autotest/discover.rb
@@ -0,0 +1 @@
+# This needs to be here for >= ZenTest-3.9.0 to add this directory to the load path. \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb b/vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb
index 1fe20fbc9..c6fe446b1 100644
--- a/vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb
+++ b/vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb
@@ -26,7 +26,7 @@ require 'active_support'
require 'autotest/rspec'
Autotest.add_hook :initialize do |at|
- %w{config coverage db doc log public script vendor/rails vendor/plugins previous_failures.txt}.each do |exception|
+ %w{config/ coverage/ db/ doc/ log/ public/ script/ tmp/ vendor/rails vendor/plugins previous_failures.txt}.each do |exception|
at.add_exception(exception)
end
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails.rb
index be8a6c415..74fc3929b 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails.rb
@@ -8,10 +8,11 @@ require 'test/unit'
require 'spec'
-require 'spec/rails/extensions'
+require 'spec/rails/matchers'
+require 'spec/rails/mocks'
require 'spec/rails/example'
+require 'spec/rails/extensions'
require 'spec/rails/version'
-require 'spec/rails/matchers'
module Spec
# = Spec::Rails
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example.rb
index 64a72a9db..f104f51e5 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example.rb
@@ -1,6 +1,5 @@
dir = File.dirname(__FILE__)
-require 'spec/rails/example/ivar_proxy'
require 'spec/rails/example/assigns_hash_proxy'
require "spec/rails/example/render_observer"
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb
index 1d121f70a..c8a7d0662 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb
@@ -17,6 +17,7 @@ module Spec
end
def []=(ivar, val)
+ @object.instance_variable_set "@#{ivar}", val
assigns[ivar.to_s] = val
end
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb
index eca06a403..a686b6a39 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb
@@ -72,12 +72,19 @@ module Spec
#
# See Spec::Rails::Example::ControllerExampleGroup for more information about
# Integration and Isolation modes.
- def integrate_views
- @integrate_views = true
+ def integrate_views(integrate_views = true)
+ @integrate_views = integrate_views
end
+
def integrate_views? # :nodoc:
@integrate_views
end
+
+ def inherited(klass) # :nodoc:
+ klass.controller_class_name = controller_class_name
+ klass.integrate_views(integrate_views?)
+ super
+ end
# You MUST provide a controller_name within the context of
# your controller specs:
@@ -106,7 +113,7 @@ module Spec
end
EOE
end
- @controller.metaclass.class_eval do
+ (class << @controller; self; end).class_eval do
def controller_path #:nodoc:
self.class.name.underscore.gsub('_controller', '')
end
@@ -150,8 +157,8 @@ module Spec
end
protected
- def _controller_ivar_proxy
- @controller_ivar_proxy ||= AssignsHashProxy.new @controller
+ def _assigns_hash_proxy
+ @_assigns_hash_proxy ||= AssignsHashProxy.new @controller
end
private
@@ -162,18 +169,32 @@ module Spec
module ControllerInstanceMethods #:nodoc:
include Spec::Rails::Example::RenderObserver
- # === render(options = nil, deprecated_status = nil, &block)
+ # === render(options = nil, deprecated_status_or_extra_options = nil, &block)
#
# This gets added to the controller's singleton meta class,
# allowing Controller Examples to run in two modes, freely switching
# from context to context.
- def render(options=nil, deprecated_status=nil, &block)
+ def render(options=nil, deprecated_status_or_extra_options=nil, &block)
+ if ::Rails::VERSION::STRING >= '2.0.0' && deprecated_status_or_extra_options.nil?
+ deprecated_status_or_extra_options = {}
+ end
+
unless block_given?
unless integrate_views?
- @template.metaclass.class_eval do
- define_method :file_exists? do
- true
+ if @template.respond_to?(:finder)
+ (class << @template.finder; self; end).class_eval do
+ define_method :file_exists? do
+ true
+ end
+ end
+ else
+ (class << @template; self; end).class_eval do
+ define_method :file_exists? do
+ true
+ end
end
+ end
+ (class << @template; self; end).class_eval do
define_method :render_file do |*args|
@first_render ||= args[0]
end
@@ -181,43 +202,39 @@ module Spec
end
end
- if expect_render_mock_proxy.send(:__mock_proxy).send(:find_matching_expectation, :render, options)
- expect_render_mock_proxy.render(options)
+ if matching_message_expectation_exists(options)
+ expect_render_mock_proxy.render(options, &block)
@performed_render = true
else
- unless expect_render_mock_proxy.send(:__mock_proxy).send(:find_matching_method_stub, :render, options)
- super(options, deprecated_status, &block)
+ unless matching_stub_exists(options)
+ super(options, deprecated_status_or_extra_options, &block)
end
end
end
+
+ def raise_with_disable_message(old_method, new_method)
+ raise %Q|
+ controller.#{old_method}(:render) has been disabled because it
+ can often produce unexpected results. Instead, you should
+ use the following (before the action):
- if self.respond_to?(:should_receive) && self.respond_to?(:stub!)
- self.send :alias_method, :orig_should_receive, :should_receive
- self.send :alias_method, :orig_stub!, :stub!
- def raise_with_disable_message(old_method, new_method)
- raise %Q|
- controller.#{old_method}(:render) has been disabled because it
- can often produce unexpected results. Instead, you should
- use the following (before the action):
-
- controller.#{new_method}(*args)
+ controller.#{new_method}(*args)
- See the rdoc for #{new_method} for more information.
- |
- end
- def should_receive(*args)
- if args[0] == :render
- raise_with_disable_message("should_receive", "expect_render")
- else
- orig_should_receive(*args)
- end
+ See the rdoc for #{new_method} for more information.
+ |
+ end
+ def should_receive(*args)
+ if args[0] == :render
+ raise_with_disable_message("should_receive", "expect_render")
+ else
+ super
end
- def stub!(*args)
- if args[0] == :render
- raise_with_disable_message("stub!", "stub_render")
- else
- orig_stub!(*args)
- end
+ end
+ def stub!(*args)
+ if args[0] == :render
+ raise_with_disable_message("stub!", "stub_render")
+ else
+ super
end
end
@@ -236,6 +253,15 @@ module Spec
def integrate_views?
@integrate_views
end
+
+ def matching_message_expectation_exists(options)
+ expect_render_mock_proxy.send(:__mock_proxy).send(:find_matching_expectation, :render, options)
+ end
+
+ def matching_stub_exists(options)
+ expect_render_mock_proxy.send(:__mock_proxy).send(:find_matching_method_stub, :render, options)
+ end
+
end
Spec::Example::ExampleGroupFactory.register(:controller, self)
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb
index 6f5790cbf..6bdb1823a 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb
@@ -11,9 +11,9 @@ module Spec
raise "Can't determine controller class for #{@controller_class_name}" if @controller_class.nil?
@controller = @controller_class.new
-
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
+ @response.session = @request.session
end
def params
@@ -25,14 +25,14 @@ module Spec
end
def session
- request.session
+ @response.session
end
# :call-seq:
# assigns()
#
- # Hash of instance variables to values that are made available to views.
- # == Examples
+ # Hash of instance variables to values that are made available to
+ # views. == Examples
#
# #in thing_controller.rb
# def new
@@ -43,23 +43,16 @@ module Spec
# get 'new'
# assigns[:registration].should == Thing.new
#--
- # NOTE - Even though docs say only use assigns[:key] format, but allowing assigns(:key)
- # in order to avoid breaking old specs.
+ # NOTE - Even though docs only use assigns[:key] format, this supports
+ # assigns(:key) in order to avoid breaking old specs.
#++
def assigns(key = nil)
if key.nil?
- @controller.assigns
- _controller_ivar_proxy
+ _assigns_hash_proxy
else
- @controller.assigns[key]
- _controller_ivar_proxy[key]
+ _assigns_hash_proxy[key]
end
end
-
- protected
- def _controller_ivar_proxy
- @controller_ivar_proxy ||= IvarProxy.new @controller
- end
end
end
end
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb
index 10c1ab002..7e60728ef 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb
@@ -26,15 +26,56 @@ module Spec
# end
# end
class HelperExampleGroup < FunctionalExampleGroup
+ class HelperObject < ActionView::Base
+ def protect_against_forgery?
+ false
+ end
+ end
+
class << self
# The helper name....
def helper_name(name=nil)
- send :include, "#{name}_helper".camelize.constantize
+ @helper_being_described = "#{name}_helper".camelize.constantize
+ send :include, @helper_being_described
+ end
+
+ def helper
+ @helper_object ||= returning HelperObject.new do |helper_object|
+ if @helper_being_described.nil?
+ if described_type.class == Module
+ helper_object.extend described_type
+ end
+ else
+ helper_object.extend @helper_being_described
+ end
+ end
end
end
+
+ # Returns an instance of ActionView::Base with the helper being spec'd
+ # included.
+ #
+ # == Example
+ #
+ # describe PersonHelper do
+ # it "should write a link to person with the name" do
+ # assigns[:person] = mock_model(Person, :full_name => "Full Name", :id => 37, :new_record? => false)
+ # helper.link_to_person.should == %{<a href="/people/37">Full Name</a>}
+ # end
+ # end
+ #
+ # module PersonHelper
+ # def link_to_person
+ # link_to person.full_name, url_for(person)
+ # end
+ # end
+ #
+ def helper
+ self.class.helper
+ end
- # Reverse the load order so that custom helpers which
- # are defined last are also loaded last.
+ # Reverse the load order so that custom helpers which are defined last
+ # are also loaded last.
ActionView::Base.included_modules.reverse.each do |mod|
include mod if mod.parents.include?(ActionView::Helpers)
end
@@ -58,10 +99,11 @@ module Spec
end
def eval_erb(text)
- ERB.new(text).result(binding)
+ helper.instance_eval do
+ ERB.new(text).result(binding)
+ end
end
-
# TODO: BT - Helper Examples should proxy method_missing to a Rails View instance.
# When that is done, remove this method
def protect_against_forgery?
@@ -69,6 +111,12 @@ module Spec
end
Spec::Example::ExampleGroupFactory.register(:helper, self)
+
+ protected
+ def _assigns_hash_proxy
+ @_assigns_hash_proxy ||= AssignsHashProxy.new helper
+ end
+
end
class HelperBehaviourController < ApplicationController #:nodoc:
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/rails_example_group.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/rails_example_group.rb
index a3df05ab5..444740d75 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/rails_example_group.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/rails_example_group.rb
@@ -4,8 +4,10 @@ ActionView::Base.cache_template_extensions = false
module Spec
module Rails
+
module Example
class RailsExampleGroup < Test::Unit::TestCase
+
# Rails >= r8570 uses setup/teardown_fixtures explicitly
before(:each) do
setup_fixtures if self.respond_to?(:setup_fixtures)
@@ -15,53 +17,10 @@ module Spec
end
include Spec::Rails::Matchers
-
- @@model_id = 1000
- # Creates a mock object instance for a +model_class+ with common
- # methods stubbed out.
- # Additional methods may be easily stubbed (via add_stubs) if +stubs+ is passed.
- def mock_model(model_class, options_and_stubs = {})
- # null = options_and_stubs.delete(:null_object)
- # stubs = options_and_stubs
- id = @@model_id
- @@model_id += 1
- options_and_stubs = {
- :id => id,
- :to_param => id.to_s,
- :new_record? => false,
- :errors => stub("errors", :count => 0)
- }.merge(options_and_stubs)
- m = mock("#{model_class.name}_#{id}", options_and_stubs)
- m.send(:__mock_proxy).instance_eval <<-CODE
- def @target.is_a?(other)
- #{model_class}.ancestors.include?(other)
- end
- def @target.kind_of?(other)
- #{model_class}.ancestors.include?(other)
- end
- def @target.instance_of?(other)
- other == #{model_class}
- end
- def @target.class
- #{model_class}
- end
- CODE
- yield m if block_given?
- m
- end
-
- #--
- # TODO - Shouldn't this just be an extension of stub! ??
- # - object.stub!(:method => return_value, :method2 => return_value2, :etc => etc)
- #++
- # Stubs methods on +object+ (if +object+ is a symbol or string a new mock
- # with that name will be created). +stubs+ is a Hash of <tt>method=>value</tt>
- def add_stubs(object, stubs = {}) #:nodoc:
- m = [String, Symbol].index(object.class) ? mock(object.to_s) : object
- stubs.each {|k,v| m.stub!(k).and_return(v)}
- m
- end
+ include Spec::Rails::Mocks
+
Spec::Example::ExampleGroupFactory.default(self)
+
end
end
end
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/render_observer.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/render_observer.rb
index 285e8b657..31086e227 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/render_observer.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/render_observer.rb
@@ -1,4 +1,4 @@
-require 'spec/mocks'
+require 'spec/mocks/framework'
module Spec
module Rails
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb
index d7b567448..e77d2fbd8 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb
@@ -28,6 +28,10 @@ module Spec
ensure_that_flash_and_session_work_properly
end
+ after(:each) do
+ ensure_that_base_view_path_is_not_set_across_example_groups
+ end
+
def initialize(defined_description, &implementation) #:nodoc:
super
@controller_class_name = "Spec::Rails::Example::ViewExampleGroupController"
@@ -40,11 +44,6 @@ module Spec
@controller.class.send :public, :flash
end
- def teardown #:nodoc:
- super
- ensure_that_base_view_path_is_not_set_across_example_groups
- end
-
def ensure_that_base_view_path_is_not_set_across_example_groups #:nodoc:
ActionView::Base.base_view_path = nil
end
@@ -73,7 +72,7 @@ module Spec
return options[render_type]
end
end
- raise Exception.new("Unhandled render type in view spec.")
+ return ""
end
def add_helpers(options) #:nodoc:
@@ -84,7 +83,8 @@ module Spec
end
# Renders a template for a View Spec, which then provides access to the result
- # through the +response+.
+ # through the +response+. Also supports render with :inline, which you can
+ # use to spec custom form builders, helpers, etc, in the context of a view.
#
# == Examples
#
@@ -92,6 +92,7 @@ module Spec
# render('/people/list', :helper => MyHelper)
# render('/people/list', :helpers => [MyHelper, MyOtherHelper])
# render(:partial => '/people/_address')
+ # render(:inline => "<% custom_helper 'argument', 'another argument' %>")
#
# See Spec::Rails::Example::ViewExampleGroup for more information.
def render(*args)
@@ -111,7 +112,7 @@ module Spec
defaults = { :layout => false }
options = defaults.merge options
- @controller.instance_variable_set :@params, @request.parameters
+ @controller.send(:params).reverse_merge! @request.parameters
@controller.send :initialize_current_url
@@ -146,6 +147,11 @@ module Spec
end
Spec::Example::ExampleGroupFactory.register(:view, self)
+
+ protected
+ def _assigns_hash_proxy
+ @_assigns_hash_proxy ||= AssignsHashProxy.new @controller
+ end
end
class ViewExampleGroupController < ApplicationController #:nodoc:
@@ -162,7 +168,7 @@ module Spec
rescue
return
end
- template.metaclass.class_eval do
+ (class << template; self; end).class_eval do
include helper_module
end
end
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/configuration.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/configuration.rb
index 06e322637..22d40a08b 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/configuration.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/configuration.rb
@@ -1,5 +1,5 @@
require 'spec/example/configuration'
-
+begin
module Spec
module Example
class Configuration
@@ -64,3 +64,8 @@ module Spec
end
end
end
+rescue Exception => e
+ puts e.message
+ puts e.backtrace
+ raise e
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers.rb
index 27ac2ba0f..6c18b2a99 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers.rb
@@ -1,6 +1,7 @@
dir = File.dirname(__FILE__)
require 'spec/rails/matchers/assert_select'
require 'spec/rails/matchers/have_text'
+require 'spec/rails/matchers/include_text'
require 'spec/rails/matchers/redirect_to'
require 'spec/rails/matchers/render_template'
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb
index 12c71ead8..e03029c7f 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb
@@ -39,9 +39,11 @@ module Spec
# Accepts a String or a Regexp, matching a String using ==
# and a Regexp using =~.
#
+ # If response_or_text has a #body, then that is used as to match against
+ # else it uses response_or_text
+ #
# Use this instead of <tt>response.should have_tag()</tt>
- # when you either don't know or don't care where on the page
- # this text appears.
+ # when you want to match the whole string or whole body
#
# == Examples
#
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/include_text.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/include_text.rb
new file mode 100644
index 000000000..4be25bce6
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/include_text.rb
@@ -0,0 +1,54 @@
+module Spec
+ module Rails
+ module Matchers
+
+ class IncludeText #:nodoc:
+
+ def initialize(expected)
+ @expected = expected
+ end
+
+ def matches?(response_or_text)
+ @actual = response_or_text.respond_to?(:body) ? response_or_text.body : response_or_text
+ return actual.include?(expected)
+ end
+
+ def failure_message
+ "expected to find #{expected.inspect} in #{actual.inspect}"
+ end
+
+ def negative_failure_message
+ "expected not to include text #{expected.inspect}"
+ end
+
+ def to_s
+ "include text #{expected.inspect}"
+ end
+
+ private
+ attr_reader :expected
+ attr_reader :actual
+
+ end
+
+
+ # :call-seq:
+ # response.should include_text(expected)
+ # response.should_not include_text(expected)
+ #
+ # Accepts a String, matching using include?
+ #
+ # Use this instead of <tt>response.should have_text()</tt>
+ # when you either don't know or don't care where on the page
+ # this text appears.
+ #
+ # == Examples
+ #
+ # response.should include_text("This text will be in the actual string")
+ def include_text(text)
+ IncludeText.new(text)
+ end
+
+ end
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb
index 7c61c81e7..12ce92516 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb
@@ -39,7 +39,7 @@ module Spec
end
def path_hash(url)
- path = url.sub(%r{^\w+://#{@request.host}}, "").split("?", 2)[0]
+ path = url.sub(%r{^\w+://#{@request.host}(?::\d+)?}, "").split("?", 2)[0]
ActionController::Routing::Routes.recognize_path path
end
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb
index 8c3df3ad2..e36c8bce0 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb
@@ -18,6 +18,10 @@ module Spec
"expected #{@expected.inspect}, got #{@actual.inspect}"
end
+ def negative_failure_message
+ "expected not to render #{@expected.inspect}, but did"
+ end
+
def description
"render template #{@expected.inspect}"
end
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/mocks.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/mocks.rb
new file mode 100644
index 000000000..34e1d18f4
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/mocks.rb
@@ -0,0 +1,115 @@
+module Spec
+ module Rails
+
+ class IllegalDataAccessException < StandardError; end
+
+ module Mocks
+
+ # Creates a mock object instance for a +model_class+ with common
+ # methods stubbed out. Additional methods may be easily stubbed (via
+ # add_stubs) if +stubs+ is passed.
+ def mock_model(model_class, options_and_stubs = {})
+ id = next_id
+ options_and_stubs.reverse_merge!({
+ :id => id,
+ :to_param => id.to_s,
+ :new_record? => false,
+ :errors => stub("errors", :count => 0)
+ })
+ m = mock("#{model_class.name}_#{options_and_stubs[:id]}", options_and_stubs)
+ m.send(:__mock_proxy).instance_eval <<-CODE
+ def @target.is_a?(other)
+ #{model_class}.ancestors.include?(other)
+ end
+ def @target.kind_of?(other)
+ #{model_class}.ancestors.include?(other)
+ end
+ def @target.instance_of?(other)
+ other == #{model_class}
+ end
+ def @target.class
+ #{model_class}
+ end
+ CODE
+ yield m if block_given?
+ m
+ end
+
+ # :call-seq:
+ # stub_model(Model)
+ # stub_model(Model).as_new_record
+ # stub_model(Model, hash_of_stubs)
+ #
+ # Creates an instance of +Model+ that is prohibited from accessing the
+ # database. For each key in +hash_of_stubs+, if the model has a
+ # matching attribute (determined by asking it, which it answers based
+ # on schema.rb) are simply assigned the submitted values. If the model
+ # does not have a matching attribute, the key/value pair is assigned
+ # as a stub return value using RSpec's mocking/stubbing framework.
+ #
+ # new_record? is overridden to return the result of id.nil? This means
+ # that by default new_record? will return false. If you want the
+ # object to behave as a new record, sending it +as_new_record+ will
+ # set the id to nil. You can also explicitly set :id => nil, in which
+ # case new_record? will return true, but using +as_new_record+ makes
+ # the example a bit more descriptive.
+ #
+ # While you can use stub_model in any example (model, view,
+ # controller, helper), it is especially useful in view examples,
+ # which are inherently more state-based than interaction-based.
+ #
+ # == Examples
+ #
+ # stub_model(Person)
+ # stub_model(Person).as_new_record
+ # stub_model(Person, :id => 37)
+ # stub_model(Person) do |person|
+ # model.first_name = "David"
+ # end
+ def stub_model(model_class, stubs = {})
+ stubs = {:id => next_id}.merge(stubs)
+ returning model_class.new do |model|
+ model.id = stubs.delete(:id)
+ (class << model; self; end).class_eval do
+ def connection
+ raise Spec::Rails::IllegalDataAccessException.new("stubbed models are not allowed to access the database")
+ end
+ def new_record?
+ id.nil?
+ end
+ def as_new_record
+ self.id = nil
+ self
+ end
+ end
+ stubs.each do |k,v|
+ if model.has_attribute?(k)
+ model[k] = stubs.delete(k)
+ end
+ end
+ add_stubs(model, stubs)
+ yield model if block_given?
+ end
+ end
+
+ #--
+ # TODO - Shouldn't this just be an extension of stub! ??
+ # - object.stub!(:method => return_value, :method2 => return_value2, :etc => etc)
+ #++
+ # Stubs methods on +object+ (if +object+ is a symbol or string a new mock
+ # with that name will be created). +stubs+ is a Hash of <tt>method=>value</tt>
+ def add_stubs(object, stubs = {}) #:nodoc:
+ m = [String, Symbol].index(object.class) ? mock(object.to_s) : object
+ stubs.each {|k,v| m.stub!(k).and_return(v)}
+ m
+ end
+
+ private
+ @@model_id = 1000
+ def next_id
+ @@model_id += 1
+ end
+
+ end
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb b/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb
index 47043a07e..68591125e 100644
--- a/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb
+++ b/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb
@@ -1,23 +1,23 @@
-module Spec
- module Rails
- module VERSION #:nodoc:
- BUILD_TIME_UTC = 20080114022430
- end
- end
-end
-
-# Verify that the plugin has the same revision as RSpec
-if Spec::Rails::VERSION::BUILD_TIME_UTC != Spec::VERSION::BUILD_TIME_UTC
- raise <<-EOF
-
-############################################################################
-Your RSpec on Rails plugin is incompatible with your installed RSpec.
-
-RSpec : #{Spec::VERSION::BUILD_TIME_UTC}
-RSpec on Rails : #{Spec::Rails::VERSION::BUILD_TIME_UTC}
-
-Make sure your RSpec on Rails plugin is compatible with your RSpec gem.
-See http://rspec.rubyforge.org/documentation/rails/install.html for details.
-############################################################################
-EOF
-end
+module Spec
+ module Rails
+ module VERSION #:nodoc:
+ BUILD_TIME_UTC = 20080526202855
+ end
+ end
+end
+
+# Verify that the plugin has the same revision as RSpec
+if Spec::Rails::VERSION::BUILD_TIME_UTC != Spec::VERSION::BUILD_TIME_UTC
+ raise <<-EOF
+
+############################################################################
+Your RSpec on Rails plugin is incompatible with your installed RSpec.
+
+RSpec : #{Spec::VERSION::BUILD_TIME_UTC}
+RSpec on Rails : #{Spec::Rails::VERSION::BUILD_TIME_UTC}
+
+Make sure your RSpec on Rails plugin is compatible with your RSpec gem.
+See http://rspec.rubyforge.org/documentation/rails/install.html for details.
+############################################################################
+EOF
+end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb
index 7a2658d2c..3ebf8909a 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb
@@ -1,41 +1,36 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "autotest", "rails_rspec")
+require File.join(File.dirname(__FILE__), *%w[.. .. .. lib autotest rails_rspec])
+require File.join(File.dirname(__FILE__), *%w[.. .. .. .. rspec spec autotest_matchers])
describe Autotest::RailsRspec, "file mapping" do
before(:each) do
@autotest = Autotest::RailsRspec.new
@autotest.hook :initialize
- @autotest.output = StringIO.new
- @autotest.files.clear
- @autotest.last_mtime = Time.at(0)
- end
-
- def ensure_mapping(examples, impl)
- @autotest.files[@impl] = Time.at(0)
- examples.each do |example|
- @autotest.files[example] = Time.at(0)
- end
- @autotest.tests_for_file(impl).should == examples
end
it "should map model example to model" do
- ensure_mapping(['spec/models/thing_spec.rb'], 'app/models/thing.rb')
+ @autotest.should map_specs(['spec/models/thing_spec.rb']).
+ to('app/models/thing.rb')
end
it "should map controller example to controller" do
- ensure_mapping(['spec/controllers/things_controller_spec.rb'], 'app/controllers/things_controller.rb')
+ @autotest.should map_specs(['spec/controllers/things_controller_spec.rb']).
+ to('app/controllers/things_controller.rb')
end
it "should map view.rhtml" do
- ensure_mapping(['spec/views/things/index.rhtml_spec.rb'], 'app/views/things/index.rhtml')
+ @autotest.should map_specs(['spec/views/things/index.rhtml_spec.rb']).
+ to('app/views/things/index.rhtml')
end
it "should map view.rhtml with underscores in example filename" do
- ensure_mapping(['spec/views/things/index_rhtml_spec.rb'], 'app/views/things/index.rhtml')
+ @autotest.should map_specs(['spec/views/things/index_rhtml_spec.rb']).
+ to('app/views/things/index.rhtml')
end
it "should map view.html.erb" do
- ensure_mapping(['spec/views/things/index.html.erb_spec.rb'], 'app/views/things/index.html.erb')
+ @autotest.should map_specs(['spec/views/things/index.html.erb_spec.rb']).
+ to('app/views/things/index.html.erb')
end
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
index 400fb829d..eab67f696 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-describe "An AssignsHashProxy" do
+describe "AssignsHashProxy" do
before(:each) do
@object = Object.new
@assigns = Hash.new
@@ -52,4 +52,9 @@ describe "An AssignsHashProxy" do
@proxy.has_key?('foo').should == true
@proxy.has_key?('bar').should == false
end
+
+ it "should sets an instance var" do
+ @proxy['foo'] = 'bar'
+ @object.instance_eval { @foo }.should == 'bar'
+ end
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb
index 204db15d6..9e40047aa 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb
@@ -32,7 +32,8 @@ describe "a controller spec running in integration mode", :type => :controller d
end
it "should choke if the template doesn't exist" do
- lambda { get 'some_action' }.should raise_error(ActionController::MissingTemplate)
+ error = defined?(ActionController::MissingTemplate) ? ActionController::MissingTemplate : ActionView::MissingTemplate
+ lambda { get 'some_action' }.should raise_error(error)
response.should_not be_success
end
@@ -40,4 +41,22 @@ describe "a controller spec running in integration mode", :type => :controller d
lambda { get 'action_with_errors_in_template' }.should raise_error(ActionView::TemplateError)
response.should_not be_success
end
+
+ describe "nested" do
+ it "should render a template" do
+ get 'action_with_template'
+ response.should be_success
+ response.should have_tag('div', 'This is action_with_template.rhtml')
+ end
+
+ describe "with integrate_views turned off" do
+ integrate_views false
+
+ it "should not care if the template doesn't exist" do
+ get 'some_action'
+ response.should be_success
+ response.should render_template("template/that/does/not/actually/exist")
+ end
+ end
+ end
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb
index 3cc861d83..afbb69f7a 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb
@@ -17,6 +17,12 @@ require 'controller_spec_controller'
session.should equal(session_before)
end
+ it "should keep the same data in the session before and after the action" do
+ session[:foo] = :bar
+ get 'action_with_template'
+ session[:foo].should == :bar
+ end
+
it "should ensure controller.session is NOT nil before the action" do
controller.session.should_not be_nil
get 'action_with_template'
@@ -47,13 +53,20 @@ require 'controller_spec_controller'
get 'action_with_partial_with_locals', :thing => "something"
end
+ it "should yield to render :update" do
+ template = stub("template")
+ controller.expect_render(:update).and_yield(template)
+ template.should_receive(:replace).with(:bottom, "replace_me", :partial => "non_existent_partial")
+ get 'action_with_render_update'
+ end
+
it "should allow a path relative to RAILS_ROOT/app/views/ when specifying a partial" do
get 'action_with_partial'
response.should render_template("controller_spec/_partial")
end
it "should provide access to flash" do
- get 'action_with_template'
+ get 'action_which_sets_flash'
flash[:flash_key].should == "flash value"
end
@@ -68,8 +81,10 @@ require 'controller_spec_controller'
end
it "should provide access to session" do
- get 'action_with_template'
- session[:session_key].should == "session value"
+ session[:session_key] = "session value"
+ lambda do
+ get 'action_which_gets_session', :expected => "session value"
+ end.should_not raise_error
end
it "should support custom routes" do
@@ -105,6 +120,7 @@ require 'controller_spec_controller'
end
it "should complain when calling stub!(:render) on the controller" do
+ controller.extend Spec::Mocks::Methods
lambda {
controller.stub!(:render)
}.should raise_error(RuntimeError, /stub!\(:render\) has been disabled/)
@@ -161,6 +177,17 @@ describe ControllerSpecController, :type => :controller do
end
end
+describe "A controller spec with controller_name set", :type => :controller do
+ controller_name :controller_spec
+
+ describe "nested" do
+ it "should inherit the controller name" do
+ get 'action_with_template'
+ response.should be_success
+ end
+ end
+end
+
module Spec
module Rails
module Example
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb
index 50defecc5..0ba2cd255 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb
@@ -2,8 +2,11 @@ require File.dirname(__FILE__) + '/../../spec_helper'
Spec::Runner.configuration.global_fixtures = :people
describe ExplicitHelper, :type => :helper do
+ include ExplicitHelper
+
it "should not require naming the helper if describe is passed a type" do
method_in_explicit_helper.should match(/text from a method/)
+ helper.method_in_explicit_helper.should match(/text from a method/)
end
end
@@ -13,17 +16,22 @@ module Spec
describe HelperExampleGroup, :type => :helper do
helper_name :explicit
- it "should have direct access to methods defined in helpers" do
+ it "DEPRECATED should have direct access to methods defined in helpers" do
method_in_explicit_helper.should =~ /text from a method/
end
+ it "should expose the helper with the #helper method" do
+ helper.method_in_explicit_helper.should =~ /text from a method/
+ end
+
it "should have access to named routes" do
rspec_on_rails_specs_url.should == "http://test.host/rspec_on_rails_specs"
rspec_on_rails_specs_path.should == "/rspec_on_rails_specs"
end
it "should fail if the helper method deson't exist" do
- lambda { non_existant_helper_method }.should raise_error(NameError)
+ lambda { non_existent_helper_method }.should raise_error(NameError)
+ lambda { helper.non_existent_helper_method }.should raise_error(NameError)
end
end
@@ -50,6 +58,13 @@ module Spec
lachie.class.should == Person
end
end
+
+ describe "methods from standard helpers", :type => :helper do
+ helper_name :explicit
+ it "should be exposed to the helper" do
+ helper.link_to("Foo","http://bar").should have_tag("a")
+ end
+ end
describe HelperExampleGroup, "included modules", :type => :helper do
helpers = [
@@ -74,9 +89,10 @@ module Spec
helpers << ActionView::Helpers::PaginationHelper rescue nil #removed for 2.0
helpers << ActionView::Helpers::JavaScriptMacrosHelper rescue nil #removed for 2.0
helpers.each do |helper_module|
- it "should include #{helper_module}" do
- self.class.ancestors.should include(helper_module)
- end
+ # it "should include #{helper_module}" do
+ # self.class.ancestors.should include(helper_module)
+ # helper.class.ancestors.should include(helper_module)
+ # end
end
end
@@ -85,6 +101,7 @@ module Spec
describe HelperExampleGroup, "#protect_against_forgery?", :type => :helper do
it "should return false" do
protect_against_forgery?.should be_false
+ helper.protect_against_forgery?.should be_false
end
end
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb
index 17e47eee8..14159c65a 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb
@@ -208,6 +208,14 @@ describe "A view", :type => :view do
it "should have access to flash data" do
response.should have_tag("div#flash", "flash")
end
+
+ it "should have a controller param" do
+ response.should have_tag("div#controller", "view_spec")
+ end
+
+ it "should have an action param" do
+ response.should have_tag("div#action", "accessor")
+ end
end
describe "A view with a form_tag", :type => :view do
@@ -231,6 +239,13 @@ describe "An instantiated ViewExampleGroupController", :type => :view do
end
end
+describe "render :inline => ...", :type => :view do
+ it "should render ERB right in the spec" do
+ render :inline => %|<%= text_field_tag('field_name', 'Value') %>|
+ response.should have_tag("input[type=?][name=?][value=?]","text","field_name","Value")
+ end
+end
+
module Spec
module Rails
module Example
@@ -243,7 +258,15 @@ module Spec
group.description.to_s.should == "foo"
$nested_group.description.to_s.should == "foo bar"
end
+
+ it "should clear ActionView::Base.base_view_path on teardown" do
+ group = describe("base_view_path_cleared flag", :type => :view) {}
+ example = group.it{}
+
+ ActionView::Base.should_receive(:base_view_path=).with(nil)
+ group.run_after_each(example)
+ end
end
end
end
-end \ No newline at end of file
+end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb
index 9d3e759b2..599249f06 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb
@@ -1,37 +1,48 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require 'spec/mocks/errors'
-describe ActionView::Base, "with RSpec extensions", :type => :view do
- it "should not raise when render has been received" do
- template.expect_render(:partial => "name")
- template.render :partial => "name"
- end
+describe ActionView::Base, "with RSpec extensions:", :type => :view do
- it "should raise when render has NOT been received" do
- template.expect_render(:partial => "name")
- lambda {
- template.verify_rendered
- }.should raise_error
- end
+ describe "expect_render" do
+ it "should not raise when render has been received" do
+ template.expect_render(:partial => "name")
+ template.render :partial => "name"
+ end
- it "should not raise when stubbing and render has been received" do
- template.stub_render(:partial => "name")
- template.render :partial => "name"
+ it "should raise when render has NOT been received" do
+ template.expect_render(:partial => "name")
+ lambda {
+ template.verify_rendered
+ }.should raise_error
+ end
+
+ it "should return something (like a normal mock)" do
+ template.expect_render(:partial => "name").and_return("Little Johnny")
+ result = template.render :partial => "name"
+ result.should == "Little Johnny"
+ end
end
- it "should not raise when stubbing and render has NOT been received" do
- template.stub_render(:partial => "name")
- end
+ describe "stub_render" do
+ it "should not raise when stubbing and render has been received" do
+ template.stub_render(:partial => "name")
+ template.render :partial => "name"
+ end
- it "should not raise when stubbing and render has been received with different options" do
- template.stub_render(:partial => "name")
- template.render :partial => "view_spec/spacer"
- end
+ it "should not raise when stubbing and render has NOT been received" do
+ template.stub_render(:partial => "name")
+ end
+
+ it "should not raise when stubbing and render has been received with different options" do
+ template.stub_render(:partial => "name")
+ template.render :partial => "view_spec/spacer"
+ end
- it "should not raise when stubbing and expecting and render has been received" do
- template.stub_render(:partial => "name")
- template.expect_render(:partial => "name")
- template.render(:partial => "name")
+ it "should not raise when stubbing and expecting and render has been received" do
+ template.stub_render(:partial => "name")
+ template.expect_render(:partial => "name")
+ template.render(:partial => "name")
+ end
end
-
+
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb
new file mode 100644
index 000000000..1ac3fd7c6
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb
@@ -0,0 +1,70 @@
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+
+describe "include_text" do
+
+ describe "where target is a String" do
+ it 'should match submitted text using a string' do
+ string = 'foo'
+ string.should include_text('foo')
+ end
+
+ it 'should match if the text is contained' do
+ string = 'I am a big piece of text'
+ string.should include_text('big piece')
+ end
+
+ it 'should not match if text is not contained' do
+ string = 'I am a big piece of text'
+ string.should_not include_text('corey')
+ end
+ end
+
+end
+
+describe "include_text", :type => :controller do
+ ['isolation','integration'].each do |mode|
+ if mode == 'integration'
+ integrate_views
+ end
+
+ describe "where target is a response (in #{mode} mode)" do
+ controller_name :render_spec
+
+ it "should pass with exactly matching text" do
+ post 'text_action'
+ response.should include_text("this is the text for this action")
+ end
+
+ it 'should pass with substring matching text' do
+ post 'text_action'
+ response.should include_text('text for this')
+ end
+
+ it "should fail with matching text" do
+ post 'text_action'
+ lambda {
+ response.should include_text("this is NOT the text for this action")
+ }.should fail_with("expected to find \"this is NOT the text for this action\" in \"this is the text for this action\"")
+ end
+
+ it "should fail when a template is rendered" do
+ post 'some_action'
+ failure_message = case mode
+ when 'isolation'
+ /expected to find \"this is the text for this action\" in \"render_spec\/some_action\"/
+ when 'integration'
+ /expected to find \"this is the text for this action\" in \"\"/
+ end
+ lambda {
+ response.should include_text("this is the text for this action")
+ }.should fail_with(failure_message)
+ end
+
+ it "should pass using should_not with incorrect text" do
+ post 'text_action'
+ response.should_not include_text("the accordian guy")
+ end
+ end
+ end
+end
+
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb
index b3c7d7a86..e3ce486d4 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb
@@ -21,6 +21,12 @@ require File.dirname(__FILE__) + '/../../spec_helper'
get 'action_with_redirect_to_somewhere_and_return'
response.should redirect_to(:action => 'somewhere')
end
+
+ it "redirected from an SSL action to a non-SSL action" do
+ request.stub!(:ssl?).and_return true
+ get 'action_with_redirect_to_somewhere'
+ response.should redirect_to(:action => 'somewhere')
+ end
it "redirected to correct path with leading /" do
get 'action_with_redirect_to_somewhere'
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb
index 5dbf576f1..93cca867f 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb
@@ -30,11 +30,10 @@ require File.dirname(__FILE__) + '/../../spec_helper'
it "should match an rjs template" do
xhr :post, 'some_action'
- if ActionView::Base.const_defined?('DEFAULT_TEMPLATE_HANDLER_PREFERENCE') ||
- ActionView::Base.respond_to?(:handler_for_extension) then
- response.should render_template('render_spec/some_action')
- else
+ if Rails::VERSION::STRING < "2.0.0"
response.should render_template('render_spec/some_action.rjs')
+ else
+ response.should render_template('render_spec/some_action')
end
end
@@ -83,4 +82,88 @@ require File.dirname(__FILE__) + '/../../spec_helper'
end.should fail_with("expected \"some_action\", got nil")
end
end
+
+ describe "response.should_not render_template (in #{mode} mode)",
+ :type => :controller do
+ controller_name :render_spec
+ if mode == 'integration'
+ integrate_views
+ end
+
+ it "should pass when the action renders nothing" do
+ post 'action_that_renders_nothing'
+ response.should_not render_template('action_that_renders_nothing')
+ end
+
+ it "should pass when the action renders nothing (symbol)" do
+ post 'action_that_renders_nothing'
+ response.should_not render_template(:action_that_renders_nothing)
+ end
+
+ it "should pass when the action does not render the template" do
+ post 'some_action'
+ response.should_not render_template('some_other_template')
+ end
+
+ it "should pass when the action does not render the template (symbol)" do
+ post 'some_action'
+ response.should_not render_template(:some_other_template)
+ end
+
+ it "should pass when the action does not render the template (named with controller)" do
+ post 'some_action'
+ response.should_not render_template('render_spec/some_other_template')
+ end
+
+ it "should pass when the action renders the template with a different controller" do
+ post 'action_which_renders_template_from_other_controller'
+ response.should_not render_template('action_with_template')
+ end
+
+ it "should pass when the action renders the template (named with controller) with a different controller" do
+ post 'action_which_renders_template_from_other_controller'
+ response.should_not render_template('render_spec/action_with_template')
+ end
+
+ it "should pass when TEXT is rendered" do
+ post 'text_action'
+ response.should_not render_template('some_action')
+ end
+
+ it "should fail when the action renders the template" do
+ post 'some_action'
+ lambda do
+ response.should_not render_template('some_action')
+ end.should fail_with("expected not to render \"some_action\", but did")
+ end
+
+ it "should fail when the action renders the template (symbol)" do
+ post 'some_action'
+ lambda do
+ response.should_not render_template(:some_action)
+ end.should fail_with("expected not to render \"some_action\", but did")
+ end
+
+ it "should fail when the action renders the template (named with controller)" do
+ post 'some_action'
+ lambda do
+ response.should_not render_template('render_spec/some_action')
+ end.should fail_with("expected not to render \"render_spec/some_action\", but did")
+ end
+
+ it "should fail when the action renders the partial" do
+ post 'action_with_partial'
+ lambda do
+ response.should_not render_template('_a_partial')
+ end.should fail_with("expected not to render \"_a_partial\", but did")
+ end
+
+ it "should fail when the action renders the partial (named with controller)" do
+ post 'action_with_partial'
+ lambda do
+ response.should_not render_template('render_spec/_a_partial')
+ end.should fail_with("expected not to render \"render_spec/_a_partial\", but did")
+ end
+
+ end
end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/mocks/ar_classes.rb b/vendor/plugins/rspec_on_rails/spec/rails/mocks/ar_classes.rb
new file mode 100644
index 000000000..05213029a
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/spec/rails/mocks/ar_classes.rb
@@ -0,0 +1,10 @@
+class MockableModel < ActiveRecord::Base
+ has_one :associated_model
+end
+
+class SubMockableModel < MockableModel
+end
+
+class AssociatedModel < ActiveRecord::Base
+ belongs_to :mockable_model
+end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb
index 76793f0a1..9ca171b8e 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb
@@ -1,17 +1,7 @@
require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/ar_classes'
-class MockableModel < ActiveRecord::Base
- has_one :associated_model
-end
-
-class SubMockableModel < MockableModel
-end
-
-class AssociatedModel < ActiveRecord::Base
- belongs_to :mockable_model
-end
-
-describe "mock_model", :type => :view do
+describe "mock_model" do
before(:each) do
@model = mock_model(SubMockableModel)
end
@@ -35,6 +25,15 @@ describe "mock_model", :type => :view do
end
end
+describe "mock_model with stubbed id", :type => :view do
+ before(:each) do
+ @model = mock_model(MockableModel, :id => 1)
+ end
+ it "should be named using the stubbed id value" do
+ @model.instance_variable_get(:@name).should == "MockableModel_1"
+ end
+end
+
describe "mock_model with null_object", :type => :view do
before(:each) do
@model = mock_model(MockableModel, :null_object => true, :mocked_method => "mocked")
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/mocks/stub_model_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/mocks/stub_model_spec.rb
new file mode 100644
index 000000000..c123de009
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/spec/rails/mocks/stub_model_spec.rb
@@ -0,0 +1,78 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/ar_classes'
+
+describe "stub_model" do
+ describe "defaults" do
+ it "should have an id" do
+ stub_model(MockableModel).id.should be > 0
+ end
+
+ it "should say it is not a new record" do
+ stub_model(MockableModel).should_not be_new_record
+ end
+ end
+
+ it "should accept a stub id" do
+ stub_model(MockableModel, :id => 37).id.should == 37
+ end
+
+ it "should say it is a new record when id is set to nil" do
+ stub_model(MockableModel, :id => nil).should be_new_record
+ end
+
+ it "should accept any arbitrary stub" do
+ stub_model(MockableModel, :foo => "bar").foo.should == "bar"
+ end
+
+ it "should accept a stub for save" do
+ stub_model(MockableModel, :save => false).save.should be(false)
+ end
+
+ describe "#as_new_record" do
+ it "should say it is a new record" do
+ stub_model(MockableModel).as_new_record.should be_new_record
+ end
+
+ it "should have a nil id" do
+ stub_model(MockableModel).as_new_record.id.should be(nil)
+ end
+ end
+
+ it "should raise when hitting the db" do
+ lambda do
+ stub_model(MockableModel).save
+ end.should raise_error(Spec::Rails::IllegalDataAccessException, /stubbed models are not allowed to access the database/)
+ end
+
+ it "should increment the id" do
+ first = stub_model(MockableModel)
+ second = stub_model(MockableModel)
+ second.id.should == (first.id + 1)
+ end
+
+end
+
+describe "stub_model as association" do
+ before(:each) do
+ @real = AssociatedModel.create!
+ @stub_model = stub_model(MockableModel)
+ @real.mockable_model = @stub_model
+ end
+
+ it "should pass associated_model == mock" do
+ @stub_model.should == @real.mockable_model
+ end
+
+ it "should pass mock == associated_model" do
+ @real.mockable_model.should == @stub_model
+ end
+end
+
+describe "stub_model with a block" do
+ it "should yield the model" do
+ model = stub_model(MockableModel) do |block_arg|
+ @block_arg = block_arg
+ end
+ model.should be(@block_arg)
+ end
+end
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/sample_modified_fixture.rb b/vendor/plugins/rspec_on_rails/spec/rails/sample_modified_fixture.rb
new file mode 100644
index 000000000..832049768
--- /dev/null
+++ b/vendor/plugins/rspec_on_rails/spec/rails/sample_modified_fixture.rb
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../spec_helper'
+
+describe "A sample spec", :type => :model do
+ fixtures :animals
+ it "should pass" do
+ animals(:pig).name.should == "Piggy"
+ end
+end \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb
index 7cd1d4e81..a88e6070e 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb
@@ -1,7 +1,8 @@
require File.dirname(__FILE__) + '/../spec_helper'
-describe "A sample spec" do
+describe "A sample spec", :type => :model do
+ fixtures :animals
it "should pass" do
- true.should === true
+ animals(:pig).name.should == "Pig"
end
end \ No newline at end of file
diff --git a/vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb b/vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb
index 957bd1089..b70f10d90 100644
--- a/vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb
+++ b/vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb
@@ -2,12 +2,24 @@ require File.dirname(__FILE__) + '/../spec_helper'
describe "script/spec_server file", :shared => true do
attr_accessor :tmbundle_install_directory
+ attr_reader :animals_yml_path, :original_animals_content
+
+ before do
+ @animals_yml_path = File.expand_path("#{RAILS_ROOT}/spec/fixtures/animals.yml")
+ @original_animals_content = File.read(animals_yml_path)
+ end
after do
- system "kill -9 #{@pid}"
+ File.open(animals_yml_path, "w") do |f|
+ f.write original_animals_content
+ end
end
- it "runs a spec" do
+ after(:each) do
+ system "lsof -i tcp:8989 | sed /COMMAND/d | awk '{print $2}' | xargs kill"
+ end
+
+ xit "runs a spec" do
dir = File.dirname(__FILE__)
output = ""
Timeout.timeout(10) do
@@ -17,54 +29,49 @@ describe "script/spec_server file", :shared => true do
end
end
- unless $?.exitstatus == 0
+ if $?.exitstatus != 0 || output !~ /0 failures/
flunk "command 'script/spec spec/sample_spec' failed\n#{output}"
end
- end
- def start_spec_server
- create_spec_server_pid_file
- start_spec_server_process
- end
+ fixtures = YAML.load(@original_animals_content)
+ fixtures['pig']['name'] = "Piggy"
+
+ File.open(animals_yml_path, "w") do |f|
+ f.write YAML.dump(fixtures)
+ end
+
+ Timeout.timeout(10) do
+ loop do
+ output = `#{RAILS_ROOT}/script/spec #{dir}/sample_modified_fixture.rb --drb 2>&1`
+ break unless output.include?("No server is running")
+ end
+ end
- def create_spec_server_pid_file
- current_dir = File.dirname(__FILE__)
- pid_dir = "#{Dir.tmpdir}/#{Time.now.to_i}"
- @spec_server_pid_file = "#{pid_dir}/spec_server.pid"
- FileUtils.mkdir_p pid_dir
- system "touch #{@spec_server_pid_file}"
- @rspec_path = File.expand_path("#{current_dir}/../../../rspec/lib")
+ if $?.exitstatus != 0 || output !~ /0 failures/
+ flunk "command 'script/spec spec/sample_modified_fixture' failed\n#{output}"
+ end
end
- def start_spec_server_process
+ def start_spec_server
dir = File.dirname(__FILE__)
- spec_server_cmd = %Q|export HOME=#{Dir.tmpdir}; |
- spec_server_cmd << %Q|ruby -e 'system("echo " + Process.pid.to_s + " > #{@spec_server_pid_file}"); |
- spec_server_cmd << %Q|$LOAD_PATH.unshift("#{@rspec_path}"); require "spec"; |
- spec_server_cmd << %Q|load "#{RAILS_ROOT}/script/spec_server"' &|
- system spec_server_cmd
+ Thread.start do
+ system "cd #{RAILS_ROOT}; script/spec_server"
+ end
file_content = ""
- Timeout.timeout(5) do
- loop do
- file_content = File.read(@spec_server_pid_file)
- break unless file_content.blank?
- end
- end
- @pid = Integer(File.read(@spec_server_pid_file))
end
end
describe "script/spec_server file without TextMate bundle" do
it_should_behave_like "script/spec_server file"
- before do
+ before(:each) do
start_spec_server
end
end
describe "script/spec_server file with TextMate bundle" do
it_should_behave_like "script/spec_server file"
- before do
+ before(:each) do
dir = File.dirname(__FILE__)
@tmbundle_install_directory = File.expand_path("#{Dir.tmpdir}/Library/Application Support/TextMate/Bundles")
@bundle_name = "RSpec.tmbundle"
@@ -77,7 +84,7 @@ describe "script/spec_server file with TextMate bundle" do
start_spec_server
end
- after do
+ after(:each) do
bundle_file_to_remove = "#{tmbundle_install_directory}/#{@bundle_name}"
if bundle_file_to_remove == "/"
raise "bundle file path resolved to '/' - could not call rm"
diff --git a/vendor/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb b/vendor/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb
index ce8bc186c..769f4c588 100644
--- a/vendor/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb
+++ b/vendor/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb
@@ -10,11 +10,23 @@ class ControllerSpecController < ActionController::Base
end
def action_with_template
- session[:session_key] = "session value"
- flash[:flash_key] = "flash value"
render :template => "controller_spec/action_with_template"
end
+ def action_which_sets_flash
+ flash[:flash_key] = "flash value"
+ render :text => ""
+ end
+
+ def action_which_gets_session
+ raise "expected #{params[:session_key].inspect}\ngot #{session[:session_key].inspect}" unless (session[:session_key] == params[:expected])
+ render :text => ""
+ end
+
+ def action_which_sets_session
+ session[:session_key] = "session value"
+ end
+
def action_with_partial
render :partial => "controller_spec/partial"
end
@@ -45,5 +57,12 @@ class ControllerSpecController < ActionController::Base
flash[:before_reset] = 'available'
reset_session
end
+
+ def action_with_render_update
+ render :update do |page|
+ page.replace :bottom, 'replace_me',
+ :partial => 'non_existent_partial'
+ end
+ end
end
diff --git a/vendor/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb b/vendor/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb
index 7ab76eefa..b546abe4c 100644
--- a/vendor/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb
+++ b/vendor/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb
@@ -19,4 +19,8 @@ class RenderSpecController < ApplicationController
def action_with_partial
render :partial => "a_partial"
end
+
+ def action_that_renders_nothing
+ render :nothing => true
+ end
end
diff --git a/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml b/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml
index ef636f61c..1d6f96b01 100644
--- a/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml
+++ b/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml
@@ -1,3 +1,5 @@
<div id="session"><%= session[:key] %></div>
<div id="params"><%= params[:key] %></div>
-<div id="flash"><%= flash[:key] %></div> \ No newline at end of file
+<div id="flash"><%= flash[:key] %></div>
+<div id="controller"><%= params[:controller] %></div>
+<div id="action"><%= params[:action] %></div>
diff --git a/vendor/plugins/rspec_on_rails/tasks/rspec.rake b/vendor/plugins/rspec_on_rails/tasks/rspec.rake
index 722854740..0230234fa 100644
--- a/vendor/plugins/rspec_on_rails/tasks/rspec.rake
+++ b/vendor/plugins/rspec_on_rails/tasks/rspec.rake
@@ -53,14 +53,14 @@ namespace :spec do
desc "Run the specs under vendor/plugins (except RSpec's own)"
Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec_on_rails/*")
+ t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
end
namespace :plugins do
desc "Runs the examples for rspec_on_rails"
Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
- t.spec_files = FileList['vendor/plugins/rspec_on_rails/spec/**/*_spec.rb']
+ t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb']
end
end