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

Music fix #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions lib/nyan_cat_format/music.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def kill_music

def linux_player
%w{mpg321 mpg123}.find {|player|
kernel.system("which #{ player } &>/dev/null && type #{ player } &>/dev/null")
kernel.system("which #{player} > /dev/null 2>&1 && type #{player} > /dev/null 2>&1")
}
end

Expand All @@ -61,7 +61,7 @@ def music_command
if osx?
@music_command = "afplay #{nyan_mp3}"
elsif linux? && linux_player
@music_command = "#{ linux_player } #{ nyan_mp3 } &>/dev/null"
@music_command = "#{linux_player} #{nyan_mp3} > /dev/null 2>&1"
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/nyan_cat_music_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ def seen
allow(mock_kernel).to receive(:system).with(match(/which mpg123/)).and_return(true)
allow(mock_kernel).to receive(:system).with(match(/which mpg321/)).and_return(false)
formatter.start 10
expect(mock_kernel.seen.any? { |entry| entry. end_with? "mpg123 #{path_to_mp3} &>/dev/null" }).to be
expect(mock_kernel.seen.any? { |entry| entry. end_with? "mpg123 #{path_to_mp3} > /dev/null 2>&1" }).to be
end

it 'plays the song for linux too with mpg321 when available' do
allow(mock_kernel).to receive(:system).with(match(/which mpg321/)).and_return(true)
allow(mock_kernel).to receive(:system).with(match(/which mpg123/)).and_return(false)
formatter.start 10
expect(mock_kernel.seen.any? { |entry| entry. end_with? "mpg321 #{path_to_mp3} &>/dev/null" }).to be
expect(mock_kernel.seen.any? { |entry| entry. end_with? "mpg321 #{path_to_mp3} > /dev/null 2>&1" }).to be
end
end

Expand Down