Skip to content

Commit

Permalink
send file when file
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Oct 28, 2013
1 parent 179241b commit 5dae182
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/rspec/core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def self.add_setting(name, opts={})
# @macro add_setting
# Default: `$stderr`.
add_setting :deprecation_stream
def deprecation_stream=(filename_or_io)
@deprecation_stream = file_or_io_from(filename_or_io)
end

# @macro add_setting
# Clean up and exit after the first failure (default: `false`).
Expand Down Expand Up @@ -1061,6 +1064,10 @@ def underscore(camel_cased_word)
word
end

def file_or_io_from(output)
String === output ? file_at(output) : output
end

def file_at(path)
FileUtils.mkdir_p(File.dirname(path))
File.new(path, 'w')
Expand Down
5 changes: 5 additions & 0 deletions spec/rspec/core/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ module RSpec::Core
config.deprecation_stream = io
expect(config.deprecation_stream).to eq io
end

it 'will load a file from a filename' do
config.deprecation_stream = 'string.rb'
expect(config.deprecation_stream).to be_a File
end
end

describe "#setup_load_path_and_require" do
Expand Down

0 comments on commit 5dae182

Please sign in to comment.