summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi/hash_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/optional/capi/hash_spec.rb')
-rw-r--r--spec/ruby/optional/capi/hash_spec.rb58
1 files changed, 28 insertions, 30 deletions
diff --git a/spec/ruby/optional/capi/hash_spec.rb b/spec/ruby/optional/capi/hash_spec.rb
index 08e03fcb26..842bc82b97 100644
--- a/spec/ruby/optional/capi/hash_spec.rb
+++ b/spec/ruby/optional/capi/hash_spec.rb
@@ -36,7 +36,7 @@ describe "C-API Hash function" do
obj = mock("rb_hash no to_int")
obj.should_receive(:hash).and_return(nil)
- -> { @s.rb_hash(obj) }.should raise_error(TypeError)
+ -> { @s.rb_hash(obj) }.should.raise(TypeError)
end
end
@@ -46,23 +46,21 @@ describe "C-API Hash function" do
end
it "creates a hash with no default proc" do
- @s.rb_hash_new {}.default_proc.should be_nil
+ @s.rb_hash_new {}.default_proc.should == nil
end
end
- ruby_version_is '3.2' do
- describe "rb_hash_new_capa" do
- it "returns a new hash" do
- @s.rb_hash_new_capa(3).should == {}
- end
+ describe "rb_hash_new_capa" do
+ it "returns a new hash" do
+ @s.rb_hash_new_capa(3).should == {}
+ end
- it "creates a hash with no default proc" do
- @s.rb_hash_new_capa(3) {}.default_proc.should be_nil
- end
+ it "creates a hash with no default proc" do
+ @s.rb_hash_new_capa(3) {}.default_proc.should == nil
+ end
- it "raises RuntimeError when negative index is provided" do
- -> { @s.rb_hash_new_capa(-1) }.should raise_error(RuntimeError, "st_table too big")
- end
+ it "raises RuntimeError when negative index is provided" do
+ -> { @s.rb_hash_new_capa(-1) }.should.raise(RuntimeError, "st_table too big")
end
end
@@ -79,13 +77,13 @@ describe "C-API Hash function" do
hsh = {}
dup = @s.rb_hash_dup(hsh)
dup.should == hsh
- dup.should_not equal(hsh)
+ dup.should_not.equal?(hsh)
end
end
describe "rb_hash_freeze" do
it "freezes the hash" do
- @s.rb_hash_freeze({}).frozen?.should be_true
+ @s.rb_hash_freeze({}).frozen?.should == true
end
end
@@ -98,13 +96,13 @@ describe "C-API Hash function" do
it "returns the default value if it exists" do
hsh = Hash.new(0)
@s.rb_hash_aref(hsh, :chunky).should == 0
- @s.rb_hash_aref_nil(hsh, :chunky).should be_false
+ @s.rb_hash_aref_nil(hsh, :chunky).should == false
end
it "returns nil if the key does not exist" do
hsh = { }
- @s.rb_hash_aref(hsh, :chunky).should be_nil
- @s.rb_hash_aref_nil(hsh, :chunky).should be_true
+ @s.rb_hash_aref(hsh, :chunky).should == nil
+ @s.rb_hash_aref_nil(hsh, :chunky).should == true
end
end
@@ -119,7 +117,7 @@ describe "C-API Hash function" do
describe "rb_hash_clear" do
it "returns self that cleared keys and values" do
hsh = { :key => 'value' }
- @s.rb_hash_clear(hsh).should equal(hsh)
+ @s.rb_hash_clear(hsh).should.equal?(hsh)
hsh.should == {}
end
end
@@ -140,7 +138,7 @@ describe "C-API Hash function" do
end
it "returns an Enumerator when no block is passed" do
- @s.rb_hash_delete_if({a: 1}).should be_an_instance_of(Enumerator)
+ @s.rb_hash_delete_if({a: 1}).should.instance_of?(Enumerator)
end
end
@@ -155,11 +153,11 @@ describe "C-API Hash function" do
it "raises a KeyError if the key is not found and default is set" do
@hsh.default = :d
- -> { @s.rb_hash_fetch(@hsh, :c) }.should raise_error(KeyError)
+ -> { @s.rb_hash_fetch(@hsh, :c) }.should.raise(KeyError)
end
it "raises a KeyError if the key is not found and no default is set" do
- -> { @s.rb_hash_fetch(@hsh, :c) }.should raise_error(KeyError)
+ -> { @s.rb_hash_fetch(@hsh, :c) }.should.raise(KeyError)
end
context "when key is not found" do
@@ -268,14 +266,14 @@ describe "C-API Hash function" do
it "does not return the default value if it exists" do
hsh = Hash.new(0)
- @s.rb_hash_lookup(hsh, :chunky).should be_nil
- @s.rb_hash_lookup_nil(hsh, :chunky).should be_true
+ @s.rb_hash_lookup(hsh, :chunky).should == nil
+ @s.rb_hash_lookup_nil(hsh, :chunky).should == true
end
it "returns nil if the key does not exist" do
hsh = { }
- @s.rb_hash_lookup(hsh, :chunky).should be_nil
- @s.rb_hash_lookup_nil(hsh, :chunky).should be_true
+ @s.rb_hash_lookup(hsh, :chunky).should == nil
+ @s.rb_hash_lookup_nil(hsh, :chunky).should == true
end
describe "rb_hash_lookup2" do
@@ -293,7 +291,7 @@ describe "C-API Hash function" do
it "returns undefined if that is the default value specified" do
hsh = Hash.new(0)
- @s.rb_hash_lookup2_default_undef(hsh, :chunky).should be_true
+ @s.rb_hash_lookup2_default_undef(hsh, :chunky).should == true
end
end
end
@@ -324,20 +322,20 @@ describe "C-API Hash function" do
end
it "raises a TypeError if the argument does not respond to #to_hash" do
- -> { @s.rb_Hash(42) }.should raise_error(TypeError)
+ -> { @s.rb_Hash(42) }.should.raise(TypeError)
end
it "raises a TypeError if #to_hash does not return a hash" do
h = BasicObject.new
def h.to_hash; 42; end
- -> { @s.rb_Hash(h) }.should raise_error(TypeError)
+ -> { @s.rb_Hash(h) }.should.raise(TypeError)
end
end
describe "hash code functions" do
it "computes a deterministic number" do
hash_code = @s.compute_a_hash_code(53)
- hash_code.should be_an_instance_of(Integer)
+ hash_code.should.instance_of?(Integer)
hash_code.should == @s.compute_a_hash_code(53)
@s.compute_a_hash_code(90).should == @s.compute_a_hash_code(90)
end