Sha256: 02eea8781e80f003ebff48487ec94082ccf587425f2355ab62303c8ff65412b0

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

require 'rext/hash'

describe Hash do
  describe "helpers" do
    describe "#delete_at" do
      it "should delete several keys, returning their values when present" do
        options = { :foo => 1, :bar => 2 }
        foo, bar, does_not_exist = options.delete_at :foo, :bar, :does_not_exist
        foo.should == 1
        bar.should == 2
        does_not_exist.should be_nil
      end
    end
    
    describe "#switchify" do
      it "should work with bools" do
        { :use_foobar => true }.switchify.should == ['--use-foobar']
        { :use_foobar => false }.switchify.should be_empty
      end
      
      it "should stringify numbers and symbols" do
        { :interval => 15, :icon => :jpeg }.switchify.should == ['--interval', '15', '--icon', 'jpeg']
      end
      
      it "should work with little switches" do
        { :T => true }.switchify.should == ['-T']
      end
      
      it "should add quotes around strings" do
        { :glob => 'lib/**/*.rb' }.switchify.should == ['--glob', '"lib/**/*.rb"']
      end
    end
  end  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
visionmedia-rext-0.0.7 spec/hash_spec.rb
visionmedia-rext-0.0.8 spec/hash_spec.rb
visionmedia-rext-0.1.0 spec/hash_spec.rb
visionmedia-rext-0.2.1 spec/hash_spec.rb
visionmedia-rext-0.2.2 spec/hash_spec.rb