Sha256: acdb45c6a397ea09832847a49b40128fb99c69809398222ca53bcf956bebb9fa

Contents?: true

Size: 1.33 KB

Versions: 19

Compression:

Stored size: 1.33 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'
require File.dirname(__FILE__) + '/../../../lib/poolparty/helpers/optioner'

describe "Option Parser" do
  describe "options" do
    before(:each) do
      @op = PoolParty::Optioner.new
      @op.parse_options
    end
    it "should set the options as an Hash" do
      @op.options.class.should == Hash
    end
    it "should have the verbose option set to false by default" do
      @op.verbose.should == false
    end
    it "should call a method called on it that is not defined on the options if they exist" do
      @op.options.should_receive(:[]).with(:verbose).once.and_return true
      @op.verbose
    end
    it "should be able to display the version" do
      @op.version.should == PoolParty::VERSION::STRING
    end
    it "should exit after displaying the help message" do
      hide_output do
        lambda {
          @o = PoolParty::Optioner.new(["-h"], {:parse_options => false})
          @o.should_receive(:process_options).once
          @o.parse_options
        }
      end
    end
  end
  it "should be able to take a block and set some options on the block" do
    o = PoolParty::Optioner.new(["-w"]) do |opts, optioner|
      opts.on('-w', '--wee')    { optioner.wee "wee" }
      opts.on('-t t', '--teatime tea')    { optioner.tea "time" }
    end
    o.wee.should == "wee"
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
auser-poolparty-0.2.16 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.20 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.21 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.22 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.23 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.24 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.25 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.26 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.35 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.36 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.37 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.38 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.39 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.40 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.41 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.42 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.44 spec/poolparty/helpers/optioner_spec.rb
auser-poolparty-0.2.45 spec/poolparty/helpers/optioner_spec.rb
poolparty-0.2.18 spec/poolparty/helpers/optioner_spec.rb