Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test coverage for output helpers #690

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions spec/lib/mina/helpers/output_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,29 @@ class DummyOutputHelper

describe '#print_line' do
it 'prints normally' do
expect{ helper.print_line('ls -al') }.to output(" ls -al\n").to_stdout
expect { helper.print_line('ls -al') }.to output(" ls -al\n").to_stdout
end

it 'prints comment' do
expect{ helper.print_line('-> ls -al') }.to output("\e[32m----->\e[0m ls -al\n").to_stdout
expect { helper.print_line('-> ls -al') }.to output("\e[32m----->\e[0m ls -al\n").to_stdout
end

it 'prints error' do
expect{ helper.print_line('! ls -al') }.to output(" \e[33m!\e[0m \e[31mls -al\e[0m\n").to_stdout
expect { helper.print_line('! ls -al') }.to output(" \e[33m!\e[0m \e[31mls -al\e[0m\n").to_stdout
end

it 'prints command' do
expect{ helper.print_line('$ ls -al') }.to output(" \e[36m$\e[0m \e[36mls -al\e[0m\n").to_stdout
expect { helper.print_line('$ ls -al') }.to output(" \e[36m$\e[0m \e[36mls -al\e[0m\n").to_stdout
end
end

describe '#print_stderr' do
it 'prints normally when the message is formatted by assets precompile' do
expect { helper.print_stderr('I, [ ls -al') }.to output(" I, [ ls -al\n").to_stdout
end

it 'prints stderr' do
expect{ helper.print_stderr('ls -al') }.to output(" \e[31mls -al\e[0m\n").to_stdout
expect { helper.print_stderr('ls -al') }.to output(" \e[31mls -al\e[0m\n").to_stdout
end
end
end