Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

equality.feature

- Closes #15.
  • Loading branch information...
commit 7b52164afd0032a7739ff7e6e5109a72e0ed3db5 1 parent 6634a7c
@justinko justinko authored dchelimsky committed
Showing with 95 additions and 0 deletions.
  1. +95 −0 features/matchers/equality.feature
View
95 features/matchers/equality.feature
@@ -0,0 +1,95 @@
+Feature: equality matchers
+
+ RSpec equality comparison matchers.
+
+ Typically, if you are comparing values, "eq" and "eql" will
+ usually do the job. However, one thing to note is that "eq"
+ will perform type conversion, while "eql" will not.
+
+ If you need to compare equality of objects, "equal" is the
+ one you want.
+
+ Scenario: compare using eq (==)
+ Given a file named "compare_using_eq.rb" with:
+ """
+ require 'spec_helper'
+
+ describe "a string" do
+
+ let(:string) { "foo" }
+
+ it "is equal to another string of the same value" do
+ string.should eq("foo")
+ end
+
+ it "is not equal to another string of a different value" do
+ string.should_not eq("bar")
+ end
+
+ end
+
+ describe "an integer" do
+
+ let(:integer) { 5 }
+
+ it "is equal to the same value in float type" do
+ integer.should eq(5.0)
+ end
+
+ end
+ """
+ When I run "rspec compare_using_eq.rb"
+ Then the output should contain "3 examples, 0 failures"
+
+ Scenario: compare using eql (eql?)
+ Given a file named "compare_using_eql.rb" with:
+ """
+ require 'spec_helper'
+
+ describe "an integer" do
+
+ let(:integer) { 5 }
+
+ it "is equal to another integer of the same value" do
+ integer.should eql(5)
+ end
+
+ it "is not equal to another integer of a different value" do
+ integer.should_not eql(6)
+ end
+
+ it "is not equal to the same value in float type" do
+ integer.should_not eql(5.0)
+ end
+
+ end
+ """
+ When I run "rspec compare_using_eql.rb"
+ Then the output should contain "3 examples, 0 failures"
+
+ Scenario: compare using equal (equal?)
+ Given a file named "compare_using_equal.rb" with:
+ """
+ require 'spec_helper'
+
+ describe "a string" do
+
+ let(:string) { "foo" }
+
+ it "is equal to itself" do
+ string.should equal(string)
+ end
+
+ it "is not equal to another string of the same value" do
+ string.should_not equal("foo")
+ end
+
+ it "is not equal to another string of a different value" do
+ string.should_not equal("bar")
+ end
+
+ end
+ """
+ When I run "rspec compare_using_equal.rb"
+ Then the output should contain "3 examples, 0 failures"
+
Please sign in to comment.
Something went wrong with that request. Please try again.