spec/reek/cli/application_spec.rb in reek-4.8.2 vs spec/reek/cli/application_spec.rb in reek-5.0.0
- old
+ new
@@ -15,13 +15,13 @@
end
end
describe '#execute' do
let(:path_excluded_in_configuration) do
- SAMPLES_PATH.join('source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb')
+ SAMPLES_DIR.join('source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb')
end
- let(:configuration) { test_configuration_for(CONFIG_PATH.join('with_excluded_paths.reek')) }
+ let(:configuration) { test_configuration_for(CONFIGURATION_DIR.join('with_excluded_paths.reek')) }
let(:command) { instance_double 'Reek::CLI::Command::ReportCommand' }
let(:app) { described_class.new [] }
before do
allow(Reek::CLI::Command::ReportCommand).to receive(:new).and_return command
@@ -35,15 +35,29 @@
context 'when no source files given and input was piped' do
before do
allow_any_instance_of(IO).to receive(:tty?).and_return(false)
end
- it 'uses source form pipe' do
+ it 'uses source from pipe' do
+ expected_sources = a_collection_containing_exactly(have_attributes(origin: 'STDIN'))
app.execute
expect(Reek::CLI::Command::ReportCommand).to have_received(:new).
- with(sources: [$stdin],
+ with(sources: expected_sources,
configuration: Reek::Configuration::AppConfiguration,
options: Reek::CLI::Options)
+ end
+
+ context 'when a stdin filename is provided' do
+ let(:app) { described_class.new ['--stdin-filename', 'foo.rb'] }
+
+ it 'assumes that filename' do
+ expected_sources = a_collection_containing_exactly(have_attributes(origin: 'foo.rb'))
+ app.execute
+ expect(Reek::CLI::Command::ReportCommand).to have_received(:new).
+ with(sources: expected_sources,
+ configuration: Reek::Configuration::AppConfiguration,
+ options: Reek::CLI::Options)
+ end
end
end
context 'when no source files given and no input was piped' do
before do