aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/library/set/sortedset/add_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/set/sortedset/add_spec.rb')
-rw-r--r--spec/ruby/library/set/sortedset/add_spec.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/spec/ruby/library/set/sortedset/add_spec.rb b/spec/ruby/library/set/sortedset/add_spec.rb
index bdc5c077d8..df291561a8 100644
--- a/spec/ruby/library/set/sortedset/add_spec.rb
+++ b/spec/ruby/library/set/sortedset/add_spec.rb
@@ -7,9 +7,15 @@ describe "SortedSet#add" do
it "takes only values which responds <=>" do
obj = mock('no_comparison_operator')
- obj.should_receive(:respond_to?).with(:<=>).and_return(false)
+ obj.stub!(:respond_to?).with(:<=>).and_return(false)
lambda { SortedSet["hello"].add(obj) }.should raise_error(ArgumentError)
end
+
+ it "raises on incompatible <=> comparison" do
+ # Use #to_a here as elements are sorted only when needed.
+ # Therefore the <=> incompatibility is only noticed on sorting.
+ lambda { SortedSet['1', '2'].add(3).to_a }.should raise_error(ArgumentError)
+ end
end
describe "SortedSet#add?" do