Skip to content

Commit

Permalink
Merge pull request #63 from basvodde/master
Browse files Browse the repository at this point in the history
Equal operator for SubjectData
  • Loading branch information
Lucas Neves Martins committed Apr 30, 2014
2 parents 8a874f1 + 2e0e6a8 commit 4a3de3a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/highrise/subject_data.rb
@@ -1,4 +1,8 @@
module Highrise
class SubjectData < Base
def==other
attributes["value"] == other.attributes["value"] &&
attributes["subject_field_label"] == other.attributes["subject_field_label"]
end
end
end
19 changes: 19 additions & 0 deletions spec/highrise/subject_data_spec.rb
Expand Up @@ -2,4 +2,23 @@

describe Highrise::SubjectData do
it { should be_a_kind_of Highrise::Base }

it "Two different subject datas with different values are not equal" do
martini = Highrise::SubjectData.new({:id => 1, :value => "Martini", :subject_field_id => 3, :subject_field_label => "Cocktail"})
sling = Highrise::SubjectData.new({:id => 2, :value => "Singapore Sling", :subject_field_id => 4, :subject_field_label => "Cocktail"})
martini.should_not==sling
end

it "Two different subject datas with different labels are not equal" do
martini = Highrise::SubjectData.new({:id => 1, :value => "Martini", :subject_field_id => 3, :subject_field_label => "Cocktail"})
sling = Highrise::SubjectData.new({:id => 2, :value => "Martini", :subject_field_id => 4, :subject_field_label => "Vermouth Brands"})
martini.should_not==sling
end

it "Two the same subject datas are equal" do
martini = Highrise::SubjectData.new({:id => 1, :value => "Martini", :subject_field_id => 3, :subject_field_label => "Cocktail"})
another_martini = Highrise::SubjectData.new({:id => 2, :value => "Martini", :subject_field_id => 4, :subject_field_label => "Cocktail"})
martini.should==another_martini
end

end

0 comments on commit 4a3de3a

Please sign in to comment.