Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

--configure option generates .rspec file instead of autotest/discover.rb

  • Loading branch information...
commit 801e7bcdc74459889138cbb29a2d9681701e22d3 1 parent db803b3
@dchelimsky dchelimsky authored
View
1  History.markdown
@@ -20,6 +20,7 @@
* rake task doesn't choke on paths with quotes (Janmejay Singh)
* restore --options option from rspec-1
* require 'ostruct' to fix bug with its([key]) (Kim Burgestrand)
+ * --configure option generates .rspec file instead of autotest/discover.rb
### 2.3.0 / 2010-12-12
View
28 features/command_line/configure.feature
@@ -3,18 +3,20 @@ Feature: configure
Use the --configure option on the command line to generate configuration
files.
- The only supported argument, so far, is "autotest", which creates an
- autotest/discover.rb file in your project root directory.
+ The only supported argument, so far, is "autotest", which creates a .rspec
+ file in your project root directory. When autotest sees this file, it knows
+ to load RSpec's Autotest subclass.
- Background:
- Given a directory named "rspec_project"
+ Scenario: generate .rspec file for autotest
+ When I run "rspec --configure autotest"
+ Then the following files should exist:
+ | .rspec |
+ And the stdout should contain ".rspec file did not exist, so it was created."
- Scenario: generate autotest directory and discover file
- When I cd to "rspec_project"
- And I run "rspec --configure autotest"
- Then the following directories should exist:
- | autotest |
- And the following files should exist:
- | autotest/discover.rb |
- And the file "autotest/discover.rb" should contain "Autotest.add_discovery"
- And the stdout should contain "autotest/discover.rb has been added"
+ Scenario: .rspec file already exists
+ Given a file named ".rspec" with:
+ """
+ --color
+ """
+ When I run "rspec --configure autotest"
+ Then the stdout should contain ".rspec file already exists, so nothing was changed."
View
32 lib/rspec/core/command_line_configuration.rb
@@ -16,7 +16,7 @@ def run
"#{@command}" is not valid a valid argument to "rspec --configure".
Supported options are:
- rspec --configure autotest # generates configuration to run autotest with rspec
+ rspec --configure autotest # generates .rspec file
#{"*"*50}
MESSAGE
@@ -26,26 +26,26 @@ def run
class Autotest
class << self
def generate
- create_autotest_directory
- create_discover_file
- puts "autotest/discover.rb has been added"
+ create_dot_rspec_file
+ remove_autotest_dir_if_present
end
- def create_autotest_directory
- Dir.mkdir('autotest') unless File.exist?('autotest')
- end
-
- def create_discover_file
- optionally_remove_discover_file if discover_file_exists?
- File.open(discover_file_path, 'w') do |file|
- file << 'Autotest.add_discovery { "rspec2" }'
+ def create_dot_rspec_file
+ puts "Autotest loads RSpec's Autotest subclass when there is a .rspec file in the project's root directory."
+ if File.exist?('./.rspec')
+ puts ".rspec file already exists, so nothing was changed."
+ else
+ FileUtils.touch('./.rspec')
+ puts ".rspec file did not exist, so it was created."
end
end
- def optionally_remove_discover_file
- print "Discover file already exists, overwrite [y/N]? "
- exit if gets !~ /y/i
- FileUtils.rm_rf(discover_file_path)
+ def remove_autotest_dir_if_present
+ if discover_file_exists?
+ print "Delete obsolete autotest/discover.rb [y/n]? "
+ exit if gets !~ /y/i
+ FileUtils.rm_rf(discover_file_path)
+ end
end
def discover_file_exists?
Please sign in to comment.
Something went wrong with that request. Please try again.