summaryrefslogtreecommitdiff
path: root/spec/mspec/spec/expectations
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mspec/spec/expectations')
-rw-r--r--spec/mspec/spec/expectations/expectations_spec.rb18
-rw-r--r--spec/mspec/spec/expectations/should.rb73
-rw-r--r--spec/mspec/spec/expectations/should_spec.rb18
3 files changed, 18 insertions, 91 deletions
diff --git a/spec/mspec/spec/expectations/expectations_spec.rb b/spec/mspec/spec/expectations/expectations_spec.rb
index fea692f3e3..371829d4f9 100644
--- a/spec/mspec/spec/expectations/expectations_spec.rb
+++ b/spec/mspec/spec/expectations/expectations_spec.rb
@@ -1,29 +1,29 @@
require 'spec_helper'
require 'mspec/expectations/expectations'
-describe SpecExpectationNotMetError do
+RSpec.describe SpecExpectationNotMetError do
it "is a subclass of StandardError" do
- SpecExpectationNotMetError.ancestors.should include(StandardError)
+ expect(SpecExpectationNotMetError.ancestors).to include(StandardError)
end
end
-describe SpecExpectationNotFoundError do
+RSpec.describe SpecExpectationNotFoundError do
it "is a subclass of StandardError" do
- SpecExpectationNotFoundError.ancestors.should include(StandardError)
+ expect(SpecExpectationNotFoundError.ancestors).to include(StandardError)
end
end
-describe SpecExpectationNotFoundError, "#message" do
+RSpec.describe SpecExpectationNotFoundError, "#message" do
it "returns 'No behavior expectation was found in the example'" do
m = SpecExpectationNotFoundError.new.message
- m.should == "No behavior expectation was found in the example"
+ expect(m).to eq("No behavior expectation was found in the example")
end
end
-describe SpecExpectation, "#fail_with" do
+RSpec.describe SpecExpectation, "#fail_with" do
it "raises an SpecExpectationNotMetError" do
- lambda {
+ expect {
SpecExpectation.fail_with "expected this", "to equal that"
- }.should raise_error(SpecExpectationNotMetError, "expected this to equal that")
+ }.to raise_error(SpecExpectationNotMetError, "expected this to equal that")
end
end
diff --git a/spec/mspec/spec/expectations/should.rb b/spec/mspec/spec/expectations/should.rb
deleted file mode 100644
index 48503b1631..0000000000
--- a/spec/mspec/spec/expectations/should.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-$: << File.dirname(__FILE__) + '/../../lib'
-require 'mspec'
-require 'mspec/utils/script'
-
-# The purpose of these specs is to confirm that the #should
-# and #should_not methods are functioning appropriately. We
-# use a separate spec file that is invoked from the MSpec
-# specs but is run by MSpec. This avoids conflicting with
-# RSpec's #should and #should_not methods.
-
-class ShouldSpecsMonitor
- def initialize
- @called = 0
- end
-
- def expectation(state)
- @called += 1
- end
-
- def finish
- puts "I was called #{@called} times"
- end
-end
-
-# Simplistic runner
-formatter = DottedFormatter.new
-formatter.register
-
-monitor = ShouldSpecsMonitor.new
-MSpec.register :expectation, monitor
-MSpec.register :finish, monitor
-
-at_exit { MSpec.actions :finish }
-
-MSpec.actions :start
-MSpec.setup_env
-
-# Specs
-describe "MSpec expectation method #should" do
- it "accepts a matcher" do
- :sym.should be_kind_of(Symbol)
- end
-
- it "causes a failure to be recorded" do
- 1.should == 2
- end
-
- it "registers that an expectation has been encountered" do
- # an empty example block causes an exception because
- # no expectation was encountered
- end
-
- it "invokes the MSpec :expectation actions" do
- 1.should == 1
- end
-end
-
-describe "MSpec expectation method #should_not" do
- it "accepts a matcher" do
- "sym".should_not be_kind_of(Symbol)
- end
-
- it "causes a failure to be recorded" do
- 1.should_not == 1
- end
-
- it "registers that an expectation has been encountered" do
- end
-
- it "invokes the MSpec :expectation actions" do
- 1.should_not == 2
- end
-end
diff --git a/spec/mspec/spec/expectations/should_spec.rb b/spec/mspec/spec/expectations/should_spec.rb
index b8bda8f86f..472890979d 100644
--- a/spec/mspec/spec/expectations/should_spec.rb
+++ b/spec/mspec/spec/expectations/should_spec.rb
@@ -1,17 +1,17 @@
require 'spec_helper'
require 'rbconfig'
-describe "MSpec" do
+RSpec.describe "MSpec" do
before :all do
path = RbConfig::CONFIG['bindir']
exe = RbConfig::CONFIG['ruby_install_name']
- file = File.dirname(__FILE__) + '/should.rb'
+ file = File.expand_path('../../fixtures/should.rb', __FILE__)
@out = `#{path}/#{exe} #{file}`
end
describe "#should" do
it "records failures" do
- @out.should include <<-EOS
+ expect(@out).to include <<-EOS
1)
MSpec expectation method #should causes a failure to be recorded FAILED
Expected 1 == 2
@@ -20,7 +20,7 @@ EOS
end
it "raises exceptions for examples with no expectations" do
- @out.should include <<-EOS
+ expect(@out).to include <<-EOS
2)
MSpec expectation method #should registers that an expectation has been encountered FAILED
No behavior expectation was found in the example
@@ -30,7 +30,7 @@ EOS
describe "#should_not" do
it "records failures" do
- @out.should include <<-EOS
+ expect(@out).to include <<-EOS
3)
MSpec expectation method #should_not causes a failure to be recorded FAILED
Expected 1 == 1
@@ -39,7 +39,7 @@ EOS
end
it "raises exceptions for examples with no expectations" do
- @out.should include <<-EOS
+ expect(@out).to include <<-EOS
4)
MSpec expectation method #should_not registers that an expectation has been encountered FAILED
No behavior expectation was found in the example
@@ -48,14 +48,14 @@ EOS
end
it "prints status information" do
- @out.should include ".FF..FF."
+ expect(@out).to include ".FF..FF."
end
it "prints out a summary" do
- @out.should include "0 files, 8 examples, 6 expectations, 4 failures, 0 errors"
+ expect(@out).to include "0 files, 8 examples, 6 expectations, 4 failures, 0 errors"
end
it "records expectations" do
- @out.should include "I was called 6 times"
+ expect(@out).to include "I was called 6 times"
end
end