Skip to content

Commit

Permalink
only use default_path when run with rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Jul 14, 2011
1 parent f995279 commit e7bb363
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
8 changes: 7 additions & 1 deletion features/command_line/ruby.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Feature: run with ruby command

@wip
You can use the `ruby` command to run specs. You just need to require
`rspec/autorun`.

Generally speaking, you're better off using the `rspec` command, which
requires `rspec/autorun` for you, but some tools only work with the `ruby`
command.

Scenario:
Given a file named "example_spec.rb" with:
"""
Expand Down
6 changes: 5 additions & 1 deletion lib/rspec/core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,14 @@ def reporter

def files_or_directories_to_run=(*files)
files = files.flatten
files << default_path if files.empty? && default_path
files << default_path if command == 'rspec' && default_path && files.empty?
self.files_to_run = get_files_to_run(files)
end

def command
$0.split(File::SEPARATOR).last
end

def get_files_to_run(files)
patterns = pattern.split(",")
files.map do |file|
Expand Down
9 changes: 8 additions & 1 deletion spec/rspec/core/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,17 @@ module RSpec::Core
end

context "with default default_path" do
it "loads files named _spec.rb" do
it "loads files in the default path when run by rspec" do
config.stub(:command) { 'rspec' }
config.files_or_directories_to_run = []
config.files_to_run.should_not be_empty
end

it "does not load files in the default path when run by ruby" do
config.stub(:command) { 'ruby' }
config.files_or_directories_to_run = []
config.files_to_run.should be_empty
end
end
end

Expand Down

0 comments on commit e7bb363

Please sign in to comment.