Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core/hash] Add specs for Hash #<=, #>=, #<, #> for Ruby 2.3 #160

Merged
merged 1 commit into from
Nov 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions core/hash/gt_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require File.expand_path('../../../spec_helper', __FILE__)

ruby_version_is "2.3" do
describe "Hash#>" do
before :each do
@hash = {a:1, b:2}
@bigger = {a:1, b:2, c:3}
@unrelated = {c:3, d:4}
@similar = {a:2, b:3}
end

it "returns false when receiver size is smaller than argument" do
(@hash > @bigger).should == false
(@unrelated > @bigger).should == false
end

it "returns false when receiver size is the same as argument" do
(@hash > @hash).should == false
(@hash > @unrelated).should == false
(@unrelated > @hash).should == false
end

it "returns true when argument is a subset of receiver" do
(@bigger > @hash).should == true
end

it "returns false when keys match but values don't" do
(@hash > @similar).should == false
(@similar > @hash).should == false
end
end
end
32 changes: 32 additions & 0 deletions core/hash/gte_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require File.expand_path('../../../spec_helper', __FILE__)

ruby_version_is "2.3" do
describe "Hash#>=" do
before :each do
@hash = {a:1, b:2}
@bigger = {a:1, b:2, c:3}
@unrelated = {c:3, d:4}
@similar = {a:2, b:3}
end

it "returns false when receiver size is smaller than argument" do
(@hash >= @bigger).should == false
(@unrelated >= @bigger).should == false
end

it "returns false when argument is not a subset or not equals to receiver" do
(@hash >= @unrelated).should == false
(@unrelated >= @hash).should == false
end

it "returns true when argument is a subset of receiver or equals to receiver" do
(@bigger >= @hash).should == true
(@hash >= @hash).should == true
end

it "returns false when keys match but values don't" do
(@hash >= @similar).should == false
(@similar >= @hash).should == false
end
end
end
32 changes: 32 additions & 0 deletions core/hash/lt_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require File.expand_path('../../../spec_helper', __FILE__)

ruby_version_is "2.3" do
describe "Hash#<" do
before :each do
@hash = {a:1, b:2}
@bigger = {a:1, b:2, c:3}
@unrelated = {c:3, d:4}
@similar = {a:2, b:3}
end

it "returns false when receiver size is larger than argument" do
(@bigger < @hash).should == false
(@bigger < @unrelated).should == false
end

it "returns false when receiver size is the same as argument" do
(@hash < @hash).should == false
(@hash < @unrelated).should == false
(@unrelated < @hash).should == false
end

it "returns true when receiver is a subset of argument" do
(@hash < @bigger).should == true
end

it "returns false when keys match but values don't" do
(@hash < @similar).should == false
(@similar < @hash).should == false
end
end
end
32 changes: 32 additions & 0 deletions core/hash/lte_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require File.expand_path('../../../spec_helper', __FILE__)

ruby_version_is "2.3" do
describe "Hash#<=" do
before :each do
@hash = {a:1, b:2}
@bigger = {a:1, b:2, c:3}
@unrelated = {c:3, d:4}
@similar = {a:2, b:3}
end

it "returns false when receiver size is larger than argument" do
(@bigger <= @hash).should == false
(@bigger <= @unrelated).should == false
end

it "returns false when receiver size is the same as argument" do
(@hash <= @unrelated).should == false
(@unrelated <= @hash).should == false
end

it "returns true when receiver is a subset of argument or equals to argument" do
(@hash <= @bigger).should == true
(@hash <= @hash).should == true
end

it "returns false when keys match but values don't" do
(@hash <= @similar).should == false
(@similar <= @hash).should == false
end
end
end