Skip to content

Instantly share code, notes, and snippets.

@kachick
Last active December 23, 2015 03:19
Show Gist options
  • Save kachick/6572946 to your computer and use it in GitHub Desktop.
Save kachick/6572946 to your computer and use it in GitHub Desktop.
behavior :array_uniq_on_dupulicated_elements, :shared => true do
it "returns a squashed array" do
verify([1, 1].send(@method)).is.eq([1])
end
end
describe "Array#uniq" do
context "when elements are duplicated" do
verify.behavior(:array_uniq_on_dupulicated_elements, :uniq)
before(:each) do
@array = [1, 1]
end
it "returns a new array" do
ret = @array.uniq
verify(ret).isnt(@array)
verify(ret).is.instance_of(Array)
end
end
end
describe "Array#uniq!" do
context "when elements are duplicated" do
verify.behavior(:array_uniq_on_dupulicated_elements, :uniq!)
before(:each) do
@array = [1, 1]
end
it "returns self" do
verify(@array.uniq!).is(@array)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment