File: cli_spec.rb

package info (click to toggle)
ruby-fission 0.5.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 624 kB
  • sloc: ruby: 4,664; makefile: 10
file content (50 lines) | stat: -rw-r--r-- 1,439 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require 'spec_helper'

describe Fission::CLI do
  before do
    @string_io = StringIO.new
    Fission::CLI.any_instance.stub(:ui).and_return(Fission::UI.new(@string_io))
    @parser = double('parser')
    @parser.stub :parse
    @parser.stub :command
  end

  describe 'initialize' do
    it 'should create a parse object using ARGV' do
      Fission::CommandLineParser.should_receive(:new).with(ARGV).
                                                      and_return(@parser)

      Fission::CLI.new
    end

    it 'should create a parse object with the provided args' do
      Fission::CommandLineParser.should_receive(:new).with(['foo']).
                                                      and_return(@parser)

      Fission::CLI.new ['foo']

    end

    it 'should create a parse object using our parser' do
      @parser.should_receive(:new).with(ARGV).and_return(@parser)
      Fission::CLI.new nil, @parser
    end

    it 'should parse the arguments using the parser' do
      @parser.should_receive(:new).with(ARGV).and_return(@parser)
      @parser.should_receive :parse
      Fission::CLI.new nil, @parser
    end
  end

  describe 'execute' do
    it 'should execute the parsed command' do
      @cmd_mock = double('cmd')
      @cmd_mock.should_receive :execute
      @parser.stub(:new).and_return(@parser)
      @parser.stub(:command).and_return(@cmd_mock)
      Fission::CLI.new(nil, @parser).execute
    end
  end

end