This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 1
1
Feature : run with ruby command
2
2
3
- @wip
3
+ You can use the `ruby` command to run specs. You just need to require
4
+ `rspec/autorun`.
5
+
6
+ Generally speaking, you're better off using the `rspec` command, which
7
+ requires `rspec/autorun` for you, but some tools only work with the `ruby`
8
+ command.
9
+
4
10
Scenario :
5
11
Given a file named "example_spec.rb" with:
6
12
"""
Original file line number Diff line number Diff line change @@ -311,10 +311,14 @@ def reporter
311
311
312
312
def files_or_directories_to_run = ( *files )
313
313
files = files . flatten
314
- files << default_path if files . empty? && default_path
314
+ files << default_path if command == 'rspec' && default_path && files . empty?
315
315
self . files_to_run = get_files_to_run ( files )
316
316
end
317
317
318
+ def command
319
+ $0. split ( File ::SEPARATOR ) . last
320
+ end
321
+
318
322
def get_files_to_run ( files )
319
323
patterns = pattern . split ( "," )
320
324
files . map do |file |
Original file line number Diff line number Diff line change @@ -176,10 +176,17 @@ module RSpec::Core
176
176
end
177
177
178
178
context "with default default_path" do
179
- it "loads files named _spec.rb" do
179
+ it "loads files in the default path when run by rspec" do
180
+ config . stub ( :command ) { 'rspec' }
180
181
config . files_or_directories_to_run = [ ]
181
182
config . files_to_run . should_not be_empty
182
183
end
184
+
185
+ it "does not load files in the default path when run by ruby" do
186
+ config . stub ( :command ) { 'ruby' }
187
+ config . files_or_directories_to_run = [ ]
188
+ config . files_to_run . should be_empty
189
+ end
183
190
end
184
191
end
185
192
You can’t perform that action at this time.
0 commit comments