Sha256: d75b391cab6b52ebbd8435d672aee65265a3cb26afb34770fafb5de1573539bc

Contents?: true

Size: 978 Bytes

Versions: 3

Compression:

Stored size: 978 Bytes

Contents

require 'spec_helper'

describe "optparser" do
	before (:each) do
		Options.clear
		@key = random_hex 4
		@value = random_hex 4
	end

	it "behaves like a OptionParser." do
		Options.kind_of? OptionParser
	end

	describe "[Hash]" do
		it "can clear" do
			Options[:foo] = :bar
			Options.clear
			Options[].any?.should be_false
		end

		it "can set via []=" do
			Options[@key] = @value
			Options[@key].should eq @value
		end

		it "gets all keys with []" do
			Options[@key] = @value
			Options[].include?(@key).should be_true
		end

		it "gets a value with [:key]" do
			Options[@key] = @value
			Options[@key].should eq @value
		end

		it "can mash values (opposite of merge)." do
			Options[:mash] = 'mush'
			h = {mash:'notmush'}
			Options.mash h
			Options[:mash].should eq 'mush'
		end

	end
	describe "parse" do
		it "will attempt to mash in the Config[]#hash if available." do
			Bini::config[@key] == @value
			Options.parse!
			Options[@key] = @value
		end
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bini-0.5.5 spec/optparser_spec.rb
bini-0.5.4 spec/optparser_spec.rb
bini-0.5.2 spec/optparser_spec.rb