Sha256: 4630a4bc6c3351ec721e41395628cfce6a06a76d74698e88c2f0383556de5837

Contents?: true

Size: 1.12 KB

Versions: 30

Compression:

Stored size: 1.12 KB

Contents

require File.dirname(__FILE__) + "/spec_helper"
require 'options'

describe Options do 
  describe "parsing" do 
    it "should be able to handle an options hash" do 
      opts = Options.parse({:this => 'that'})
      opts.getopt(:this).should eql('that')
    end

    it "should be able to handle args list w/ options hash" do 
      args, opts = Options.parse([:foo, {:this => 'that'}])
      opts.getopt(:this).should eql('that')
      args.should eql([:foo])
    end
  end

  describe "validation" do 
    it "should be able to detect extraneous options" do 
      lambda{
        Options.parse({:this => 'test'}).validate(:foo, :bar)
      }.should raise_error(ArgumentError, "Unrecognized options: this")
    end

    it "should list all extraneous options in message" do 
      lambda{
        Options.parse({:this => 'test', :that => 'test'}).validate(:foo)
      }.should raise_error(ArgumentError, "Unrecognized options: that, this")
    end

    it "should accept options from simple list" do 
      lambda{
        Options.parse({:foo => 'this', :bar => 'that'}).validate(:foo, :bar)
      }.should_not raise_error
    end

  end
end

Version data entries

30 entries across 30 versions & 3 rubygems

Version Path
ahoward-options-2.1.1 spec/options_spec.rb
options-2.3.2 spec/options_spec.rb
options-2.3.1 spec/options_spec.rb
abiquo-etk-0.6.4 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.6.3 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.6.2 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.6.1 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.6.0 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.5.9 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.5.8 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.5.3 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.4.42 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.4.33 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.4.32 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.4.29 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.4.25 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.4.24 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.4.23 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.4.22 vendor/options-2.3.0/spec/options_spec.rb
abiquo-etk-0.4.20 vendor/options-2.3.0/spec/options_spec.rb