Sha256: cd9a969ec206cc50bc6ba48a2355b65e952b759c376e5caa8bba33ed20ae1c64

Contents?: true

Size: 963 Bytes

Versions: 20

Compression:

Stored size: 963 Bytes

Contents

require File.join(File.dirname(__FILE__), %w[.. .. .. spec_helper])

describe SC::HashStruct, 'has_options?' do
  
  include SC::SpecHelpers

  before do 
    @hash = SC::HashStruct.new :foo => :foo, :bar => :bar
  end
  
  it "always returns true if passed match is empty or nil" do
    @hash.has_options?.should be_true
    @hash.has_options?({}).should be_true
  end
  
  it "returns true if every key/value pair in passed value set matches" do
    @hash.has_options?(:foo => :foo, :bar => :bar).should be_true
  end
  
  it "returns false if any key/value pair in passed value set does not match" do
    @hash.has_options?(:foo => :foo, :bar => :no_match).should be_false
  end
  
  it "returns false if any key/value pair does not exist in hash" do
    @hash.has_options?(:imaginary => true).should be_false
  end
  
  it "returns treats strings + symbols the same for keys" do
    @hash.has_options?('foo' => :foo, 'bar' => :bar).should be_true
  end
  
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
sproutit-sproutcore-1.0.0.20090407205609 spec/lib/models/hash_struct/has_options_spec.rb
sproutit-sproutcore-1.0.0.20090408130025 spec/lib/models/hash_struct/has_options_spec.rb
sproutit-sproutcore-1.0.0.20090416161445 spec/lib/models/hash_struct/has_options_spec.rb
sproutit-sproutcore-1.0.20090721145236 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1046 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1043 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1042 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1037 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1035 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1031 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1030 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1029 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1027 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1028 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1026 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1025 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1024 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1009 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1008 spec/lib/models/hash_struct/has_options_spec.rb
sproutcore-1.0.1003 spec/lib/models/hash_struct/has_options_spec.rb