Sha256: 2f0508d6ddb2486caee40ab5835c272fd255b5099378c68ddf5df6ac0b0ac91c

Contents?: true

Size: 950 Bytes

Versions: 1

Compression:

Stored size: 950 Bytes

Contents

require 'test_helper'
require_relative '../lib/sandi_meter/cli'

describe SandiMeter::CLI do
  let(:cli) { SandiMeter::CLI }
  
  describe '#execute' do
    before do 
      @original_argv = ARGV
      ARGV.clear
    end
    
    after do 
      ARGV.clear
      ARGV.concat(@original_argv)
    end
    
    context 'with the graph flag passed in' do
      before { ARGV.push('-g') }
      after { ARGV.pop }
      
      it 'opens the graph in a web browser' do
        cli.should_receive(:open_in_browser)
        expect { cli.execute }.to raise_error(SystemExit)
      end
    end

    context 'with the quiet flag passed in' do
      before do
        ARGV.push('-q')
        ARGV.push('-g')
      end
      after do 
        ARGV.pop 
        ARGV.pop 
      end
      
      it 'does not open the browser' do
        cli.should_not_receive(:open_in_browser)
        expect { cli.execute }.to raise_error(SystemExit)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sandi_meter-1.1.8 spec/cli_spec.rb