summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/matchers
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2021-03-27 13:02:38 +0100
committerBenoit Daloze <eregontp@gmail.com>2021-03-27 13:02:38 +0100
commit44736a6b7a2b3475db2d05187f33e3c1a7b4b4e5 (patch)
tree4cb679a8742121782a50e72e01160d19f479f9a6 /spec/mspec/spec/matchers
parent31ae931e166825450dcc16d470553e67281951a2 (diff)
Update to ruby/mspec@d1adf59
Diffstat (limited to 'spec/mspec/spec/matchers')
-rw-r--r--spec/mspec/spec/matchers/base_spec.rb140
-rw-r--r--spec/mspec/spec/matchers/be_an_instance_of_spec.rb22
-rw-r--r--spec/mspec/spec/matchers/be_ancestor_of_spec.rb10
-rw-r--r--spec/mspec/spec/matchers/be_close_spec.rb24
-rw-r--r--spec/mspec/spec/matchers/be_computed_by_spec.rb14
-rw-r--r--spec/mspec/spec/matchers/be_empty_spec.rb10
-rw-r--r--spec/mspec/spec/matchers/be_false_spec.rb16
-rw-r--r--spec/mspec/spec/matchers/be_kind_of_spec.rb22
-rw-r--r--spec/mspec/spec/matchers/be_nan_spec.rb12
-rw-r--r--spec/mspec/spec/matchers/be_nil_spec.rb14
-rw-r--r--spec/mspec/spec/matchers/be_true_or_false_spec.rb8
-rw-r--r--spec/mspec/spec/matchers/be_true_spec.rb16
-rw-r--r--spec/mspec/spec/matchers/block_caller_spec.rb6
-rw-r--r--spec/mspec/spec/matchers/complain_spec.rb43
-rw-r--r--spec/mspec/spec/matchers/eql_spec.rb22
-rw-r--r--spec/mspec/spec/matchers/equal_element_spec.rb78
-rw-r--r--spec/mspec/spec/matchers/equal_spec.rb20
-rw-r--r--spec/mspec/spec/matchers/have_class_variable_spec.rb18
-rw-r--r--spec/mspec/spec/matchers/have_constant_spec.rb14
-rw-r--r--spec/mspec/spec/matchers/have_instance_method_spec.rb20
-rw-r--r--spec/mspec/spec/matchers/have_instance_variable_spec.rb18
-rw-r--r--spec/mspec/spec/matchers/have_method_spec.rb24
-rw-r--r--spec/mspec/spec/matchers/have_private_instance_method_spec.rb20
-rw-r--r--spec/mspec/spec/matchers/have_private_method_spec.rb16
-rw-r--r--spec/mspec/spec/matchers/have_protected_instance_method_spec.rb20
-rw-r--r--spec/mspec/spec/matchers/have_public_instance_method_spec.rb20
-rw-r--r--spec/mspec/spec/matchers/have_singleton_method_spec.rb16
-rw-r--r--spec/mspec/spec/matchers/include_any_of_spec.rb26
-rw-r--r--spec/mspec/spec/matchers/include_spec.rb22
-rw-r--r--spec/mspec/spec/matchers/infinity_spec.rb18
-rw-r--r--spec/mspec/spec/matchers/match_yaml_spec.rb22
-rw-r--r--spec/mspec/spec/matchers/output_spec.rb48
-rw-r--r--spec/mspec/spec/matchers/output_to_fd_spec.rb30
-rw-r--r--spec/mspec/spec/matchers/raise_error_spec.rb90
-rw-r--r--spec/mspec/spec/matchers/respond_to_spec.rb26
-rw-r--r--spec/mspec/spec/matchers/signed_zero_spec.rb18
36 files changed, 501 insertions, 462 deletions
diff --git a/spec/mspec/spec/matchers/base_spec.rb b/spec/mspec/spec/matchers/base_spec.rb
index 762822bf09..6b5a3fbd72 100644
--- a/spec/mspec/spec/matchers/base_spec.rb
+++ b/spec/mspec/spec/matchers/base_spec.rb
@@ -3,11 +3,11 @@ require 'mspec/expectations/expectations'
require 'mspec/matchers'
require 'time'
-describe SpecPositiveOperatorMatcher, "== operator" do
+RSpec.describe SpecPositiveOperatorMatcher, "== operator" do
it "provides a failure message that 'Expected x to equal y'" do
- lambda {
+ expect {
SpecPositiveOperatorMatcher.new(1) == 2
- }.should raise_error(SpecExpectationNotMetError, "Expected 1 == 2\nto be truthy but was false")
+ }.to raise_error(SpecExpectationNotMetError, "Expected 1 == 2\nto be truthy but was false")
end
it "does not raise an exception when == returns true" do
@@ -15,11 +15,11 @@ describe SpecPositiveOperatorMatcher, "== operator" do
end
end
-describe SpecPositiveOperatorMatcher, "=~ operator" do
+RSpec.describe SpecPositiveOperatorMatcher, "=~ operator" do
it "provides a failure message that 'Expected \"x\" to match y'" do
- lambda {
+ expect {
SpecPositiveOperatorMatcher.new('real') =~ /fake/
- }.should raise_error(SpecExpectationNotMetError, "Expected \"real\" =~ /fake/\nto be truthy but was nil")
+ }.to raise_error(SpecExpectationNotMetError, "Expected \"real\" =~ /fake/\nto be truthy but was nil")
end
it "does not raise an exception when =~ returns true" do
@@ -27,11 +27,11 @@ describe SpecPositiveOperatorMatcher, "=~ operator" do
end
end
-describe SpecPositiveOperatorMatcher, "> operator" do
+RSpec.describe SpecPositiveOperatorMatcher, "> operator" do
it "provides a failure message that 'Expected x to be greater than y'" do
- lambda {
+ expect {
SpecPositiveOperatorMatcher.new(4) > 5
- }.should raise_error(SpecExpectationNotMetError, "Expected 4 > 5\nto be truthy but was false")
+ }.to raise_error(SpecExpectationNotMetError, "Expected 4 > 5\nto be truthy but was false")
end
it "does not raise an exception when > returns true" do
@@ -39,11 +39,11 @@ describe SpecPositiveOperatorMatcher, "> operator" do
end
end
-describe SpecPositiveOperatorMatcher, ">= operator" do
+RSpec.describe SpecPositiveOperatorMatcher, ">= operator" do
it "provides a failure message that 'Expected x to be greater than or equal to y'" do
- lambda {
+ expect {
SpecPositiveOperatorMatcher.new(4) >= 5
- }.should raise_error(SpecExpectationNotMetError, "Expected 4 >= 5\nto be truthy but was false")
+ }.to raise_error(SpecExpectationNotMetError, "Expected 4 >= 5\nto be truthy but was false")
end
it "does not raise an exception when > returns true" do
@@ -52,11 +52,11 @@ describe SpecPositiveOperatorMatcher, ">= operator" do
end
end
-describe SpecPositiveOperatorMatcher, "< operator" do
+RSpec.describe SpecPositiveOperatorMatcher, "< operator" do
it "provides a failure message that 'Expected x to be less than y'" do
- lambda {
+ expect {
SpecPositiveOperatorMatcher.new(5) < 4
- }.should raise_error(SpecExpectationNotMetError, "Expected 5 < 4\nto be truthy but was false")
+ }.to raise_error(SpecExpectationNotMetError, "Expected 5 < 4\nto be truthy but was false")
end
it "does not raise an exception when < returns true" do
@@ -64,11 +64,11 @@ describe SpecPositiveOperatorMatcher, "< operator" do
end
end
-describe SpecPositiveOperatorMatcher, "<= operator" do
+RSpec.describe SpecPositiveOperatorMatcher, "<= operator" do
it "provides a failure message that 'Expected x to be less than or equal to y'" do
- lambda {
+ expect {
SpecPositiveOperatorMatcher.new(5) <= 4
- }.should raise_error(SpecExpectationNotMetError, "Expected 5 <= 4\nto be truthy but was false")
+ }.to raise_error(SpecExpectationNotMetError, "Expected 5 <= 4\nto be truthy but was false")
end
it "does not raise an exception when < returns true" do
@@ -77,7 +77,7 @@ describe SpecPositiveOperatorMatcher, "<= operator" do
end
end
-describe SpecPositiveOperatorMatcher, "arbitrary predicates" do
+RSpec.describe SpecPositiveOperatorMatcher, "arbitrary predicates" do
it "do not raise an exception when the predicate is truthy" do
SpecPositiveOperatorMatcher.new(2).eql?(2)
SpecPositiveOperatorMatcher.new(2).equal?(2)
@@ -89,31 +89,31 @@ describe SpecPositiveOperatorMatcher, "arbitrary predicates" do
end
it "provide a failure message when the predicate returns a falsy value" do
- lambda {
+ expect {
SpecPositiveOperatorMatcher.new(2).eql?(3)
- }.should raise_error(SpecExpectationNotMetError, "Expected 2.eql? 3\nto be truthy but was false")
- lambda {
+ }.to raise_error(SpecExpectationNotMetError, "Expected 2.eql? 3\nto be truthy but was false")
+ expect {
SpecPositiveOperatorMatcher.new(2).equal?(3)
- }.should raise_error(SpecExpectationNotMetError, "Expected 2.equal? 3\nto be truthy but was false")
- lambda {
+ }.to raise_error(SpecExpectationNotMetError, "Expected 2.equal? 3\nto be truthy but was false")
+ expect {
SpecPositiveOperatorMatcher.new([1, 2, 3]).include?(4)
- }.should raise_error(SpecExpectationNotMetError, "Expected [1, 2, 3].include? 4\nto be truthy but was false")
- lambda {
+ }.to raise_error(SpecExpectationNotMetError, "Expected [1, 2, 3].include? 4\nto be truthy but was false")
+ expect {
SpecPositiveOperatorMatcher.new("abc").start_with?("de")
- }.should raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"de\"\nto be truthy but was false")
- lambda {
+ }.to raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"de\"\nto be truthy but was false")
+ expect {
SpecPositiveOperatorMatcher.new("abc").start_with?("d", "e")
- }.should raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"d\", \"e\"\nto be truthy but was false")
- lambda {
+ }.to raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"d\", \"e\"\nto be truthy but was false")
+ expect {
SpecPositiveOperatorMatcher.new(2).odd?
- }.should raise_error(SpecExpectationNotMetError, "Expected 2.odd?\nto be truthy but was false")
- lambda {
+ }.to raise_error(SpecExpectationNotMetError, "Expected 2.odd?\nto be truthy but was false")
+ expect {
SpecPositiveOperatorMatcher.new([1, 3]).any? { |e| e.even? }
- }.should raise_error(SpecExpectationNotMetError, "Expected [1, 3].any? { ... }\nto be truthy but was false")
+ }.to raise_error(SpecExpectationNotMetError, "Expected [1, 3].any? { ... }\nto be truthy but was false")
end
end
-describe SpecNegativeOperatorMatcher, "arbitrary predicates" do
+RSpec.describe SpecNegativeOperatorMatcher, "arbitrary predicates" do
it "do not raise an exception when the predicate returns a falsy value" do
SpecNegativeOperatorMatcher.new(2).eql?(3)
SpecNegativeOperatorMatcher.new(2).equal?(3)
@@ -125,35 +125,35 @@ describe SpecNegativeOperatorMatcher, "arbitrary predicates" do
end
it "provide a failure message when the predicate returns a truthy value" do
- lambda {
+ expect {
SpecNegativeOperatorMatcher.new(2).eql?(2)
- }.should raise_error(SpecExpectationNotMetError, "Expected 2.eql? 2\nto be falsy but was true")
- lambda {
+ }.to raise_error(SpecExpectationNotMetError, "Expected 2.eql? 2\nto be falsy but was true")
+ expect {
SpecNegativeOperatorMatcher.new(2).equal?(2)
- }.should raise_error(SpecExpectationNotMetError, "Expected 2.equal? 2\nto be falsy but was true")
- lambda {
+ }.to raise_error(SpecExpectationNotMetError, "Expected 2.equal? 2\nto be falsy but was true")
+ expect {
SpecNegativeOperatorMatcher.new([1, 2, 3]).include?(2)
- }.should raise_error(SpecExpectationNotMetError, "Expected [1, 2, 3].include? 2\nto be falsy but was true")
- lambda {
+ }.to raise_error(SpecExpectationNotMetError, "Expected [1, 2, 3].include? 2\nto be falsy but was true")
+ expect {
SpecNegativeOperatorMatcher.new("abc").start_with?("ab")
- }.should raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"ab\"\nto be falsy but was true")
- lambda {
+ }.to raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"ab\"\nto be falsy but was true")
+ expect {
SpecNegativeOperatorMatcher.new("abc").start_with?("d", "a")
- }.should raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"d\", \"a\"\nto be falsy but was true")
- lambda {
+ }.to raise_error(SpecExpectationNotMetError, "Expected \"abc\".start_with? \"d\", \"a\"\nto be falsy but was true")
+ expect {
SpecNegativeOperatorMatcher.new(3).odd?
- }.should raise_error(SpecExpectationNotMetError, "Expected 3.odd?\nto be falsy but was true")
- lambda {
+ }.to raise_error(SpecExpectationNotMetError, "Expected 3.odd?\nto be falsy but was true")
+ expect {
SpecNegativeOperatorMatcher.new([1, 2]).any? { |e| e.even? }
- }.should raise_error(SpecExpectationNotMetError, "Expected [1, 2].any? { ... }\nto be falsy but was true")
+ }.to raise_error(SpecExpectationNotMetError, "Expected [1, 2].any? { ... }\nto be falsy but was true")
end
end
-describe SpecNegativeOperatorMatcher, "== operator" do
+RSpec.describe SpecNegativeOperatorMatcher, "== operator" do
it "provides a failure message that 'Expected x not to equal y'" do
- lambda {
+ expect {
SpecNegativeOperatorMatcher.new(1) == 1
- }.should raise_error(SpecExpectationNotMetError, "Expected 1 == 1\nto be falsy but was true")
+ }.to raise_error(SpecExpectationNotMetError, "Expected 1 == 1\nto be falsy but was true")
end
it "does not raise an exception when == returns false" do
@@ -161,11 +161,11 @@ describe SpecNegativeOperatorMatcher, "== operator" do
end
end
-describe SpecNegativeOperatorMatcher, "=~ operator" do
+RSpec.describe SpecNegativeOperatorMatcher, "=~ operator" do
it "provides a failure message that 'Expected \"x\" not to match /y/'" do
- lambda {
+ expect {
SpecNegativeOperatorMatcher.new('real') =~ /real/
- }.should raise_error(SpecExpectationNotMetError, "Expected \"real\" =~ /real/\nto be falsy but was 0")
+ }.to raise_error(SpecExpectationNotMetError, "Expected \"real\" =~ /real/\nto be falsy but was 0")
end
it "does not raise an exception when =~ returns false" do
@@ -173,11 +173,11 @@ describe SpecNegativeOperatorMatcher, "=~ operator" do
end
end
-describe SpecNegativeOperatorMatcher, "< operator" do
+RSpec.describe SpecNegativeOperatorMatcher, "< operator" do
it "provides a failure message that 'Expected x not to be less than y'" do
- lambda {
+ expect {
SpecNegativeOperatorMatcher.new(4) < 5
- }.should raise_error(SpecExpectationNotMetError, "Expected 4 < 5\nto be falsy but was true")
+ }.to raise_error(SpecExpectationNotMetError, "Expected 4 < 5\nto be falsy but was true")
end
it "does not raise an exception when < returns false" do
@@ -185,14 +185,14 @@ describe SpecNegativeOperatorMatcher, "< operator" do
end
end
-describe SpecNegativeOperatorMatcher, "<= operator" do
+RSpec.describe SpecNegativeOperatorMatcher, "<= operator" do
it "provides a failure message that 'Expected x not to be less than or equal to y'" do
- lambda {
+ expect {
SpecNegativeOperatorMatcher.new(4) <= 5
- }.should raise_error(SpecExpectationNotMetError, "Expected 4 <= 5\nto be falsy but was true")
- lambda {
+ }.to raise_error(SpecExpectationNotMetError, "Expected 4 <= 5\nto be falsy but was true")
+ expect {
SpecNegativeOperatorMatcher.new(5) <= 5
- }.should raise_error(SpecExpectationNotMetError, "Expected 5 <= 5\nto be falsy but was true")
+ }.to raise_error(SpecExpectationNotMetError, "Expected 5 <= 5\nto be falsy but was true")
end
it "does not raise an exception when <= returns false" do
@@ -200,11 +200,11 @@ describe SpecNegativeOperatorMatcher, "<= operator" do
end
end
-describe SpecNegativeOperatorMatcher, "> operator" do
+RSpec.describe SpecNegativeOperatorMatcher, "> operator" do
it "provides a failure message that 'Expected x not to be greater than y'" do
- lambda {
+ expect {
SpecNegativeOperatorMatcher.new(5) > 4
- }.should raise_error(SpecExpectationNotMetError, "Expected 5 > 4\nto be falsy but was true")
+ }.to raise_error(SpecExpectationNotMetError, "Expected 5 > 4\nto be falsy but was true")
end
it "does not raise an exception when > returns false" do
@@ -212,14 +212,14 @@ describe SpecNegativeOperatorMatcher, "> operator" do
end
end
-describe SpecNegativeOperatorMatcher, ">= operator" do
+RSpec.describe SpecNegativeOperatorMatcher, ">= operator" do
it "provides a failure message that 'Expected x not to be greater than or equal to y'" do
- lambda {
+ expect {
SpecNegativeOperatorMatcher.new(5) >= 4
- }.should raise_error(SpecExpectationNotMetError, "Expected 5 >= 4\nto be falsy but was true")
- lambda {
+ }.to raise_error(SpecExpectationNotMetError, "Expected 5 >= 4\nto be falsy but was true")
+ expect {
SpecNegativeOperatorMatcher.new(5) >= 5
- }.should raise_error(SpecExpectationNotMetError, "Expected 5 >= 5\nto be falsy but was true")
+ }.to raise_error(SpecExpectationNotMetError, "Expected 5 >= 5\nto be falsy but was true")
end
it "does not raise an exception when >= returns false" do
diff --git a/spec/mspec/spec/matchers/be_an_instance_of_spec.rb b/spec/mspec/spec/matchers/be_an_instance_of_spec.rb
index 7f2126df7d..7c74249d24 100644
--- a/spec/mspec/spec/matchers/be_an_instance_of_spec.rb
+++ b/spec/mspec/spec/matchers/be_an_instance_of_spec.rb
@@ -13,38 +13,38 @@ module BeAnInOfSpecs
end
end
-describe BeAnInstanceOfMatcher do
+RSpec.describe BeAnInstanceOfMatcher do
it "matches when actual is an instance_of? expected" do
a = BeAnInOfSpecs::A.new
- BeAnInstanceOfMatcher.new(BeAnInOfSpecs::A).matches?(a).should be_true
+ expect(BeAnInstanceOfMatcher.new(BeAnInOfSpecs::A).matches?(a)).to be_truthy
b = BeAnInOfSpecs::B.new
- BeAnInstanceOfMatcher.new(BeAnInOfSpecs::B).matches?(b).should be_true
+ expect(BeAnInstanceOfMatcher.new(BeAnInOfSpecs::B).matches?(b)).to be_truthy
end
it "does not match when actual is not an instance_of? expected" do
a = BeAnInOfSpecs::A.new
- BeAnInstanceOfMatcher.new(BeAnInOfSpecs::B).matches?(a).should be_false
+ expect(BeAnInstanceOfMatcher.new(BeAnInOfSpecs::B).matches?(a)).to be_falsey
b = BeAnInOfSpecs::B.new
- BeAnInstanceOfMatcher.new(BeAnInOfSpecs::A).matches?(b).should be_false
+ expect(BeAnInstanceOfMatcher.new(BeAnInOfSpecs::A).matches?(b)).to be_falsey
c = BeAnInOfSpecs::C.new
- BeAnInstanceOfMatcher.new(BeAnInOfSpecs::A).matches?(c).should be_false
- BeAnInstanceOfMatcher.new(BeAnInOfSpecs::B).matches?(c).should be_false
+ expect(BeAnInstanceOfMatcher.new(BeAnInOfSpecs::A).matches?(c)).to be_falsey
+ expect(BeAnInstanceOfMatcher.new(BeAnInOfSpecs::B).matches?(c)).to be_falsey
end
it "provides a useful failure message" do
matcher = BeAnInstanceOfMatcher.new(Numeric)
matcher.matches?("string")
- matcher.failure_message.should == [
- "Expected \"string\" (String)", "to be an instance of Numeric"]
+ expect(matcher.failure_message).to eq([
+ "Expected \"string\" (String)", "to be an instance of Numeric"])
end
it "provides a useful negative failure message" do
matcher = BeAnInstanceOfMatcher.new(Numeric)
matcher.matches?(4.0)
- matcher.negative_failure_message.should == [
- "Expected 4.0 (Float)", "not to be an instance of Numeric"]
+ expect(matcher.negative_failure_message).to eq([
+ "Expected 4.0 (Float)", "not to be an instance of Numeric"])
end
end
diff --git a/spec/mspec/spec/matchers/be_ancestor_of_spec.rb b/spec/mspec/spec/matchers/be_ancestor_of_spec.rb
index c6bd1a26c7..abc05e0f7a 100644
--- a/spec/mspec/spec/matchers/be_ancestor_of_spec.rb
+++ b/spec/mspec/spec/matchers/be_ancestor_of_spec.rb
@@ -5,24 +5,24 @@ require 'mspec/matchers'
class Parent; end
class Child < Parent; end
-describe BeAncestorOfMatcher do
+RSpec.describe BeAncestorOfMatcher do
it "matches when actual is an ancestor of expected" do
- BeAncestorOfMatcher.new(Child).matches?(Parent).should == true
+ expect(BeAncestorOfMatcher.new(Child).matches?(Parent)).to eq(true)
end
it "does not match when actual is not an ancestor of expected" do
- BeAncestorOfMatcher.new(Parent).matches?(Child).should == false
+ expect(BeAncestorOfMatcher.new(Parent).matches?(Child)).to eq(false)
end
it "provides a useful failure message" do
matcher = BeAncestorOfMatcher.new(Parent)
matcher.matches?(Child)
- matcher.failure_message.should == ["Expected Child", "to be an ancestor of Parent"]
+ expect(matcher.failure_message).to eq(["Expected Child", "to be an ancestor of Parent"])
end
it "provides a useful negative failure message" do
matcher = BeAncestorOfMatcher.new(Child)
matcher.matches?(Parent)
- matcher.negative_failure_message.should == ["Expected Parent", "not to be an ancestor of Child"]
+ expect(matcher.negative_failure_message).to eq(["Expected Parent", "not to be an ancestor of Child"])
end
end
diff --git a/spec/mspec/spec/matchers/be_close_spec.rb b/spec/mspec/spec/matchers/be_close_spec.rb
index 6edff98e4a..dfd4f4ddbb 100644
--- a/spec/mspec/spec/matchers/be_close_spec.rb
+++ b/spec/mspec/spec/matchers/be_close_spec.rb
@@ -3,46 +3,46 @@ require 'mspec/expectations/expectations'
require 'mspec/matchers'
# Adapted from RSpec 1.0.8
-describe BeCloseMatcher do
+RSpec.describe BeCloseMatcher do
it "matches when actual == expected" do
- BeCloseMatcher.new(5.0, 0.5).matches?(5.0).should == true
+ expect(BeCloseMatcher.new(5.0, 0.5).matches?(5.0)).to eq(true)
end
it "matches when actual < (expected + tolerance)" do
- BeCloseMatcher.new(5.0, 0.5).matches?(5.49).should == true
+ expect(BeCloseMatcher.new(5.0, 0.5).matches?(5.49)).to eq(true)
end
it "matches when actual > (expected - tolerance)" do
- BeCloseMatcher.new(5.0, 0.5).matches?(4.51).should == true
+ expect(BeCloseMatcher.new(5.0, 0.5).matches?(4.51)).to eq(true)
end
it "matches when actual == (expected + tolerance)" do
- BeCloseMatcher.new(5.0, 0.5).matches?(5.5).should == true
- BeCloseMatcher.new(3, 2).matches?(5).should == true
+ expect(BeCloseMatcher.new(5.0, 0.5).matches?(5.5)).to eq(true)
+ expect(BeCloseMatcher.new(3, 2).matches?(5)).to eq(true)
end
it "matches when actual == (expected - tolerance)" do
- BeCloseMatcher.new(5.0, 0.5).matches?(4.5).should == true
- BeCloseMatcher.new(3, 2).matches?(1).should == true
+ expect(BeCloseMatcher.new(5.0, 0.5).matches?(4.5)).to eq(true)
+ expect(BeCloseMatcher.new(3, 2).matches?(1)).to eq(true)
end
it "does not match when actual < (expected - tolerance)" do
- BeCloseMatcher.new(5.0, 0.5).matches?(4.49).should == false
+ expect(BeCloseMatcher.new(5.0, 0.5).matches?(4.49)).to eq(false)
end
it "does not match when actual > (expected + tolerance)" do
- BeCloseMatcher.new(5.0, 0.5).matches?(5.51).should == false
+ expect(BeCloseMatcher.new(5.0, 0.5).matches?(5.51)).to eq(false)
end
it "provides a useful failure message" do
matcher = BeCloseMatcher.new(5.0, 0.5)
matcher.matches?(6.5)
- matcher.failure_message.should == ["Expected 6.5", "to be within 5.0 +/- 0.5"]
+ expect(matcher.failure_message).to eq(["Expected 6.5", "to be within 5.0 +/- 0.5"])
end
it "provides a useful negative failure message" do
matcher = BeCloseMatcher.new(5.0, 0.5)
matcher.matches?(4.9)
- matcher.negative_failure_message.should == ["Expected 4.9", "not to be within 5.0 +/- 0.5"]
+ expect(matcher.negative_failure_message).to eq(["Expected 4.9", "not to be within 5.0 +/- 0.5"])
end
end
diff --git a/spec/mspec/spec/matchers/be_computed_by_spec.rb b/spec/mspec/spec/matchers/be_computed_by_spec.rb
index 9833e211a4..f73861a576 100644
--- a/spec/mspec/spec/matchers/be_computed_by_spec.rb
+++ b/spec/mspec/spec/matchers/be_computed_by_spec.rb
@@ -1,35 +1,35 @@
require 'spec_helper'
require 'mspec/matchers'
-describe BeComputedByMatcher do
+RSpec.describe BeComputedByMatcher do
it "matches when all entries in the Array compute" do
array = [ [65, "A"],
[90, "Z"] ]
- BeComputedByMatcher.new(:chr).matches?(array).should be_true
+ expect(BeComputedByMatcher.new(:chr).matches?(array)).to be_truthy
end
it "matches when all entries in the Array with arguments compute" do
array = [ [1, 2, 3],
[2, 4, 6] ]
- BeComputedByMatcher.new(:+).matches?(array).should be_true
+ expect(BeComputedByMatcher.new(:+).matches?(array)).to be_truthy
end
it "does not match when any entry in the Array does not compute" do
array = [ [65, "A" ],
[91, "Z" ] ]
- BeComputedByMatcher.new(:chr).matches?(array).should be_false
+ expect(BeComputedByMatcher.new(:chr).matches?(array)).to be_falsey
end
it "accepts an argument list to apply to each method call" do
array = [ [65, "1000001" ],
[90, "1011010" ] ]
- BeComputedByMatcher.new(:to_s, 2).matches?(array).should be_true
+ expect(BeComputedByMatcher.new(:to_s, 2).matches?(array)).to be_truthy
end
it "does not match when any entry in the Array with arguments does not compute" do
array = [ [1, 2, 3],
[2, 4, 7] ]
- BeComputedByMatcher.new(:+).matches?(array).should be_false
+ expect(BeComputedByMatcher.new(:+).matches?(array)).to be_falsey
end
it "provides a useful failure message" do
@@ -37,6 +37,6 @@ describe BeComputedByMatcher do
[91, "Z" ] ]
matcher = BeComputedByMatcher.new(:chr)
matcher.matches?(array)
- matcher.failure_message.should == ["Expected \"Z\"", "to be computed by 91.chr (computed \"[\" instead)"]
+ expect(matcher.failure_message).to eq(["Expected \"Z\"", "to be computed by 91.chr (computed \"[\" instead)"])
end
end
diff --git a/spec/mspec/spec/matchers/be_empty_spec.rb b/spec/mspec/spec/matchers/be_empty_spec.rb
index cb8663f5ee..30678fe85f 100644
--- a/spec/mspec/spec/matchers/be_empty_spec.rb
+++ b/spec/mspec/spec/matchers/be_empty_spec.rb
@@ -2,25 +2,25 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe BeEmptyMatcher do
+RSpec.describe BeEmptyMatcher do
it "matches when actual is empty" do
- BeEmptyMatcher.new.matches?("").should == true
+ expect(BeEmptyMatcher.new.matches?("")).to eq(true)
end
it "does not match when actual is not empty" do
- BeEmptyMatcher.new.matches?([10]).should == false
+ expect(BeEmptyMatcher.new.matches?([10])).to eq(false)
end
it "provides a useful failure message" do
matcher = BeEmptyMatcher.new
matcher.matches?("not empty string")
- matcher.failure_message.should == ["Expected \"not empty string\"", "to be empty"]
+ expect(matcher.failure_message).to eq(["Expected \"not empty string\"", "to be empty"])
end
it "provides a useful negative failure message" do
matcher = BeEmptyMatcher.new
matcher.matches?("")
- matcher.negative_failure_message.should == ["Expected \"\"", "not to be empty"]
+ expect(matcher.negative_failure_message).to eq(["Expected \"\"", "not to be empty"])
end
end
diff --git a/spec/mspec/spec/matchers/be_false_spec.rb b/spec/mspec/spec/matchers/be_false_spec.rb
index 31afd24ebc..46d7253220 100644
--- a/spec/mspec/spec/matchers/be_false_spec.rb
+++ b/spec/mspec/spec/matchers/be_false_spec.rb
@@ -2,27 +2,27 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe BeFalseMatcher do
+RSpec.describe BeFalseMatcher do
it "matches when actual is false" do
- BeFalseMatcher.new.matches?(false).should == true
+ expect(BeFalseMatcher.new.matches?(false)).to eq(true)
end
it "does not match when actual is not false" do
- BeFalseMatcher.new.matches?("").should == false
- BeFalseMatcher.new.matches?(true).should == false
- BeFalseMatcher.new.matches?(nil).should == false
- BeFalseMatcher.new.matches?(0).should == false
+ expect(BeFalseMatcher.new.matches?("")).to eq(false)
+ expect(BeFalseMatcher.new.matches?(true)).to eq(false)
+ expect(BeFalseMatcher.new.matches?(nil)).to eq(false)
+ expect(BeFalseMatcher.new.matches?(0)).to eq(false)
end
it "provides a useful failure message" do
matcher = BeFalseMatcher.new
matcher.matches?("some string")
- matcher.failure_message.should == ["Expected \"some string\"", "to be false"]
+ expect(matcher.failure_message).to eq(["Expected \"some string\"", "to be false"])
end
it "provides a useful negative failure message" do
matcher = BeFalseMatcher.new
matcher.matches?(false)
- matcher.negative_failure_message.should == ["Expected false", "not to be false"]
+ expect(matcher.negative_failure_message).to eq(["Expected false", "not to be false"])
end
end
diff --git a/spec/mspec/spec/matchers/be_kind_of_spec.rb b/spec/mspec/spec/matchers/be_kind_of_spec.rb
index 7c4a59f7b9..1e19058411 100644
--- a/spec/mspec/spec/matchers/be_kind_of_spec.rb
+++ b/spec/mspec/spec/matchers/be_kind_of_spec.rb
@@ -2,30 +2,30 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe BeKindOfMatcher do
+RSpec.describe BeKindOfMatcher do
it "matches when actual is a kind_of? expected" do
- BeKindOfMatcher.new(Numeric).matches?(1).should == true
- BeKindOfMatcher.new(Integer).matches?(2).should == true
- BeKindOfMatcher.new(Regexp).matches?(/m/).should == true
+ expect(BeKindOfMatcher.new(Numeric).matches?(1)).to eq(true)
+ expect(BeKindOfMatcher.new(Integer).matches?(2)).to eq(true)
+ expect(BeKindOfMatcher.new(Regexp).matches?(/m/)).to eq(true)
end
it "does not match when actual is not a kind_of? expected" do
- BeKindOfMatcher.new(Integer).matches?(1.5).should == false
- BeKindOfMatcher.new(String).matches?(:a).should == false
- BeKindOfMatcher.new(Hash).matches?([]).should == false
+ expect(BeKindOfMatcher.new(Integer).matches?(1.5)).to eq(false)
+ expect(BeKindOfMatcher.new(String).matches?(:a)).to eq(false)
+ expect(BeKindOfMatcher.new(Hash).matches?([])).to eq(false)
end
it "provides a useful failure message" do
matcher = BeKindOfMatcher.new(Numeric)
matcher.matches?('string')
- matcher.failure_message.should == [
- "Expected \"string\" (String)", "to be kind of Numeric"]
+ expect(matcher.failure_message).to eq([
+ "Expected \"string\" (String)", "to be kind of Numeric"])
end
it "provides a useful negative failure message" do
matcher = BeKindOfMatcher.new(Numeric)
matcher.matches?(4.0)
- matcher.negative_failure_message.should == [
- "Expected 4.0 (Float)", "not to be kind of Numeric"]
+ expect(matcher.negative_failure_message).to eq([
+ "Expected 4.0 (Float)", "not to be kind of Numeric"])
end
end
diff --git a/spec/mspec/spec/matchers/be_nan_spec.rb b/spec/mspec/spec/matchers/be_nan_spec.rb
index 2062763a92..baa7447943 100644
--- a/spec/mspec/spec/matchers/be_nan_spec.rb
+++ b/spec/mspec/spec/matchers/be_nan_spec.rb
@@ -4,25 +4,25 @@ require 'mspec/guards'
require 'mspec/helpers'
require 'mspec/matchers'
-describe BeNaNMatcher do
+RSpec.describe BeNaNMatcher do
it "matches when actual is NaN" do
- BeNaNMatcher.new.matches?(nan_value).should == true
+ expect(BeNaNMatcher.new.matches?(nan_value)).to eq(true)
end
it "does not match when actual is not NaN" do
- BeNaNMatcher.new.matches?(1.0).should == false
- BeNaNMatcher.new.matches?(0).should == false
+ expect(BeNaNMatcher.new.matches?(1.0)).to eq(false)
+ expect(BeNaNMatcher.new.matches?(0)).to eq(false)
end
it "provides a useful failure message" do
matcher = BeNaNMatcher.new
matcher.matches?(0)
- matcher.failure_message.should == ["Expected 0", "to be NaN"]
+ expect(matcher.failure_message).to eq(["Expected 0", "to be NaN"])
end
it "provides a useful negative failure message" do
matcher = BeNaNMatcher.new
matcher.matches?(nan_value)
- matcher.negative_failure_message.should == ["Expected NaN", "not to be NaN"]
+ expect(matcher.negative_failure_message).to eq(["Expected NaN", "not to be NaN"])
end
end
diff --git a/spec/mspec/spec/matchers/be_nil_spec.rb b/spec/mspec/spec/matchers/be_nil_spec.rb
index 6551feb5de..e2768acf83 100644
--- a/spec/mspec/spec/matchers/be_nil_spec.rb
+++ b/spec/mspec/spec/matchers/be_nil_spec.rb
@@ -2,26 +2,26 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe BeNilMatcher do
+RSpec.describe BeNilMatcher do
it "matches when actual is nil" do
- BeNilMatcher.new.matches?(nil).should == true
+ expect(BeNilMatcher.new.matches?(nil)).to eq(true)
end
it "does not match when actual is not nil" do
- BeNilMatcher.new.matches?("").should == false
- BeNilMatcher.new.matches?(false).should == false
- BeNilMatcher.new.matches?(0).should == false
+ expect(BeNilMatcher.new.matches?("")).to eq(false)
+ expect(BeNilMatcher.new.matches?(false)).to eq(false)
+ expect(BeNilMatcher.new.matches?(0)).to eq(false)
end
it "provides a useful failure message" do
matcher = BeNilMatcher.new
matcher.matches?("some string")
- matcher.failure_message.should == ["Expected \"some string\"", "to be nil"]
+ expect(matcher.failure_message).to eq(["Expected \"some string\"", "to be nil"])
end
it "provides a useful negative failure message" do
matcher = BeNilMatcher.new
matcher.matches?(nil)
- matcher.negative_failure_message.should == ["Expected nil", "not to be nil"]
+ expect(matcher.negative_failure_message).to eq(["Expected nil", "not to be nil"])
end
end
diff --git a/spec/mspec/spec/matchers/be_true_or_false_spec.rb b/spec/mspec/spec/matchers/be_true_or_false_spec.rb
index 3edffcb1b1..e4b456eafc 100644
--- a/spec/mspec/spec/matchers/be_true_or_false_spec.rb
+++ b/spec/mspec/spec/matchers/be_true_or_false_spec.rb
@@ -2,18 +2,18 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe BeTrueOrFalseMatcher do
+RSpec.describe BeTrueOrFalseMatcher do
it "matches when actual is true" do
- BeTrueOrFalseMatcher.new.matches?(true).should == true
+ expect(BeTrueOrFalseMatcher.new.matches?(true)).to eq(true)
end
it "matches when actual is false" do
- BeTrueOrFalseMatcher.new.matches?(false).should == true
+ expect(BeTrueOrFalseMatcher.new.matches?(false)).to eq(true)
end
it "provides a useful failure message" do
matcher = BeTrueOrFalseMatcher.new
matcher.matches?("some string")
- matcher.failure_message.should == ["Expected \"some string\"", "to be true or false"]
+ expect(matcher.failure_message).to eq(["Expected \"some string\"", "to be true or false"])
end
end
diff --git a/spec/mspec/spec/matchers/be_true_spec.rb b/spec/mspec/spec/matchers/be_true_spec.rb
index 90c89b3911..39ef05a0f8 100644
--- a/spec/mspec/spec/matchers/be_true_spec.rb
+++ b/spec/mspec/spec/matchers/be_true_spec.rb
@@ -2,27 +2,27 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe BeTrueMatcher do
+RSpec.describe BeTrueMatcher do
it "matches when actual is true" do
- BeTrueMatcher.new.matches?(true).should == true
+ expect(BeTrueMatcher.new.matches?(true)).to eq(true)
end
it "does not match when actual is not true" do
- BeTrueMatcher.new.matches?("").should == false
- BeTrueMatcher.new.matches?(false).should == false
- BeTrueMatcher.new.matches?(nil).should == false
- BeTrueMatcher.new.matches?(0).should == false
+ expect(BeTrueMatcher.new.matches?("")).to eq(false)
+ expect(BeTrueMatcher.new.matches?(false)).to eq(false)
+ expect(BeTrueMatcher.new.matches?(nil)).to eq(false)
+ expect(BeTrueMatcher.new.matches?(0)).to eq(false)
end
it "provides a useful failure message" do
matcher = BeTrueMatcher.new
matcher.matches?("some string")
- matcher.failure_message.should == ["Expected \"some string\"", "to be true"]
+ expect(matcher.failure_message).to eq(["Expected \"some string\"", "to be true"])
end
it "provides a useful negative failure message" do
matcher = BeTrueMatcher.new
matcher.matches?(true)
- matcher.negative_failure_message.should == ["Expected true", "not to be true"]
+ expect(matcher.negative_failure_message).to eq(["Expected true", "not to be true"])
end
end
diff --git a/spec/mspec/spec/matchers/block_caller_spec.rb b/spec/mspec/spec/matchers/block_caller_spec.rb
index d6793b9779..5d7085fa63 100644
--- a/spec/mspec/spec/matchers/block_caller_spec.rb
+++ b/spec/mspec/spec/matchers/block_caller_spec.rb
@@ -2,12 +2,12 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe BlockingMatcher do
+RSpec.describe BlockingMatcher do
it 'matches when a Proc blocks the caller' do
- BlockingMatcher.new.matches?(proc { sleep }).should == true
+ expect(BlockingMatcher.new.matches?(proc { sleep })).to eq(true)
end
it 'does not match when a Proc does not block the caller' do
- BlockingMatcher.new.matches?(proc { 1 }).should == false
+ expect(BlockingMatcher.new.matches?(proc { 1 })).to eq(false)
end
end
diff --git a/spec/mspec/spec/matchers/complain_spec.rb b/spec/mspec/spec/matchers/complain_spec.rb
index 90f94c3684..399ef3105b 100644
--- a/spec/mspec/spec/matchers/complain_spec.rb
+++ b/spec/mspec/spec/matchers/complain_spec.rb
@@ -2,52 +2,57 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe ComplainMatcher do
+RSpec.describe ComplainMatcher do
it "matches when executing the proc results in output to $stderr" do
proc = lambda { warn "I'm gonna tell yo mama" }
- ComplainMatcher.new(nil).matches?(proc).should == true
+ expect(ComplainMatcher.new(nil).matches?(proc)).to eq(true)
end
it "matches when executing the proc results in the expected output to $stderr" do
proc = lambda { warn "Que haces?" }
- ComplainMatcher.new("Que haces?\n").matches?(proc).should == true
- ComplainMatcher.new("Que pasa?\n").matches?(proc).should == false
- ComplainMatcher.new(/Que/).matches?(proc).should == true
- ComplainMatcher.new(/Quoi/).matches?(proc).should == false
+ expect(ComplainMatcher.new("Que haces?\n").matches?(proc)).to eq(true)
+ expect(ComplainMatcher.new("Que pasa?\n").matches?(proc)).to eq(false)
+ expect(ComplainMatcher.new(/Que/).matches?(proc)).to eq(true)
+ expect(ComplainMatcher.new(/Quoi/).matches?(proc)).to eq(false)
end
it "does not match when there is no output to $stderr" do
- ComplainMatcher.new(nil).matches?(lambda {}).should == false
+ expect(ComplainMatcher.new(nil).matches?(lambda {})).to eq(false)
end
it "provides a useful failure message" do
matcher = ComplainMatcher.new(nil)
matcher.matches?(lambda { })
- matcher.failure_message.should == ["Expected a warning", "but received none"]
+ expect(matcher.failure_message).to eq(["Expected a warning", "but received none"])
matcher = ComplainMatcher.new("listen here")
matcher.matches?(lambda { warn "look out" })
- matcher.failure_message.should ==
+ expect(matcher.failure_message).to eq(
["Expected warning: \"listen here\"", "but got: \"look out\""]
+ )
matcher = ComplainMatcher.new(/talk/)
matcher.matches?(lambda { warn "listen up" })
- matcher.failure_message.should ==
+ expect(matcher.failure_message).to eq(
["Expected warning to match: /talk/", "but got: \"listen up\""]
+ )
end
it "provides a useful negative failure message" do
proc = lambda { warn "ouch" }
matcher = ComplainMatcher.new(nil)
matcher.matches?(proc)
- matcher.negative_failure_message.should ==
+ expect(matcher.negative_failure_message).to eq(
["Unexpected warning: ", "\"ouch\""]
+ )
matcher = ComplainMatcher.new("ouchy")
matcher.matches?(proc)
- matcher.negative_failure_message.should ==
+ expect(matcher.negative_failure_message).to eq(
["Expected warning: \"ouchy\"", "but got: \"ouch\""]
+ )
matcher = ComplainMatcher.new(/ou/)
matcher.matches?(proc)
- matcher.negative_failure_message.should ==
+ expect(matcher.negative_failure_message).to eq(
["Expected warning not to match: /ou/", "but got: \"ouch\""]
+ )
end
context "`verbose` option specified" do
@@ -64,10 +69,10 @@ describe ComplainMatcher do
proc = lambda { verbose = $VERBOSE }
ComplainMatcher.new(nil, verbose: true).matches?(proc)
- verbose.should == true
+ expect(verbose).to eq(true)
ComplainMatcher.new(nil, verbose: false).matches?(proc)
- verbose.should == false
+ expect(verbose).to eq(false)
end
it "sets $VERBOSE with false by default" do
@@ -75,15 +80,15 @@ describe ComplainMatcher do
proc = lambda { verbose = $VERBOSE }
ComplainMatcher.new(nil).matches?(proc)
- verbose.should == false
+ expect(verbose).to eq(false)
end
it "does not have side effect" do
proc = lambda { safe_value = $VERBOSE }
- lambda do
+ expect do
ComplainMatcher.new(nil, verbose: true).matches?(proc)
- end.should_not change { $VERBOSE }
+ end.not_to change { $VERBOSE }
end
it "accepts a verbose level as single argument" do
@@ -91,7 +96,7 @@ describe ComplainMatcher do
proc = lambda { verbose = $VERBOSE }
ComplainMatcher.new(verbose: true).matches?(proc)
- verbose.should == true
+ expect(verbose).to eq(true)
end
end
end
diff --git a/spec/mspec/spec/matchers/eql_spec.rb b/spec/mspec/spec/matchers/eql_spec.rb
index f29e6976da..66307d2a9d 100644
--- a/spec/mspec/spec/matchers/eql_spec.rb
+++ b/spec/mspec/spec/matchers/eql_spec.rb
@@ -2,32 +2,32 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe EqlMatcher do
+RSpec.describe EqlMatcher do
it "matches when actual is eql? to expected" do
- EqlMatcher.new(1).matches?(1).should == true
- EqlMatcher.new(1.5).matches?(1.5).should == true
- EqlMatcher.new("red").matches?("red").should == true
- EqlMatcher.new(:blue).matches?(:blue).should == true
- EqlMatcher.new(Object).matches?(Object).should == true
+ expect(EqlMatcher.new(1).matches?(1)).to eq(true)
+ expect(EqlMatcher.new(1.5).matches?(1.5)).to eq(true)
+ expect(EqlMatcher.new("red").matches?("red")).to eq(true)
+ expect(EqlMatcher.new(:blue).matches?(:blue)).to eq(true)
+ expect(EqlMatcher.new(Object).matches?(Object)).to eq(true)
o = Object.new
- EqlMatcher.new(o).matches?(o).should == true
+ expect(EqlMatcher.new(o).matches?(o)).to eq(true)
end
it "does not match when actual is not eql? to expected" do
- EqlMatcher.new(1).matches?(1.0).should == false
- EqlMatcher.new(Hash).matches?(Object).should == false
+ expect(EqlMatcher.new(1).matches?(1.0)).to eq(false)
+ expect(EqlMatcher.new(Hash).matches?(Object)).to eq(false)
end
it "provides a useful failure message" do
matcher = EqlMatcher.new("red")
matcher.matches?("red")
- matcher.failure_message.should == ["Expected \"red\"", "to have same value and type as \"red\""]
+ expect(matcher.failure_message).to eq(["Expected \"red\"", "to have same value and type as \"red\""])
end
it "provides a useful negative failure message" do
matcher = EqlMatcher.new(1)
matcher.matches?(1.0)
- matcher.negative_failure_message.should == ["Expected 1.0", "not to have same value or type as 1"]
+ expect(matcher.negative_failure_message).to eq(["Expected 1.0", "not to have same value or type as 1"])
end
end
diff --git a/spec/mspec/spec/matchers/equal_element_spec.rb b/spec/mspec/spec/matchers/equal_element_spec.rb
index 06fae762c4..3a5ae4ede2 100644
--- a/spec/mspec/spec/matchers/equal_element_spec.rb
+++ b/spec/mspec/spec/matchers/equal_element_spec.rb
@@ -2,74 +2,74 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe EqualElementMatcher do
+RSpec.describe EqualElementMatcher do
it "matches if it finds an element with the passed name, no matter what attributes/content" do
- EqualElementMatcher.new("A").matches?('<A></A>').should be_true
- EqualElementMatcher.new("A").matches?('<A HREF="http://example.com"></A>').should be_true
- EqualElementMatcher.new("A").matches?('<A HREF="http://example.com"></A>').should be_true
+ expect(EqualElementMatcher.new("A").matches?('<A></A>')).to be_truthy
+ expect(EqualElementMatcher.new("A").matches?('<A HREF="http://example.com"></A>')).to be_truthy
+ expect(EqualElementMatcher.new("A").matches?('<A HREF="http://example.com"></A>')).to be_truthy
- EqualElementMatcher.new("BASE").matches?('<BASE></A>').should be_false
- EqualElementMatcher.new("BASE").matches?('<A></BASE>').should be_false
- EqualElementMatcher.new("BASE").matches?('<A></A>').should be_false
- EqualElementMatcher.new("BASE").matches?('<A HREF="http://example.com"></A>').should be_false
- EqualElementMatcher.new("BASE").matches?('<A HREF="http://example.com"></A>').should be_false
+ expect(EqualElementMatcher.new("BASE").matches?('<BASE></A>')).to be_falsey
+ expect(EqualElementMatcher.new("BASE").matches?('<A></BASE>')).to be_falsey
+ expect(EqualElementMatcher.new("BASE").matches?('<A></A>')).to be_falsey
+ expect(EqualElementMatcher.new("BASE").matches?('<A HREF="http://example.com"></A>')).to be_falsey
+ expect(EqualElementMatcher.new("BASE").matches?('<A HREF="http://example.com"></A>')).to be_falsey
end
it "matches if it finds an element with the passed name and the passed attributes" do
- EqualElementMatcher.new("A", {}).matches?('<A></A>').should be_true
- EqualElementMatcher.new("A", nil).matches?('<A HREF="http://example.com"></A>').should be_true
- EqualElementMatcher.new("A", "HREF" => "http://example.com").matches?('<A HREF="http://example.com"></A>').should be_true
+ expect(EqualElementMatcher.new("A", {}).matches?('<A></A>')).to be_truthy
+ expect(EqualElementMatcher.new("A", nil).matches?('<A HREF="http://example.com"></A>')).to be_truthy
+ expect(EqualElementMatcher.new("A", "HREF" => "http://example.com").matches?('<A HREF="http://example.com"></A>')).to be_truthy
- EqualElementMatcher.new("A", {}).matches?('<A HREF="http://example.com"></A>').should be_false
- EqualElementMatcher.new("A", "HREF" => "http://example.com").matches?('<A></A>').should be_false
- EqualElementMatcher.new("A", "HREF" => "http://example.com").matches?('<A HREF="http://test.com"></A>').should be_false
- EqualElementMatcher.new("A", "HREF" => "http://example.com").matches?('<A HREF="http://example.com" HREF="http://example.com"></A>').should be_false
+ expect(EqualElementMatcher.new("A", {}).matches?('<A HREF="http://example.com"></A>')).to be_falsey
+ expect(EqualElementMatcher.new("A", "HREF" => "http://example.com").matches?('<A></A>')).to be_falsey
+ expect(EqualElementMatcher.new("A", "HREF" => "http://example.com").matches?('<A HREF="http://test.com"></A>')).to be_falsey
+ expect(EqualElementMatcher.new("A", "HREF" => "http://example.com").matches?('<A HREF="http://example.com" HREF="http://example.com"></A>')).to be_falsey
end
it "matches if it finds an element with the passed name, the passed attributes and the passed content" do
- EqualElementMatcher.new("A", {}, "").matches?('<A></A>').should be_true
- EqualElementMatcher.new("A", {"HREF" => "http://example.com"}, "Example").matches?('<A HREF="http://example.com">Example</A>').should be_true
+ expect(EqualElementMatcher.new("A", {}, "").matches?('<A></A>')).to be_truthy
+ expect(EqualElementMatcher.new("A", {"HREF" => "http://example.com"}, "Example").matches?('<A HREF="http://example.com">Example</A>')).to be_truthy
- EqualElementMatcher.new("A", {}, "Test").matches?('<A></A>').should be_false
- EqualElementMatcher.new("A", {"HREF" => "http://example.com"}, "Example").matches?('<A HREF="http://example.com"></A>').should be_false
- EqualElementMatcher.new("A", {"HREF" => "http://example.com"}, "Example").matches?('<A HREF="http://example.com">Test</A>').should be_false
+ expect(EqualElementMatcher.new("A", {}, "Test").matches?('<A></A>')).to be_falsey
+ expect(EqualElementMatcher.new("A", {"HREF" => "http://example.com"}, "Example").matches?('<A HREF="http://example.com"></A>')).to be_falsey
+ expect(EqualElementMatcher.new("A", {"HREF" => "http://example.com"}, "Example").matches?('<A HREF="http://example.com">Test</A>')).to be_falsey
end
it "can match unclosed elements" do
- EqualElementMatcher.new("BASE", nil, nil, :not_closed => true).matches?('<BASE>').should be_true
- EqualElementMatcher.new("BASE", {"HREF" => "http://example.com"}, nil, :not_closed => true).matches?('<BASE HREF="http://example.com">').should be_true
- EqualElementMatcher.new("BASE", {"HREF" => "http://example.com"}, "Example", :not_closed => true).matches?('<BASE HREF="http://example.com">Example').should be_true
+ expect(EqualElementMatcher.new("BASE", nil, nil, :not_closed => true).matches?('<BASE>')).to be_truthy
+ expect(EqualElementMatcher.new("BASE", {"HREF" => "http://example.com"}, nil, :not_closed => true).matches?('<BASE HREF="http://example.com">')).to be_truthy
+ expect(EqualElementMatcher.new("BASE", {"HREF" => "http://example.com"}, "Example", :not_closed => true).matches?('<BASE HREF="http://example.com">Example')).to be_truthy
- EqualElementMatcher.new("BASE", {}, nil, :not_closed => true).matches?('<BASE HREF="http://example.com">').should be_false
- EqualElementMatcher.new("BASE", {"HREF" => "http://example.com"}, "", :not_closed => true).matches?('<BASE HREF="http://example.com">Example').should be_false
- EqualElementMatcher.new("BASE", {"HREF" => "http://example.com"}, "Test", :not_closed => true).matches?('<BASE HREF="http://example.com">Example').should be_false
+ expect(EqualElementMatcher.new("BASE", {}, nil, :not_closed => true).matches?('<BASE HREF="http://example.com">')).to be_falsey
+ expect(EqualElementMatcher.new("BASE", {"HREF" => "http://example.com"}, "", :not_closed => true).matches?('<BASE HREF="http://example.com">Example')).to be_falsey
+ expect(EqualElementMatcher.new("BASE", {"HREF" => "http://example.com"}, "Test", :not_closed => true).matches?('<BASE HREF="http://example.com">Example')).to be_falsey
end
it "provides a useful failure message" do
equal_element = EqualElementMatcher.new("A", {}, "Test")
- equal_element.matches?('<A></A>').should be_false
- equal_element.failure_message.should == [%{Expected "<A></A>"}, %{to be a 'A' element with no attributes and "Test" as content}]
+ expect(equal_element.matches?('<A></A>')).to be_falsey
+ expect(equal_element.failure_message).to eq([%{Expected "<A></A>"}, %{to be a 'A' element with no attributes and "Test" as content}])
equal_element = EqualElementMatcher.new("A", {}, "")
- equal_element.matches?('<A>Test</A>').should be_false
- equal_element.failure_message.should == [%{Expected "<A>Test</A>"}, %{to be a 'A' element with no attributes and no content}]
+ expect(equal_element.matches?('<A>Test</A>')).to be_falsey
+ expect(equal_element.failure_message).to eq([%{Expected "<A>Test</A>"}, %{to be a 'A' element with no attributes and no content}])
equal_element = EqualElementMatcher.new("A", "HREF" => "http://www.example.com")
- equal_element.matches?('<A>Test</A>').should be_false
- equal_element.failure_message.should == [%{Expected "<A>Test</A>"}, %{to be a 'A' element with HREF="http://www.example.com" and any content}]
+ expect(equal_element.matches?('<A>Test</A>')).to be_falsey
+ expect(equal_element.failure_message).to eq([%{Expected "<A>Test</A>"}, %{to be a 'A' element with HREF="http://www.example.com" and any content}])
end
it "provides a useful negative failure message" do
equal_element = EqualElementMatcher.new("A", {}, "Test")
- equal_element.matches?('<A></A>').should be_false
- equal_element.negative_failure_message.should == [%{Expected "<A></A>"}, %{not to be a 'A' element with no attributes and "Test" as content}]
+ expect(equal_element.matches?('<A></A>')).to be_falsey
+ expect(equal_element.negative_failure_message).to eq([%{Expected "<A></A>"}, %{not to be a 'A' element with no attributes and "Test" as content}])
equal_element = EqualElementMatcher.new("A", {}, "")
- equal_element.matches?('<A>Test</A>').should be_false
- equal_element.negative_failure_message.should == [%{Expected "<A>Test</A>"}, %{not to be a 'A' element with no attributes and no content}]
+ expect(equal_element.matches?('<A>Test</A>')).to be_falsey
+ expect(equal_element.negative_failure_message).to eq([%{Expected "<A>Test</A>"}, %{not to be a 'A' element with no attributes and no content}])
equal_element = EqualElementMatcher.new("A", "HREF" => "http://www.example.com")
- equal_element.matches?('<A>Test</A>').should be_false
- equal_element.negative_failure_message.should == [%{Expected "<A>Test</A>"}, %{not to be a 'A' element with HREF="http://www.example.com" and any content}]
+ expect(equal_element.matches?('<A>Test</A>')).to be_falsey
+ expect(equal_element.negative_failure_message).to eq([%{Expected "<A>Test</A>"}, %{not to be a 'A' element with HREF="http://www.example.com" and any content}])
end
end
diff --git a/spec/mspec/spec/matchers/equal_spec.rb b/spec/mspec/spec/matchers/equal_spec.rb
index a61432b750..2df1de54b4 100644
--- a/spec/mspec/spec/matchers/equal_spec.rb
+++ b/spec/mspec/spec/matchers/equal_spec.rb
@@ -2,31 +2,31 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe EqualMatcher do
+RSpec.describe EqualMatcher do
it "matches when actual is equal? to expected" do
- EqualMatcher.new(1).matches?(1).should == true
- EqualMatcher.new(:blue).matches?(:blue).should == true
- EqualMatcher.new(Object).matches?(Object).should == true
+ expect(EqualMatcher.new(1).matches?(1)).to eq(true)
+ expect(EqualMatcher.new(:blue).matches?(:blue)).to eq(true)
+ expect(EqualMatcher.new(Object).matches?(Object)).to eq(true)
o = Object.new
- EqualMatcher.new(o).matches?(o).should == true
+ expect(EqualMatcher.new(o).matches?(o)).to eq(true)
end
it "does not match when actual is not a equal? to expected" do
- EqualMatcher.new(1).matches?(1.0).should == false
- EqualMatcher.new("blue").matches?("blue").should == false
- EqualMatcher.new(Hash).matches?(Object).should == false
+ expect(EqualMatcher.new(1).matches?(1.0)).to eq(false)
+ expect(EqualMatcher.new("blue").matches?("blue")).to eq(false)
+ expect(EqualMatcher.new(Hash).matches?(Object)).to eq(false)
end
it "provides a useful failure message" do
matcher = EqualMatcher.new("red")
matcher.matches?("red")
- matcher.failure_message.should == ["Expected \"red\"", "to be identical to \"red\""]
+ expect(matcher.failure_message).to eq(["Expected \"red\"", "to be identical to \"red\""])
end
it "provides a useful negative failure message" do
matcher = EqualMatcher.new(1)
matcher.matches?(1)
- matcher.negative_failure_message.should == ["Expected 1", "not to be identical to 1"]
+ expect(matcher.negative_failure_message).to eq(["Expected 1", "not to be identical to 1"])
end
end
diff --git a/spec/mspec/spec/matchers/have_class_variable_spec.rb b/spec/mspec/spec/matchers/have_class_variable_spec.rb
index 01ba9d0f57..d6fcf9d4e2 100644
--- a/spec/mspec/spec/matchers/have_class_variable_spec.rb
+++ b/spec/mspec/spec/matchers/have_class_variable_spec.rb
@@ -8,42 +8,42 @@ class IVarModMock
end
end
-describe HaveClassVariableMatcher, "on RUBY_VERSION >= 1.9" do
+RSpec.describe HaveClassVariableMatcher, "on RUBY_VERSION >= 1.9" do
it "matches when mod has the class variable, given as string" do
matcher = HaveClassVariableMatcher.new('@foo')
- matcher.matches?(IVarModMock).should be_true
+ expect(matcher.matches?(IVarModMock)).to be_truthy
end
it "matches when mod has the class variable, given as symbol" do
matcher = HaveClassVariableMatcher.new(:@foo)
- matcher.matches?(IVarModMock).should be_true
+ expect(matcher.matches?(IVarModMock)).to be_truthy
end
it "does not match when mod hasn't got the class variable, given as string" do
matcher = HaveClassVariableMatcher.new('@bar')
- matcher.matches?(IVarModMock).should be_false
+ expect(matcher.matches?(IVarModMock)).to be_falsey
end
it "does not match when mod hasn't got the class variable, given as symbol" do
matcher = HaveClassVariableMatcher.new(:@bar)
- matcher.matches?(IVarModMock).should be_false
+ expect(matcher.matches?(IVarModMock)).to be_falsey
end
it "provides a failure message for #should" do
matcher = HaveClassVariableMatcher.new(:@bar)
matcher.matches?(IVarModMock)
- matcher.failure_message.should == [
+ expect(matcher.failure_message).to eq([
"Expected IVarModMock to have class variable '@bar'",
"but it does not"
- ]
+ ])
end
it "provides a failure messoge for #should_not" do
matcher = HaveClassVariableMatcher.new(:@bar)
matcher.matches?(IVarModMock)
- matcher.negative_failure_message.should == [
+ expect(matcher.negative_failure_message).to eq([
"Expected IVarModMock NOT to have class variable '@bar'",
"but it does"
- ]
+ ])
end
end
diff --git a/spec/mspec/spec/matchers/have_constant_spec.rb b/spec/mspec/spec/matchers/have_constant_spec.rb
index 20c5f161d4..0bf44dbe2b 100644
--- a/spec/mspec/spec/matchers/have_constant_spec.rb
+++ b/spec/mspec/spec/matchers/have_constant_spec.rb
@@ -6,32 +6,32 @@ class HCMSpecs
X = :x
end
-describe HaveConstantMatcher do
+RSpec.describe HaveConstantMatcher do
it "matches when mod has the constant" do
matcher = HaveConstantMatcher.new :X
- matcher.matches?(HCMSpecs).should be_true
+ expect(matcher.matches?(HCMSpecs)).to be_truthy
end
it "does not match when mod does not have the constant" do
matcher = HaveConstantMatcher.new :A
- matcher.matches?(HCMSpecs).should be_false
+ expect(matcher.matches?(HCMSpecs)).to be_falsey
end
it "provides a failure message for #should" do
matcher = HaveConstantMatcher.new :A
matcher.matches?(HCMSpecs)
- matcher.failure_message.should == [
+ expect(matcher.failure_message).to eq([
"Expected HCMSpecs to have constant 'A'",
"but it does not"
- ]
+ ])
end
it "provides a failure messoge for #should_not" do
matcher = HaveConstantMatcher.new :X
matcher.matches?(HCMSpecs)
- matcher.negative_failure_message.should == [
+ expect(matcher.negative_failure_message).to eq([
"Expected HCMSpecs NOT to have constant 'X'",
"but it does"
- ]
+ ])
end
end
diff --git a/spec/mspec/spec/matchers/have_instance_method_spec.rb b/spec/mspec/spec/matchers/have_instance_method_spec.rb
index 738f5f875d..7c2e50dba6 100644
--- a/spec/mspec/spec/matchers/have_instance_method_spec.rb
+++ b/spec/mspec/spec/matchers/have_instance_method_spec.rb
@@ -12,42 +12,42 @@ class HIMMSpecs
end
end
-describe HaveInstanceMethodMatcher do
+RSpec.describe HaveInstanceMethodMatcher do
it "inherits from MethodMatcher" do
- HaveInstanceMethodMatcher.new(:m).should be_kind_of(MethodMatcher)
+ expect(HaveInstanceMethodMatcher.new(:m)).to be_kind_of(MethodMatcher)
end
it "matches when mod has the instance method" do
matcher = HaveInstanceMethodMatcher.new :instance_method
- matcher.matches?(HIMMSpecs).should be_true
- matcher.matches?(HIMMSpecs::Subclass).should be_true
+ expect(matcher.matches?(HIMMSpecs)).to be_truthy
+ expect(matcher.matches?(HIMMSpecs::Subclass)).to be_truthy
end
it "does not match when mod does not have the instance method" do
matcher = HaveInstanceMethodMatcher.new :another_method
- matcher.matches?(HIMMSpecs).should be_false
+ expect(matcher.matches?(HIMMSpecs)).to be_falsey
end
it "does not match if the method is in a superclass and include_super is false" do
matcher = HaveInstanceMethodMatcher.new :instance_method, false
- matcher.matches?(HIMMSpecs::Subclass).should be_false
+ expect(matcher.matches?(HIMMSpecs::Subclass)).to be_falsey
end
it "provides a failure message for #should" do
matcher = HaveInstanceMethodMatcher.new :some_method
matcher.matches?(HIMMSpecs)
- matcher.failure_message.should == [
+ expect(matcher.failure_message).to eq([
"Expected HIMMSpecs to have instance method 'some_method'",
"but it does not"
- ]
+ ])
end
it "provides a failure messoge for #should_not" do
matcher = HaveInstanceMethodMatcher.new :some_method
matcher.matches?(HIMMSpecs)
- matcher.negative_failure_message.should == [
+ expect(matcher.negative_failure_message).to eq([
"Expected HIMMSpecs NOT to have instance method 'some_method'",
"but it does"
- ]
+ ])
end
end
diff --git a/spec/mspec/spec/matchers/have_instance_variable_spec.rb b/spec/mspec/spec/matchers/have_instance_variable_spec.rb
index 4122c6551b..12e2470f14 100644
--- a/spec/mspec/spec/matchers/have_instance_variable_spec.rb
+++ b/spec/mspec/spec/matchers/have_instance_variable_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe HaveInstanceVariableMatcher do
+RSpec.describe HaveInstanceVariableMatcher do
before :each do
@object = Object.new
def @object.instance_variables
@@ -12,39 +12,39 @@ describe HaveInstanceVariableMatcher do
it "matches when object has the instance variable, given as string" do
matcher = HaveInstanceVariableMatcher.new('@foo')
- matcher.matches?(@object).should be_true
+ expect(matcher.matches?(@object)).to be_truthy
end
it "matches when object has the instance variable, given as symbol" do
matcher = HaveInstanceVariableMatcher.new(:@foo)
- matcher.matches?(@object).should be_true
+ expect(matcher.matches?(@object)).to be_truthy
end
it "does not match when object hasn't got the instance variable, given as string" do
matcher = HaveInstanceVariableMatcher.new('@bar')
- matcher.matches?(@object).should be_false
+ expect(matcher.matches?(@object)).to be_falsey
end
it "does not match when object hasn't got the instance variable, given as symbol" do
matcher = HaveInstanceVariableMatcher.new(:@bar)
- matcher.matches?(@object).should be_false
+ expect(matcher.matches?(@object)).to be_falsey
end
it "provides a failure message for #should" do
matcher = HaveInstanceVariableMatcher.new(:@bar)
matcher.matches?(@object)
- matcher.failure_message.should == [
+ expect(matcher.failure_message).to eq([
"Expected #{@object.inspect} to have instance variable '@bar'",
"but it does not"
- ]
+ ])
end
it "provides a failure messoge for #should_not" do
matcher = HaveInstanceVariableMatcher.new(:@bar)
matcher.matches?(@object)
- matcher.negative_failure_message.should == [
+ expect(matcher.negative_failure_message).to eq([
"Expected #{@object.inspect} NOT to have instance variable '@bar'",
"but it does"
- ]
+ ])
end
end
diff --git a/spec/mspec/spec/matchers/have_method_spec.rb b/spec/mspec/spec/matchers/have_method_spec.rb
index 41bd485119..4fc0bf5e45 100644
--- a/spec/mspec/spec/matchers/have_method_spec.rb
+++ b/spec/mspec/spec/matchers/have_method_spec.rb
@@ -12,44 +12,44 @@ class HMMSpecs
end
end
-describe HaveMethodMatcher do
+RSpec.describe HaveMethodMatcher do
it "inherits from MethodMatcher" do
- HaveMethodMatcher.new(:m).should be_kind_of(MethodMatcher)
+ expect(HaveMethodMatcher.new(:m)).to be_kind_of(MethodMatcher)
end
it "matches when mod has the method" do
matcher = HaveMethodMatcher.new :instance_method
- matcher.matches?(HMMSpecs).should be_true
- matcher.matches?(HMMSpecs.new).should be_true
- matcher.matches?(HMMSpecs::Subclass).should be_true
- matcher.matches?(HMMSpecs::Subclass.new).should be_true
+ expect(matcher.matches?(HMMSpecs)).to be_truthy
+ expect(matcher.matches?(HMMSpecs.new)).to be_truthy
+ expect(matcher.matches?(HMMSpecs::Subclass)).to be_truthy
+ expect(matcher.matches?(HMMSpecs::Subclass.new)).to be_truthy
end
it "does not match when mod does not have the method" do
matcher = HaveMethodMatcher.new :another_method
- matcher.matches?(HMMSpecs).should be_false
+ expect(matcher.matches?(HMMSpecs)).to be_falsey
end
it "does not match if the method is in a superclass and include_super is false" do
matcher = HaveMethodMatcher.new :instance_method, false
- matcher.matches?(HMMSpecs::Subclass).should be_false
+ expect(matcher.matches?(HMMSpecs::Subclass)).to be_falsey
end
it "provides a failure message for #should" do
matcher = HaveMethodMatcher.new :some_method
matcher.matches?(HMMSpecs)
- matcher.failure_message.should == [
+ expect(matcher.failure_message).to eq([
"Expected HMMSpecs to have method 'some_method'",
"but it does not"
- ]
+ ])
end
it "provides a failure messoge for #should_not" do
matcher = HaveMethodMatcher.new :some_method
matcher.matches?(HMMSpecs)
- matcher.negative_failure_message.should == [
+ expect(matcher.negative_failure_message).to eq([
"Expected HMMSpecs NOT to have method 'some_method'",
"but it does"
- ]
+ ])
end
end
diff --git a/spec/mspec/spec/matchers/have_private_instance_method_spec.rb b/spec/mspec/spec/matchers/have_private_instance_method_spec.rb
index 827c6b6034..0e65c264d9 100644
--- a/spec/mspec/spec/matchers/have_private_instance_method_spec.rb
+++ b/spec/mspec/spec/matchers/have_private_instance_method_spec.rb
@@ -16,42 +16,42 @@ class HPIMMSpecs
end
end
-describe HavePrivateInstanceMethodMatcher do
+RSpec.describe HavePrivateInstanceMethodMatcher do
it "inherits from MethodMatcher" do
- HavePrivateInstanceMethodMatcher.new(:m).should be_kind_of(MethodMatcher)
+ expect(HavePrivateInstanceMethodMatcher.new(:m)).to be_kind_of(MethodMatcher)
end
it "matches when mod has the private instance method" do
matcher = HavePrivateInstanceMethodMatcher.new :private_method
- matcher.matches?(HPIMMSpecs).should be_true
- matcher.matches?(HPIMMSpecs::Subclass).should be_true
+ expect(matcher.matches?(HPIMMSpecs)).to be_truthy
+ expect(matcher.matches?(HPIMMSpecs::Subclass)).to be_truthy
end
it "does not match when mod does not have the private instance method" do
matcher = HavePrivateInstanceMethodMatcher.new :another_method
- matcher.matches?(HPIMMSpecs).should be_false
+ expect(matcher.matches?(HPIMMSpecs)).to be_falsey
end
it "does not match if the method is in a superclass and include_super is false" do
matcher = HavePrivateInstanceMethodMatcher.new :private_method, false
- matcher.matches?(HPIMMSpecs::Subclass).should be_false
+ expect(matcher.matches?(HPIMMSpecs::Subclass)).to be_falsey
end
it "provides a failure message for #should" do
matcher = HavePrivateInstanceMethodMatcher.new :some_method
matcher.matches?(HPIMMSpecs)
- matcher.failure_message.should == [
+ expect(matcher.failure_message).to eq([
"Expected HPIMMSpecs to have private instance method 'some_method'",
"but it does not"
- ]
+ ])
end
it "provides a failure message for #should_not" do
matcher = HavePrivateInstanceMethodMatcher.new :some_method
matcher.matches?(HPIMMSpecs)
- matcher.negative_failure_message.should == [
+ expect(matcher.negative_failure_message).to eq([
"Expected HPIMMSpecs NOT to have private instance method 'some_method'",
"but it does"
- ]
+ ])
end
end
diff --git a/spec/mspec/spec/matchers/have_private_method_spec.rb b/spec/mspec/spec/matchers/have_private_method_spec.rb
index e63a9a3c2f..f433288057 100644
--- a/spec/mspec/spec/matchers/have_private_method_spec.rb
+++ b/spec/mspec/spec/matchers/have_private_method_spec.rb
@@ -9,36 +9,36 @@ class HPMMSpecs
private_class_method :private_method
end
-describe HavePrivateMethodMatcher do
+RSpec.describe HavePrivateMethodMatcher do
it "inherits from MethodMatcher" do
- HavePrivateMethodMatcher.new(:m).should be_kind_of(MethodMatcher)
+ expect(HavePrivateMethodMatcher.new(:m)).to be_kind_of(MethodMatcher)
end
it "matches when mod has the private method" do
matcher = HavePrivateMethodMatcher.new :private_method
- matcher.matches?(HPMMSpecs).should be_true
+ expect(matcher.matches?(HPMMSpecs)).to be_truthy
end
it "does not match when mod does not have the private method" do
matcher = HavePrivateMethodMatcher.new :another_method
- matcher.matches?(HPMMSpecs).should be_false
+ expect(matcher.matches?(HPMMSpecs)).to be_falsey
end
it "provides a failure message for #should" do
matcher = HavePrivateMethodMatcher.new :some_method
matcher.matches?(HPMMSpecs)
- matcher.failure_message.should == [
+ expect(matcher.failure_message).to eq([
"Expected HPMMSpecs to have private method 'some_method'",
"but it does not"
- ]
+ ])
end
it "provides a failure message for #should_not" do
matcher = HavePrivateMethodMatcher.new :private_method
matcher.matches?(HPMMSpecs)
- matcher.negative_failure_message.should == [
+ expect(matcher.negative_failure_message).to eq([
"Expected HPMMSpecs NOT to have private method 'private_method'",
"but it does"
- ]
+ ])
end
end
diff --git a/spec/mspec/spec/matchers/have_protected_instance_method_spec.rb b/spec/mspec/spec/matchers/have_protected_instance_method_spec.rb
index 460d0368fb..45b39004a3 100644
--- a/spec/mspec/spec/matchers/have_protected_instance_method_spec.rb
+++ b/spec/mspec/spec/matchers/have_protected_instance_method_spec.rb
@@ -16,42 +16,42 @@ class HPIMMSpecs
end
end
-describe HaveProtectedInstanceMethodMatcher do
+RSpec.describe HaveProtectedInstanceMethodMatcher do
it "inherits from MethodMatcher" do
- HaveProtectedInstanceMethodMatcher.new(:m).should be_kind_of(MethodMatcher)
+ expect(HaveProtectedInstanceMethodMatcher.new(:m)).to be_kind_of(MethodMatcher)
end
it "matches when mod has the protected instance method" do
matcher = HaveProtectedInstanceMethodMatcher.new :protected_method
- matcher.matches?(HPIMMSpecs).should be_true
- matcher.matches?(HPIMMSpecs::Subclass).should be_true
+ expect(matcher.matches?(HPIMMSpecs)).to be_truthy
+ expect(matcher.matches?(HPIMMSpecs::Subclass)).to be_truthy
end
it "does not match when mod does not have the protected instance method" do
matcher = HaveProtectedInstanceMethodMatcher.new :another_method
- matcher.matches?(HPIMMSpecs).should be_false
+ expect(matcher.matches?(HPIMMSpecs)).to be_falsey
end
it "does not match if the method is in a superclass and include_super is false" do
matcher = HaveProtectedInstanceMethodMatcher.new :protected_method, false
- matcher.matches?(HPIMMSpecs::Subclass).should be_false
+ expect(matcher.matches?(HPIMMSpecs::Subclass)).to be_falsey
end
it "provides a failure message for #should" do
matcher = HaveProtectedInstanceMethodMatcher.new :some_method
matcher.matches?(HPIMMSpecs)
- matcher.failure_message.should == [
+ expect(matcher.failure_message).to eq([
"Expected HPIMMSpecs to have protected instance method 'some_method'",
"but it does not"
- ]
+ ])
end
it "provides a failure messoge for #should_not" do
matcher = HaveProtectedInstanceMethodMatcher.new :some_method
matcher.matches?(HPIMMSpecs)
- matcher.negative_failure_message.should == [
+ expect(matcher.negative_failure_message).to eq([
"Expected HPIMMSpecs NOT to have protected instance method 'some_method'",
"but it does"
- ]
+ ])
end
end
diff --git a/spec/mspec/spec/matchers/have_public_instance_method_spec.rb b/spec/mspec/spec/matchers/have_public_instance_method_spec.rb
index bff1046f04..771d5b7911 100644
--- a/spec/mspec/spec/matchers/have_public_instance_method_spec.rb
+++ b/spec/mspec/spec/matchers/have_public_instance_method_spec.rb
@@ -12,42 +12,42 @@ class HPIMMSpecs
end
end
-describe HavePublicInstanceMethodMatcher do
+RSpec.describe HavePublicInstanceMethodMatcher do
it "inherits from MethodMatcher" do
- HavePublicInstanceMethodMatcher.new(:m).should be_kind_of(MethodMatcher)
+ expect(HavePublicInstanceMethodMatcher.new(:m)).to be_kind_of(MethodMatcher)
end
it "matches when mod has the public instance method" do
matcher = HavePublicInstanceMethodMatcher.new :public_method
- matcher.matches?(HPIMMSpecs).should be_true
- matcher.matches?(HPIMMSpecs::Subclass).should be_true
+ expect(matcher.matches?(HPIMMSpecs)).to be_truthy
+ expect(matcher.matches?(HPIMMSpecs::Subclass)).to be_truthy
end
it "does not match when mod does not have the public instance method" do
matcher = HavePublicInstanceMethodMatcher.new :another_method
- matcher.matches?(HPIMMSpecs).should be_false
+ expect(matcher.matches?(HPIMMSpecs)).to be_falsey
end
it "does not match if the method is in a superclass and include_super is false" do
matcher = HavePublicInstanceMethodMatcher.new :public_method, false
- matcher.matches?(HPIMMSpecs::Subclass).should be_false
+ expect(matcher.matches?(HPIMMSpecs::Subclass)).to be_falsey
end
it "provides a failure message for #should" do
matcher = HavePublicInstanceMethodMatcher.new :some_method
matcher.matches?(HPIMMSpecs)
- matcher.failure_message.should == [
+ expect(matcher.failure_message).to eq([
"Expected HPIMMSpecs to have public instance method 'some_method'",
"but it does not"
- ]
+ ])
end
it "provides a failure messoge for #should_not" do
matcher = HavePublicInstanceMethodMatcher.new :some_method
matcher.matches?(HPIMMSpecs)
- matcher.negative_failure_message.should == [
+ expect(matcher.negative_failure_message).to eq([
"Expected HPIMMSpecs NOT to have public instance method 'some_method'",
"but it does"
- ]
+ ])
end
end
diff --git a/spec/mspec/spec/matchers/have_singleton_method_spec.rb b/spec/mspec/spec/matchers/have_singleton_method_spec.rb
index 57c37e01d9..61ef00d49c 100644
--- a/spec/mspec/spec/matchers/have_singleton_method_spec.rb
+++ b/spec/mspec/spec/matchers/have_singleton_method_spec.rb
@@ -7,14 +7,14 @@ class HSMMSpecs
end
end
-describe HaveSingletonMethodMatcher do
+RSpec.describe HaveSingletonMethodMatcher do
it "inherits from MethodMatcher" do
- HaveSingletonMethodMatcher.new(:m).should be_kind_of(MethodMatcher)
+ expect(HaveSingletonMethodMatcher.new(:m)).to be_kind_of(MethodMatcher)
end
it "matches when the class has a singleton method" do
matcher = HaveSingletonMethodMatcher.new :singleton_method
- matcher.matches?(HSMMSpecs).should be_true
+ expect(matcher.matches?(HSMMSpecs)).to be_truthy
end
it "matches when the object has a singleton method" do
@@ -22,24 +22,24 @@ describe HaveSingletonMethodMatcher do
def obj.singleton_method; end
matcher = HaveSingletonMethodMatcher.new :singleton_method
- matcher.matches?(obj).should be_true
+ expect(matcher.matches?(obj)).to be_truthy
end
it "provides a failure message for #should" do
matcher = HaveSingletonMethodMatcher.new :some_method
matcher.matches?(HSMMSpecs)
- matcher.failure_message.should == [
+ expect(matcher.failure_message).to eq([
"Expected HSMMSpecs to have singleton method 'some_method'",
"but it does not"
- ]
+ ])
end
it "provides a failure message for #should_not" do
matcher = HaveSingletonMethodMatcher.new :singleton_method
matcher.matches?(HSMMSpecs)
- matcher.negative_failure_message.should == [
+ expect(matcher.negative_failure_message).to eq([
"Expected HSMMSpecs NOT to have singleton method 'singleton_method'",
"but it does"
- ]
+ ])
end
end
diff --git a/spec/mspec/spec/matchers/include_any_of_spec.rb b/spec/mspec/spec/matchers/include_any_of_spec.rb
index 697c8d8886..1473bb6d0b 100644
--- a/spec/mspec/spec/matchers/include_any_of_spec.rb
+++ b/spec/mspec/spec/matchers/include_any_of_spec.rb
@@ -2,41 +2,41 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe IncludeAnyOfMatcher do
+RSpec.describe IncludeAnyOfMatcher do
it "matches when actual includes expected" do
- IncludeAnyOfMatcher.new(2).matches?([1,2,3]).should == true
- IncludeAnyOfMatcher.new("b").matches?("abc").should == true
+ expect(IncludeAnyOfMatcher.new(2).matches?([1,2,3])).to eq(true)
+ expect(IncludeAnyOfMatcher.new("b").matches?("abc")).to eq(true)
end
it "does not match when actual does not include expected" do
- IncludeAnyOfMatcher.new(4).matches?([1,2,3]).should == false
- IncludeAnyOfMatcher.new("d").matches?("abc").should == false
+ expect(IncludeAnyOfMatcher.new(4).matches?([1,2,3])).to eq(false)
+ expect(IncludeAnyOfMatcher.new("d").matches?("abc")).to eq(false)
end
it "matches when actual includes all expected" do
- IncludeAnyOfMatcher.new(3, 2, 1).matches?([1,2,3]).should == true
- IncludeAnyOfMatcher.new("a", "b", "c").matches?("abc").should == true
+ expect(IncludeAnyOfMatcher.new(3, 2, 1).matches?([1,2,3])).to eq(true)
+ expect(IncludeAnyOfMatcher.new("a", "b", "c").matches?("abc")).to eq(true)
end
it "matches when actual includes any expected" do
- IncludeAnyOfMatcher.new(3, 4, 5).matches?([1,2,3]).should == true
- IncludeAnyOfMatcher.new("c", "d", "e").matches?("abc").should == true
+ expect(IncludeAnyOfMatcher.new(3, 4, 5).matches?([1,2,3])).to eq(true)
+ expect(IncludeAnyOfMatcher.new("c", "d", "e").matches?("abc")).to eq(true)
end
it "does not match when actual does not include any expected" do
- IncludeAnyOfMatcher.new(4, 5).matches?([1,2,3]).should == false
- IncludeAnyOfMatcher.new("de").matches?("abc").should == false
+ expect(IncludeAnyOfMatcher.new(4, 5).matches?([1,2,3])).to eq(false)
+ expect(IncludeAnyOfMatcher.new("de").matches?("abc")).to eq(false)
end
it "provides a useful failure message" do
matcher = IncludeAnyOfMatcher.new(5, 6)
matcher.matches?([1,2,3])
- matcher.failure_message.should == ["Expected [1, 2, 3]", "to include any of [5, 6]"]
+ expect(matcher.failure_message).to eq(["Expected [1, 2, 3]", "to include any of [5, 6]"])
end
it "provides a useful negative failure message" do
matcher = IncludeAnyOfMatcher.new(1, 2, 3)
matcher.matches?([1,2])
- matcher.negative_failure_message.should == ["Expected [1, 2]", "not to include any of [1, 2, 3]"]
+ expect(matcher.negative_failure_message).to eq(["Expected [1, 2]", "not to include any of [1, 2, 3]"])
end
end
diff --git a/spec/mspec/spec/matchers/include_spec.rb b/spec/mspec/spec/matchers/include_spec.rb
index f045c5e0cb..6bf1bef085 100644
--- a/spec/mspec/spec/matchers/include_spec.rb
+++ b/spec/mspec/spec/matchers/include_spec.rb
@@ -2,36 +2,36 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe IncludeMatcher do
+RSpec.describe IncludeMatcher do
it "matches when actual includes expected" do
- IncludeMatcher.new(2).matches?([1,2,3]).should == true
- IncludeMatcher.new("b").matches?("abc").should == true
+ expect(IncludeMatcher.new(2).matches?([1,2,3])).to eq(true)
+ expect(IncludeMatcher.new("b").matches?("abc")).to eq(true)
end
it "does not match when actual does not include expected" do
- IncludeMatcher.new(4).matches?([1,2,3]).should == false
- IncludeMatcher.new("d").matches?("abc").should == false
+ expect(IncludeMatcher.new(4).matches?([1,2,3])).to eq(false)
+ expect(IncludeMatcher.new("d").matches?("abc")).to eq(false)
end
it "matches when actual includes all expected" do
- IncludeMatcher.new(3, 2, 1).matches?([1,2,3]).should == true
- IncludeMatcher.new("a", "b", "c").matches?("abc").should == true
+ expect(IncludeMatcher.new(3, 2, 1).matches?([1,2,3])).to eq(true)
+ expect(IncludeMatcher.new("a", "b", "c").matches?("abc")).to eq(true)
end
it "does not match when actual does not include all expected" do
- IncludeMatcher.new(3, 2, 4).matches?([1,2,3]).should == false
- IncludeMatcher.new("a", "b", "c", "d").matches?("abc").should == false
+ expect(IncludeMatcher.new(3, 2, 4).matches?([1,2,3])).to eq(false)
+ expect(IncludeMatcher.new("a", "b", "c", "d").matches?("abc")).to eq(false)
end
it "provides a useful failure message" do
matcher = IncludeMatcher.new(5, 2)
matcher.matches?([1,2,3])
- matcher.failure_message.should == ["Expected [1, 2, 3]", "to include 5"]
+ expect(matcher.failure_message).to eq(["Expected [1, 2, 3]", "to include 5"])
end
it "provides a useful negative failure message" do
matcher = IncludeMatcher.new(1, 2, 3)
matcher.matches?([1,2,3])
- matcher.negative_failure_message.should == ["Expected [1, 2, 3]", "not to include 3"]
+ expect(matcher.negative_failure_message).to eq(["Expected [1, 2, 3]", "not to include 3"])
end
end
diff --git a/spec/mspec/spec/matchers/infinity_spec.rb b/spec/mspec/spec/matchers/infinity_spec.rb
index 6eb8ac2940..78c4194526 100644
--- a/spec/mspec/spec/matchers/infinity_spec.rb
+++ b/spec/mspec/spec/matchers/infinity_spec.rb
@@ -4,31 +4,31 @@ require 'mspec/guards'
require 'mspec/helpers'
require 'mspec/matchers'
-describe InfinityMatcher do
+RSpec.describe InfinityMatcher do
it "matches when actual is infinite and has the correct sign" do
- InfinityMatcher.new(1).matches?(infinity_value).should == true
- InfinityMatcher.new(-1).matches?(-infinity_value).should == true
+ expect(InfinityMatcher.new(1).matches?(infinity_value)).to eq(true)
+ expect(InfinityMatcher.new(-1).matches?(-infinity_value)).to eq(true)
end
it "does not match when actual is not infinite" do
- InfinityMatcher.new(1).matches?(1.0).should == false
- InfinityMatcher.new(-1).matches?(-1.0).should == false
+ expect(InfinityMatcher.new(1).matches?(1.0)).to eq(false)
+ expect(InfinityMatcher.new(-1).matches?(-1.0)).to eq(false)
end
it "does not match when actual is infinite but has the incorrect sign" do
- InfinityMatcher.new(1).matches?(-infinity_value).should == false
- InfinityMatcher.new(-1).matches?(infinity_value).should == false
+ expect(InfinityMatcher.new(1).matches?(-infinity_value)).to eq(false)
+ expect(InfinityMatcher.new(-1).matches?(infinity_value)).to eq(false)
end
it "provides a useful failure message" do
matcher = InfinityMatcher.new(-1)
matcher.matches?(0)
- matcher.failure_message.should == ["Expected 0", "to be -Infinity"]
+ expect(matcher.failure_message).to eq(["Expected 0", "to be -Infinity"])
end
it "provides a useful negative failure message" do
matcher = InfinityMatcher.new(1)
matcher.matches?(infinity_value)
- matcher.negative_failure_message.should == ["Expected Infinity", "not to be Infinity"]
+ expect(matcher.negative_failure_message).to eq(["Expected Infinity", "not to be Infinity"])
end
end
diff --git a/spec/mspec/spec/matchers/match_yaml_spec.rb b/spec/mspec/spec/matchers/match_yaml_spec.rb
index 4f16aee0ec..85123bb87d 100644
--- a/spec/mspec/spec/matchers/match_yaml_spec.rb
+++ b/spec/mspec/spec/matchers/match_yaml_spec.rb
@@ -2,38 +2,38 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe MatchYAMLMatcher do
+RSpec.describe MatchYAMLMatcher do
before :each do
@matcher = MatchYAMLMatcher.new("--- \nfoo: bar\n")
end
it "compares YAML documents and matches if they're equivalent" do
- @matcher.matches?("--- \nfoo: bar\n").should == true
+ expect(@matcher.matches?("--- \nfoo: bar\n")).to eq(true)
end
it "compares YAML documents and does not match if they're not equivalent" do
- @matcher.matches?("--- \nbar: foo\n").should == false
- @matcher.matches?("--- \nfoo: \nbar\n").should == false
+ expect(@matcher.matches?("--- \nbar: foo\n")).to eq(false)
+ expect(@matcher.matches?("--- \nfoo: \nbar\n")).to eq(false)
end
it "also receives objects that respond_to to_yaml" do
matcher = MatchYAMLMatcher.new("some string")
- matcher.matches?("some string").should == true
+ expect(matcher.matches?("some string")).to eq(true)
matcher = MatchYAMLMatcher.new(['a', 'b'])
- matcher.matches?("--- \n- a\n- b\n").should == true
+ expect(matcher.matches?("--- \n- a\n- b\n")).to eq(true)
matcher = MatchYAMLMatcher.new("foo" => "bar")
- matcher.matches?("--- \nfoo: bar\n").should == true
+ expect(matcher.matches?("--- \nfoo: bar\n")).to eq(true)
end
it "matches documents with trailing whitespace" do
- @matcher.matches?("--- \nfoo: bar \n").should == true
- @matcher.matches?("--- \nfoo: bar \n").should == true
+ expect(@matcher.matches?("--- \nfoo: bar \n")).to eq(true)
+ expect(@matcher.matches?("--- \nfoo: bar \n")).to eq(true)
end
it "fails with a descriptive error message" do
- @matcher.matches?("foo").should == false
- @matcher.failure_message.should == ["Expected \"foo\"", " to match \"--- \\nfoo: bar\\n\""]
+ expect(@matcher.matches?("foo")).to eq(false)
+ expect(@matcher.failure_message).to eq(["Expected \"foo\"", " to match \"--- \\nfoo: bar\\n\""])
end
end
diff --git a/spec/mspec/spec/matchers/output_spec.rb b/spec/mspec/spec/matchers/output_spec.rb
index 264da3b569..3baad9a4b2 100644
--- a/spec/mspec/spec/matchers/output_spec.rb
+++ b/spec/mspec/spec/matchers/output_spec.rb
@@ -2,73 +2,83 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe OutputMatcher do
+RSpec.describe OutputMatcher do
it "matches when executing the proc results in the expected output to $stdout" do
proc = Proc.new { puts "bang!" }
- OutputMatcher.new("bang!\n", nil).matches?(proc).should == true
- OutputMatcher.new("pop", nil).matches?(proc).should == false
- OutputMatcher.new(/bang/, nil).matches?(proc).should == true
- OutputMatcher.new(/po/, nil).matches?(proc).should == false
+ expect(OutputMatcher.new("bang!\n", nil).matches?(proc)).to eq(true)
+ expect(OutputMatcher.new("pop", nil).matches?(proc)).to eq(false)
+ expect(OutputMatcher.new(/bang/, nil).matches?(proc)).to eq(true)
+ expect(OutputMatcher.new(/po/, nil).matches?(proc)).to eq(false)
end
it "matches when executing the proc results in the expected output to $stderr" do
proc = Proc.new { $stderr.write "boom!" }
- OutputMatcher.new(nil, "boom!").matches?(proc).should == true
- OutputMatcher.new(nil, "fizzle").matches?(proc).should == false
- OutputMatcher.new(nil, /boom/).matches?(proc).should == true
- OutputMatcher.new(nil, /fizzl/).matches?(proc).should == false
+ expect(OutputMatcher.new(nil, "boom!").matches?(proc)).to eq(true)
+ expect(OutputMatcher.new(nil, "fizzle").matches?(proc)).to eq(false)
+ expect(OutputMatcher.new(nil, /boom/).matches?(proc)).to eq(true)
+ expect(OutputMatcher.new(nil, /fizzl/).matches?(proc)).to eq(false)
end
it "provides a useful failure message" do
proc = Proc.new { print "unexpected"; $stderr.print "unerror" }
matcher = OutputMatcher.new("expected", "error")
matcher.matches?(proc)
- matcher.failure_message.should ==
+ expect(matcher.failure_message).to eq(
["Expected:\n $stdout: \"expected\"\n $stderr: \"error\"\n",
" got:\n $stdout: \"unexpected\"\n $stderr: \"unerror\"\n"]
+ )
matcher = OutputMatcher.new("expected", nil)
matcher.matches?(proc)
- matcher.failure_message.should ==
+ expect(matcher.failure_message).to eq(
["Expected:\n $stdout: \"expected\"\n",
" got:\n $stdout: \"unexpected\"\n"]
+ )
matcher = OutputMatcher.new(nil, "error")
matcher.matches?(proc)
- matcher.failure_message.should ==
+ expect(matcher.failure_message).to eq(
["Expected:\n $stderr: \"error\"\n",
" got:\n $stderr: \"unerror\"\n"]
+ )
matcher = OutputMatcher.new(/base/, nil)
matcher.matches?(proc)
- matcher.failure_message.should ==
+ expect(matcher.failure_message).to eq(
["Expected:\n $stdout: /base/\n",
" got:\n $stdout: \"unexpected\"\n"]
+ )
matcher = OutputMatcher.new(nil, /octave/)
matcher.matches?(proc)
- matcher.failure_message.should ==
+ expect(matcher.failure_message).to eq(
["Expected:\n $stderr: /octave/\n",
" got:\n $stderr: \"unerror\"\n"]
+ )
end
it "provides a useful negative failure message" do
proc = Proc.new { puts "expected"; $stderr.puts "error" }
matcher = OutputMatcher.new("expected", "error")
matcher.matches?(proc)
- matcher.negative_failure_message.should ==
+ expect(matcher.negative_failure_message).to eq(
["Expected output not to be:\n", " $stdout: \"expected\"\n $stderr: \"error\"\n"]
+ )
matcher = OutputMatcher.new("expected", nil)
matcher.matches?(proc)
- matcher.negative_failure_message.should ==
+ expect(matcher.negative_failure_message).to eq(
["Expected output not to be:\n", " $stdout: \"expected\"\n"]
+ )
matcher = OutputMatcher.new(nil, "error")
matcher.matches?(proc)
- matcher.negative_failure_message.should ==
+ expect(matcher.negative_failure_message).to eq(
["Expected output not to be:\n", " $stderr: \"error\"\n"]
+ )
matcher = OutputMatcher.new(/expect/, nil)
matcher.matches?(proc)
- matcher.negative_failure_message.should ==
+ expect(matcher.negative_failure_message).to eq(
["Expected output not to be:\n", " $stdout: \"expected\"\n"]
+ )
matcher = OutputMatcher.new(nil, /err/)
matcher.matches?(proc)
- matcher.negative_failure_message.should ==
+ expect(matcher.negative_failure_message).to eq(
["Expected output not to be:\n", " $stderr: \"error\"\n"]
+ )
end
end
diff --git a/spec/mspec/spec/matchers/output_to_fd_spec.rb b/spec/mspec/spec/matchers/output_to_fd_spec.rb
index e584c4e003..a39cab3206 100644
--- a/spec/mspec/spec/matchers/output_to_fd_spec.rb
+++ b/spec/mspec/spec/matchers/output_to_fd_spec.rb
@@ -2,43 +2,43 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe OutputToFDMatcher do
+RSpec.describe OutputToFDMatcher do
# Figure out how in the hell to achieve this
it "matches when running the block produces the expected output to the given FD" do
- OutputToFDMatcher.new("Hi\n", STDERR).matches?(lambda { $stderr.print "Hi\n" }).should == true
+ expect(OutputToFDMatcher.new("Hi\n", STDERR).matches?(lambda { $stderr.print "Hi\n" })).to eq(true)
end
it "does not match if running the block does not produce the expected output to the FD" do
- OutputToFDMatcher.new("Hi\n", STDERR).matches?(lambda { $stderr.puts("Hello\n") }).should == false
+ expect(OutputToFDMatcher.new("Hi\n", STDERR).matches?(lambda { $stderr.puts("Hello\n") })).to eq(false)
end
it "propagate the exception if one is thrown while matching" do
exc = RuntimeError.new("propagates")
- lambda {
- OutputToFDMatcher.new("Hi\n", STDERR).matches?(lambda {
+ expect {
+ expect(OutputToFDMatcher.new("Hi\n", STDERR).matches?(lambda {
raise exc
- }).should == false
- }.should raise_error(exc)
+ })).to eq(false)
+ }.to raise_error(exc)
end
it "defaults to matching against STDOUT" do
object = Object.new
object.extend MSpecMatchers
- object.send(:output_to_fd, "Hi\n").matches?(lambda { $stdout.print "Hi\n" }).should == true
+ expect(object.send(:output_to_fd, "Hi\n").matches?(lambda { $stdout.print "Hi\n" })).to eq(true)
end
it "accepts any IO instance" do
io = IO.new STDOUT.fileno
- OutputToFDMatcher.new("Hi\n", io).matches?(lambda { io.print "Hi\n" }).should == true
+ expect(OutputToFDMatcher.new("Hi\n", io).matches?(lambda { io.print "Hi\n" })).to eq(true)
end
it "allows matching with a Regexp" do
s = "Hi there\n"
- OutputToFDMatcher.new(/Hi/, STDERR).matches?(lambda { $stderr.print s }).should == true
- OutputToFDMatcher.new(/Hi?/, STDERR).matches?(lambda { $stderr.print s }).should == true
- OutputToFDMatcher.new(/[hH]i?/, STDERR).matches?(lambda { $stderr.print s }).should == true
- OutputToFDMatcher.new(/.*/, STDERR).matches?(lambda { $stderr.print s }).should == true
- OutputToFDMatcher.new(/H.*?here/, STDERR).matches?(lambda { $stderr.print s }).should == true
- OutputToFDMatcher.new(/Ahoy/, STDERR).matches?(lambda { $stderr.print s }).should == false
+ expect(OutputToFDMatcher.new(/Hi/, STDERR).matches?(lambda { $stderr.print s })).to eq(true)
+ expect(OutputToFDMatcher.new(/Hi?/, STDERR).matches?(lambda { $stderr.print s })).to eq(true)
+ expect(OutputToFDMatcher.new(/[hH]i?/, STDERR).matches?(lambda { $stderr.print s })).to eq(true)
+ expect(OutputToFDMatcher.new(/.*/, STDERR).matches?(lambda { $stderr.print s })).to eq(true)
+ expect(OutputToFDMatcher.new(/H.*?here/, STDERR).matches?(lambda { $stderr.print s })).to eq(true)
+ expect(OutputToFDMatcher.new(/Ahoy/, STDERR).matches?(lambda { $stderr.print s })).to eq(false)
end
end
diff --git a/spec/mspec/spec/matchers/raise_error_spec.rb b/spec/mspec/spec/matchers/raise_error_spec.rb
index a40acc0ea0..8613eee118 100644
--- a/spec/mspec/spec/matchers/raise_error_spec.rb
+++ b/spec/mspec/spec/matchers/raise_error_spec.rb
@@ -1,79 +1,94 @@
require 'spec_helper'
-require 'mspec/expectations/expectations'
-require 'mspec/matchers'
class ExpectedException < Exception; end
class UnexpectedException < Exception; end
-describe RaiseErrorMatcher do
+RSpec.describe RaiseErrorMatcher do
+ before :each do
+ state = double("run state").as_null_object
+ allow(MSpec).to receive(:current).and_return(state)
+ end
+
it "matches when the proc raises the expected exception" do
proc = Proc.new { raise ExpectedException }
matcher = RaiseErrorMatcher.new(ExpectedException, nil)
- matcher.matches?(proc).should == true
+ expect(matcher.matches?(proc)).to eq(true)
end
- it "executes its optional block if matched" do
+ it "executes its optional {/} block if matched" do
+ ensure_mspec_method(-> {}.method(:should))
+
run = false
- proc = Proc.new { raise ExpectedException }
- matcher = RaiseErrorMatcher.new(ExpectedException, nil) { |error|
+ -> { raise ExpectedException }.should PublicMSpecMatchers.raise_error { |error|
+ expect(error.class).to eq(ExpectedException)
run = true
- error.class.should == ExpectedException
}
+ expect(run).to eq(true)
+ end
- matcher.matches?(proc).should == true
- run.should == true
+ it "executes its optional do/end block if matched" do
+ ensure_mspec_method(-> {}.method(:should))
+
+ run = false
+ -> { raise ExpectedException }.should PublicMSpecMatchers.raise_error do |error|
+ expect(error.class).to eq(ExpectedException)
+ run = true
+ end
+ expect(run).to eq(true)
end
it "matches when the proc raises the expected exception with the expected message" do
proc = Proc.new { raise ExpectedException, "message" }
matcher = RaiseErrorMatcher.new(ExpectedException, "message")
- matcher.matches?(proc).should == true
+ expect(matcher.matches?(proc)).to eq(true)
end
it "matches when the proc raises the expected exception with a matching message" do
proc = Proc.new { raise ExpectedException, "some message" }
matcher = RaiseErrorMatcher.new(ExpectedException, /some/)
- matcher.matches?(proc).should == true
+ expect(matcher.matches?(proc)).to eq(true)
end
it "does not match when the proc does not raise the expected exception" do
exc = UnexpectedException.new
matcher = RaiseErrorMatcher.new(ExpectedException, nil)
- matcher.matching_exception?(exc).should == false
- lambda {
+ expect(matcher.matching_exception?(exc)).to eq(false)
+ expect {
matcher.matches?(Proc.new { raise exc })
- }.should raise_error(UnexpectedException)
+ }.to raise_error(UnexpectedException)
end
it "does not match when the proc raises the expected exception with an unexpected message" do
exc = ExpectedException.new("unexpected")
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
- matcher.matching_exception?(exc).should == false
- lambda {
+ expect(matcher.matching_exception?(exc)).to eq(false)
+ expect {
matcher.matches?(Proc.new { raise exc })
- }.should raise_error(ExpectedException)
+ }.to raise_error(ExpectedException)
end
it "does not match when the proc does not raise an exception" do
proc = Proc.new {}
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
- matcher.matches?(proc).should == false
+ expect(matcher.matches?(proc)).to eq(false)
end
it "provides a useful failure message when the exception class differs" do
exc = UnexpectedException.new("message")
matcher = RaiseErrorMatcher.new(ExpectedException, "message")
- matcher.matching_exception?(exc).should == false
+ expect(matcher.matching_exception?(exc)).to eq(false)
begin
matcher.matches?(Proc.new { raise exc })
rescue UnexpectedException => e
- matcher.failure_message.should ==
+ expect(matcher.failure_message).to eq(
["Expected ExpectedException (message)", "but got: UnexpectedException (message)"]
- ExceptionState.new(nil, nil, e).message.should ==
+ )
+ expect(ExceptionState.new(nil, nil, e).message).to eq(
"Expected ExpectedException (message)\nbut got: UnexpectedException (message)"
+ )
else
raise "no exception"
end
@@ -83,14 +98,16 @@ describe RaiseErrorMatcher do
exc = ExpectedException.new("unexpected")
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
- matcher.matching_exception?(exc).should == false
+ expect(matcher.matching_exception?(exc)).to eq(false)
begin
matcher.matches?(Proc.new { raise exc })
rescue ExpectedException => e
- matcher.failure_message.should ==
+ expect(matcher.failure_message).to eq(
["Expected ExpectedException (expected)", "but got: ExpectedException (unexpected)"]
- ExceptionState.new(nil, nil, e).message.should ==
+ )
+ expect(ExceptionState.new(nil, nil, e).message).to eq(
"Expected ExpectedException (expected)\nbut got: ExpectedException (unexpected)"
+ )
else
raise "no exception"
end
@@ -100,14 +117,16 @@ describe RaiseErrorMatcher do
exc = UnexpectedException.new("unexpected")
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
- matcher.matching_exception?(exc).should == false
+ expect(matcher.matching_exception?(exc)).to eq(false)
begin
matcher.matches?(Proc.new { raise exc })
rescue UnexpectedException => e
- matcher.failure_message.should ==
+ expect(matcher.failure_message).to eq(
["Expected ExpectedException (expected)", "but got: UnexpectedException (unexpected)"]
- ExceptionState.new(nil, nil, e).message.should ==
+ )
+ expect(ExceptionState.new(nil, nil, e).message).to eq(
"Expected ExpectedException (expected)\nbut got: UnexpectedException (unexpected)"
+ )
else
raise "no exception"
end
@@ -117,16 +136,18 @@ describe RaiseErrorMatcher do
proc = Proc.new { 120 }
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
matcher.matches?(proc)
- matcher.failure_message.should ==
+ expect(matcher.failure_message).to eq(
["Expected ExpectedException (expected)", "but no exception was raised (120 was returned)"]
+ )
end
it "provides a useful failure message when no exception is raised and nil is returned" do
proc = Proc.new { nil }
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
matcher.matches?(proc)
- matcher.failure_message.should ==
+ expect(matcher.failure_message).to eq(
["Expected ExpectedException (expected)", "but no exception was raised (nil was returned)"]
+ )
end
it "provides a useful failure message when no exception is raised and the result raises in #pretty_inspect" do
@@ -137,23 +158,26 @@ describe RaiseErrorMatcher do
proc = Proc.new { result }
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
matcher.matches?(proc)
- matcher.failure_message.should ==
+ expect(matcher.failure_message).to eq(
["Expected ExpectedException (expected)", "but no exception was raised (#<Object>(#pretty_inspect raised #<ArgumentError: bad>) was returned)"]
+ )
end
it "provides a useful negative failure message" do
proc = Proc.new { raise ExpectedException, "expected" }
matcher = RaiseErrorMatcher.new(ExpectedException, "expected")
matcher.matches?(proc)
- matcher.negative_failure_message.should ==
+ expect(matcher.negative_failure_message).to eq(
["Expected to not get ExpectedException (expected)", ""]
+ )
end
it "provides a useful negative failure message for strict subclasses of the matched exception class" do
proc = Proc.new { raise UnexpectedException, "unexpected" }
matcher = RaiseErrorMatcher.new(Exception, nil)
matcher.matches?(proc)
- matcher.negative_failure_message.should ==
+ expect(matcher.negative_failure_message).to eq(
["Expected to not get Exception", "but got: UnexpectedException (unexpected)"]
+ )
end
end
diff --git a/spec/mspec/spec/matchers/respond_to_spec.rb b/spec/mspec/spec/matchers/respond_to_spec.rb
index 988caf4dff..6f1cd8d148 100644
--- a/spec/mspec/spec/matchers/respond_to_spec.rb
+++ b/spec/mspec/spec/matchers/respond_to_spec.rb
@@ -2,32 +2,32 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe RespondToMatcher do
+RSpec.describe RespondToMatcher do
it "matches when actual does respond_to? expected" do
- RespondToMatcher.new(:to_s).matches?(Object.new).should == true
- RespondToMatcher.new(:inject).matches?([]).should == true
- RespondToMatcher.new(:[]).matches?(1).should == true
- RespondToMatcher.new(:[]=).matches?("string").should == true
+ expect(RespondToMatcher.new(:to_s).matches?(Object.new)).to eq(true)
+ expect(RespondToMatcher.new(:inject).matches?([])).to eq(true)
+ expect(RespondToMatcher.new(:[]).matches?(1)).to eq(true)
+ expect(RespondToMatcher.new(:[]=).matches?("string")).to eq(true)
end
it "does not match when actual does not respond_to? expected" do
- RespondToMatcher.new(:to_i).matches?(Object.new).should == false
- RespondToMatcher.new(:inject).matches?(1).should == false
- RespondToMatcher.new(:non_existent_method).matches?([]).should == false
- RespondToMatcher.new(:[]=).matches?(1).should == false
+ expect(RespondToMatcher.new(:to_i).matches?(Object.new)).to eq(false)
+ expect(RespondToMatcher.new(:inject).matches?(1)).to eq(false)
+ expect(RespondToMatcher.new(:non_existent_method).matches?([])).to eq(false)
+ expect(RespondToMatcher.new(:[]=).matches?(1)).to eq(false)
end
it "provides a useful failure message" do
matcher = RespondToMatcher.new(:non_existent_method)
matcher.matches?('string')
- matcher.failure_message.should == [
- "Expected \"string\" (String)", "to respond to non_existent_method"]
+ expect(matcher.failure_message).to eq([
+ "Expected \"string\" (String)", "to respond to non_existent_method"])
end
it "provides a useful negative failure message" do
matcher = RespondToMatcher.new(:to_i)
matcher.matches?(4.0)
- matcher.negative_failure_message.should == [
- "Expected 4.0 (Float)", "not to respond to to_i"]
+ expect(matcher.negative_failure_message).to eq([
+ "Expected 4.0 (Float)", "not to respond to to_i"])
end
end
diff --git a/spec/mspec/spec/matchers/signed_zero_spec.rb b/spec/mspec/spec/matchers/signed_zero_spec.rb
index 9c5c50c602..6d1c1007bc 100644
--- a/spec/mspec/spec/matchers/signed_zero_spec.rb
+++ b/spec/mspec/spec/matchers/signed_zero_spec.rb
@@ -2,31 +2,31 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-describe SignedZeroMatcher do
+RSpec.describe SignedZeroMatcher do
it "matches when actual is zero and has the correct sign" do
- SignedZeroMatcher.new(1).matches?(0.0).should == true
- SignedZeroMatcher.new(-1).matches?(-0.0).should == true
+ expect(SignedZeroMatcher.new(1).matches?(0.0)).to eq(true)
+ expect(SignedZeroMatcher.new(-1).matches?(-0.0)).to eq(true)
end
it "does not match when actual is non-zero" do
- SignedZeroMatcher.new(1).matches?(1.0).should == false
- SignedZeroMatcher.new(-1).matches?(-1.0).should == false
+ expect(SignedZeroMatcher.new(1).matches?(1.0)).to eq(false)
+ expect(SignedZeroMatcher.new(-1).matches?(-1.0)).to eq(false)
end
it "does not match when actual is zero but has the incorrect sign" do
- SignedZeroMatcher.new(1).matches?(-0.0).should == false
- SignedZeroMatcher.new(-1).matches?(0.0).should == false
+ expect(SignedZeroMatcher.new(1).matches?(-0.0)).to eq(false)
+ expect(SignedZeroMatcher.new(-1).matches?(0.0)).to eq(false)
end
it "provides a useful failure message" do
matcher = SignedZeroMatcher.new(-1)
matcher.matches?(0.0)
- matcher.failure_message.should == ["Expected 0.0", "to be -0.0"]
+ expect(matcher.failure_message).to eq(["Expected 0.0", "to be -0.0"])
end
it "provides a useful negative failure message" do
matcher = SignedZeroMatcher.new(-1)
matcher.matches?(-0.0)
- matcher.negative_failure_message.should == ["Expected -0.0", "not to be -0.0"]
+ expect(matcher.negative_failure_message).to eq(["Expected -0.0", "not to be -0.0"])
end
end