spec/grab_spec.rb in grab-0.0.4 vs spec/grab_spec.rb in grab-0.1.0
- old
+ new
@@ -1,35 +1,35 @@
require 'grab'
-describe "#grab" do
+describe "#grab!" do
let(:h) { {a: 1, b: 2} }
it "fetches a single value from the hash" do
- h.grab(:a).should == [1]
+ h.grab!(:a).should == [1]
end
it "fetches multiple values from the hash" do
- h.grab(:a, :b).should == [1,2]
+ h.grab!(:a, :b).should == [1,2]
end
it "raises a KeyError for nonexistent keys" do
expect do
- h.grab(:a, :b, :c)
+ h.grab!(:a, :b, :c)
end.to raise_error(KeyError, "key not found: :c")
end
end
-describe "#values" do
+describe "#grab" do
let(:h) { {a: 1, b: 2} }
- it "retains the original behaviour of Hash#values" do
- h.values.should == [1,2]
+ it "requests a single value from the hash" do
+ h.grab(:a).should == [1]
end
- it "returns multiple values from the hash" do
- h.values(:a, :b).should == [1,2]
+ it "requests multiple values from the hash" do
+ h.grab(:a, :b).should == [1,2]
end
it "returns nil for nonexistent keys" do
- h.values(:a, :b, :c).should == [1,2,nil]
+ h.grab(:a, :b, :c).should == [1,2,nil]
end
end
\ No newline at end of file