Skip to content

Instantly share code, notes, and snippets.

@austinbv
Created November 27, 2011 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save austinbv/1397084 to your computer and use it in GitHub Desktop.
Save austinbv/1397084 to your computer and use it in GitHub Desktop.
def == (list)
(0..size).each do |position|
if set[position] != list.set[position]
return false
end
end
true
end
context "with a populated list" do
before(:each) do
@list = List.new
@list.add 1
@list.add 4
@list.add 5
@list.add 3
end
describe "when campairing to another list" do
it "retuns true when the lists are equal" do
list2 = List.new
list2.add 1
list2.add 4
list2.add 5
list2.add 3
@list.equals(list2).should be_true
(@list == list2).should be_true
(@list != list2).should be_false
end
it "returns false when the lists aren't equal" do
list2 = List.new
list2.add 2
list2.add 4
list2.add 6
list2.add 3
@list.equals(list2).should be_false
(@list == list2).should be_false
(@list != list2).should be_true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment