Sha256: a9ae30a3dfbcf2f28bca265b2045eed2f71cef6b74e897846f3d838a31c3b575

Contents?: true

Size: 972 Bytes

Versions: 4

Compression:

Stored size: 972 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper.rb'

describe 'flac2mp3 command' do
  def run_command(*args)
    Object.const_set(:ARGV, args)
    begin
      eval File.read(File.join(File.dirname(__FILE__), *%w[.. bin flac2mp3]))
    rescue SystemExit
    end
  end
  
  before :all do
    path = File.join(File.dirname(__FILE__), *%w[.. bin])
    ENV['PATH'] = [path, ENV['PATH']].join(':')
  end
  
  before :each do
    Flac2mp3.stubs(:convert)
  end
  
  it 'should exist' do
    lambda { run_command('blah') }.should_not raise_error(Errno::ENOENT)
  end
  
  it 'should require a filename' do
    self.expects(:puts) { |text|  text.match(/usage.+filename/i) }
    run_command
  end
  
  it 'should pass the filename to Flac2mp3 for conversion' do
    Flac2mp3.expects(:convert).with('blah')
    run_command('blah')
  end
  
  it 'should duplicate the filename' do
    filename = 'blah'
    filename.expects(:dup).returns(filename)
    run_command(filename)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
flac2mp3-0.2.3 spec/flac2mp3_command_spec.rb
flac2mp3-0.2.2 spec/flac2mp3_command_spec.rb
flac2mp3-0.2.4 spec/flac2mp3_command_spec.rb
flac2mp3-0.2.5 spec/flac2mp3_command_spec.rb