Sha256: 0111850f411e13a55a981de0d94c0028965e8ff54eb68f01b37babe8b39c08cc

Contents?: true

Size: 953 Bytes

Versions: 3

Compression:

Stored size: 953 Bytes

Contents

require "ostruct"
require File.expand_path('../fixtures/classes', __FILE__)

describe "OpenStruct#==" do
  before(:each) do
    @os = OpenStruct.new(:name => "John")
  end

  it "returns false when the passed argument is no OpenStruct" do
    (@os == Object.new).should be_false
    (@os == "Test").should be_false
    (@os == 10).should be_false
    (@os == :sym).should be_false
  end

  it "returns true when self and other are equal method/value wise" do
    (@os == @os).should be_true
    (@os == OpenStruct.new(:name => "John")).should be_true
    (@os == OpenStructSpecs::OpenStructSub.new(:name => "John")).should be_true

    (@os == OpenStruct.new(:name => "Jonny")).should be_false
    (@os == OpenStructSpecs::OpenStructSub.new(:name => "Jonny")).should be_false

    (@os == OpenStruct.new(:name => "John", :age => 20)).should be_false
    (@os == OpenStructSpecs::OpenStructSub.new(:name => "John", :age => 20)).should be_false
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubysl-ostruct-2.1.0 spec/equal_value_spec.rb
rubysl-ostruct-2.0.4 spec/equal_value_spec.rb
rubysl-ostruct-1.0.0 spec/equal_value_spec.rb