File: ui_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 (30 lines) | stat: -rw-r--r-- 871 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
require 'spec_helper'

describe Fission::UI do
  before do
    @string_io = StringIO.new
  end

  describe 'output' do
    it 'should show the desired text' do
      Fission::UI.new(@string_io).output "foo bar\nbaz blah"
      @string_io.string.should == "foo bar\nbaz blah\n"
    end
  end

  describe 'output_printf' do
    it 'should pass the arguments to printf' do
      @output = double('output')
      @output.should_receive(:printf).with('foo', 'bar', 'baz')
      Fission::UI.new(@output).output_printf('foo', 'bar', 'baz')
    end
  end

  describe 'output_and_exit' do
    it 'should show the desired text and exit with the desired exit code' do
      Fission::UI.any_instance.should_receive(:exit).and_return(1)
      Fission::UI.new(@string_io).output_and_exit "foo bar\nbaz blah", 1
      @string_io.string.should == "foo bar\nbaz blah\n"
    end
  end
end