Permalink
Browse files

Add "rspec2" to list of Autotest discoveries if ./.rspec file is found.

  • Loading branch information...
1 parent c228993 commit dc1b0d53fde7505bb5769884e5c54b09b6886f89 @dchelimsky dchelimsky committed Dec 11, 2010
Showing with 62 additions and 2 deletions.
  1. 0 .rspec
  2. +4 −0 History.markdown
  3. +10 −0 Upgrade.markdown
  4. +0 −2 autotest/discover.rb
  5. +28 −0 features/README.markdown
  6. +1 −0 lib/autotest/discover.rb
  7. +19 −0 spec/autotest/discover_spec.rb
View
0 .rspec
No changes.
View
@@ -5,6 +5,10 @@
[full changelog](http://github.com/rspec/rspec-core/compare/v2.2.1...master)
* Enhancements
+ * tell autotest to use "rspec2" if it sees a .rspec file in the project's
+ root directory
+ * replaces the need for ./autotest/discover.rb, which will not work with
+ all versions of ZenTest and/or autotest
* config.expect_with
* :rspec # => rspec/expectations
* :stdlib # => test/unit/assertions
View
@@ -1,5 +1,15 @@
# rspec-core-2.3
+## autotest integration
+
+Add a .rspec file to the project's root directory to tell RSpec to tell
+Autotest to use RSpec's specialized Autotest class.
+
+NOTE that rspec-core-2.0, 2.1, and 2.2 required an autotest/discover.rb file in
+the project's root directory. This worked with some, but not all versions of
+autotest and/or the autotest command that ships with ZenTest. This new approach
+will work regardless of which version of autotest/ZenTest you are using.
+
## config.expect_with
Use this to configure RSpec to use rspec/expectations (default),
View
@@ -1,2 +0,0 @@
-Autotest.add_discovery { "rspec2" }
-
View
@@ -8,6 +8,34 @@ rspec-core provides the structure for RSpec code examples:
end
end
+### Autotest integration
+
+RSpec ships with a specialized subclass of Autotest. You can pass the --style
+option to the autotest command to tell Autotest to load this subclass:
+
+ $ autotest --style rspec2
+
+Alternatively, you can configure your project such that this happens
+automatically, in which case you can just type:
+
+ $ autotest
+
+Here's how:
+
+#### rspec-2.3 and up
+
+Add a .rspec file to the project's root directory if it's not already there.
+You can use this to configure RSpec options, but you don't have to. As long as
+RSpec sees this file, it will tell Autotest to use the "rspec2" style.
+
+#### rspec-2.2 and down
+
+Add an autotest directory to the project root, and add a file named discover.rb to
+that directory with the following:
+
+ # in ./autotest/discover.rb
+ Autotest.add_discovery {"rspec2"}
+
## Issues
The documentation for rspec-core is a work in progress. We'll be adding
View
@@ -0,0 +1 @@
+Autotest.add_discovery { "rspec2" } if File.exist?("./.rspec")
@@ -0,0 +1,19 @@
+require "spec_helper"
+
+describe "autotest/discover.rb" do
+ context "with /.rspec present" do
+ it "adds 'rspec2' to the list of discoveries" do
+ File.stub(:exist?).with("./.rspec") { true }
+ Autotest.should_receive(:add_discovery)
+ load File.expand_path("../../../lib/autotest/discover.rb", __FILE__)
+ end
+ end
+
+ context "with /.rspec absent" do
+ it "does not add 'rspec2' to the list of discoveries" do
+ File.stub(:exist?) { false }
+ Autotest.should_not_receive(:add_discovery)
+ load File.expand_path("../../../lib/autotest/discover.rb", __FILE__)
+ end
+ end
+end

0 comments on commit dc1b0d5

Please sign in to comment.