Sha256: 6d7eacbb5bfcd50c96470183b33acfeb3aa5f0d33a5230a3cb045255800c843b

Contents?: true

Size: 873 Bytes

Versions: 3

Compression:

Stored size: 873 Bytes

Contents

require 'base_test'
require 'methadone'
require 'stringio'

class TestExitNow < BaseTest
  include Methadone
  include Methadone::ExitNow

  test_that "exit_now raises the proper error" do
    Given {
      @exit_code = any_int :min => 1
      @message = any_string
    }
    When {
      @code = lambda { exit_now!(@exit_code,@message) }
    }
    Then {
      exception = assert_raises(Methadone::Error,&@code)
      exception.exit_code.should be == @exit_code
      exception.message.should be == @message
    }
  end

  test_that "exit_now without an exit code uses 1 as the exti code" do
    Given {
      @message = any_string
    }
    When {
      @code = lambda { exit_now!(@message) }
    }
    Then {
      exception = assert_raises(Methadone::Error,&@code)
      exception.exit_code.should be == 1
      exception.message.should be == @message
    }
  end
end 

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
methadone-2.0.2 test/unit/test_exit_now.rb
methadone-2.0.1 test/unit/test_exit_now.rb
methadone-2.0.0 test/unit/test_exit_now.rb