summaryrefslogtreecommitdiff
path: root/spec/mspec/spec
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-14 15:56:09 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-14 15:56:09 +0000
commit49a864ad902c7e819f2464f1001e9719a9af6cb5 (patch)
tree3b084371c3dfc8cb6eda885094b9470014c8e48b /spec/mspec/spec
parent3efe410dd0812a3781b9f75a52d67a632009b2d2 (diff)
Update to ruby/mspec@5bd9409
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/mspec/spec')
-rw-r--r--spec/mspec/spec/commands/mkspec_spec.rb8
-rw-r--r--spec/mspec/spec/commands/mspec_ci_spec.rb28
-rw-r--r--spec/mspec/spec/guards/guard_spec.rb7
-rw-r--r--spec/mspec/spec/guards/support_spec.rb23
-rw-r--r--spec/mspec/spec/helpers/io_spec.rb6
-rw-r--r--spec/mspec/spec/matchers/be_kind_of_spec.rb4
-rw-r--r--spec/mspec/spec/matchers/have_class_variable_spec.rb23
-rw-r--r--spec/mspec/spec/matchers/have_instance_variable_spec.rb23
-rw-r--r--spec/mspec/spec/runner/context_spec.rb2
-rw-r--r--spec/mspec/spec/runner/mspec_spec.rb4
-rw-r--r--spec/mspec/spec/spec_helper.rb2
11 files changed, 43 insertions, 87 deletions
diff --git a/spec/mspec/spec/commands/mkspec_spec.rb b/spec/mspec/spec/commands/mkspec_spec.rb
index ab3410af50..14c363f286 100644
--- a/spec/mspec/spec/commands/mkspec_spec.rb
+++ b/spec/mspec/spec/commands/mkspec_spec.rb
@@ -38,7 +38,7 @@ describe "The -b, --base DIR option" do
@options.stub(:on)
@options.should_receive(:on).with("-b", "--base", "DIR",
an_instance_of(String))
- @script.options
+ @script.options []
end
it "sets the base directory relative to which the spec directories are created" do
@@ -62,7 +62,7 @@ describe "The -r, --require LIBRARY option" do
@options.stub(:on)
@options.should_receive(:on).with("-r", "--require", "LIBRARY",
an_instance_of(String))
- @script.options
+ @script.options []
end
it "adds CONSTANT to the list of constants" do
@@ -86,7 +86,7 @@ describe "The -V, --version-guard VERSION option" do
@options.stub(:on)
@options.should_receive(:on).with("-V", "--version-guard", "VERSION",
an_instance_of(String))
- @script.options
+ @script.options []
end
it "sets the version for the ruby_version_is guards to VERSION" do
@@ -119,7 +119,7 @@ describe MkSpec, "#options" do
@options.should_receive(:raise).with(MSpecOptions::ParseError, an_instance_of(String))
@options.stub(:puts)
@options.stub(:exit)
- @script.options "--iunknown"
+ @script.options ["--iunknown"]
end
end
diff --git a/spec/mspec/spec/commands/mspec_ci_spec.rb b/spec/mspec/spec/commands/mspec_ci_spec.rb
index 5221363953..a90cbd8d0d 100644
--- a/spec/mspec/spec/commands/mspec_ci_spec.rb
+++ b/spec/mspec/spec/commands/mspec_ci_spec.rb
@@ -15,17 +15,17 @@ describe MSpecCI, "#options" do
it "enables the chdir option" do
@options.should_receive(:chdir)
- @script.options
+ @script.options []
end
it "enables the prefix option" do
@options.should_receive(:prefix)
- @script.options
+ @script.options []
end
it "enables the config option" do
@options.should_receive(:configure)
- @script.options
+ @script.options []
end
it "provides a custom action (block) to the config option" do
@@ -35,52 +35,52 @@ describe MSpecCI, "#options" do
it "enables the dry run option" do
@options.should_receive(:pretend)
- @script.options
+ @script.options []
end
it "enables the unguarded option" do
@options.should_receive(:unguarded)
- @script.options
+ @script.options []
end
it "enables the interrupt single specs option" do
@options.should_receive(:interrupt)
- @script.options
+ @script.options []
end
it "enables the formatter options" do
@options.should_receive(:formatters)
- @script.options
+ @script.options []
end
it "enables the verbose option" do
@options.should_receive(:verbose)
- @script.options
+ @script.options []
end
it "enables the action options" do
@options.should_receive(:actions)
- @script.options
+ @script.options []
end
it "enables the action filter options" do
@options.should_receive(:action_filters)
- @script.options
+ @script.options []
end
it "enables the version option" do
@options.should_receive(:version)
- @script.options
+ @script.options []
end
it "enables the help option" do
@options.should_receive(:help)
- @script.options
+ @script.options []
end
it "calls #custom_options" do
@script.should_receive(:custom_options).with(@options)
- @script.options
+ @script.options []
end
end
@@ -99,7 +99,7 @@ describe MSpecCI, "#run" do
@script.stub(:exit)
@script.stub(:config).and_return(@config)
@script.stub(:files).and_return(["one", "two"])
- @script.options
+ @script.options []
end
it "registers the tags patterns" do
diff --git a/spec/mspec/spec/guards/guard_spec.rb b/spec/mspec/spec/guards/guard_spec.rb
index f2828dd4ad..5c3dae4b3f 100644
--- a/spec/mspec/spec/guards/guard_spec.rb
+++ b/spec/mspec/spec/guards/guard_spec.rb
@@ -4,12 +4,7 @@ require 'rbconfig'
describe SpecGuard, ".ruby_version" do
before :each do
- @ruby_version = Object.const_get :RUBY_VERSION
- Object.const_set :RUBY_VERSION, "8.2.3"
- end
-
- after :each do
- Object.const_set :RUBY_VERSION, @ruby_version
+ stub_const "RUBY_VERSION", "8.2.3"
end
it "returns the full version for :full" do
diff --git a/spec/mspec/spec/guards/support_spec.rb b/spec/mspec/spec/guards/support_spec.rb
index f899ad02f6..38414abebd 100644
--- a/spec/mspec/spec/guards/support_spec.rb
+++ b/spec/mspec/spec/guards/support_spec.rb
@@ -2,27 +2,12 @@ require 'spec_helper'
require 'mspec/guards'
describe Object, "#not_supported_on" do
- before :all do
- @verbose = $VERBOSE
- $VERBOSE = nil
- @ruby_engine = Object.const_get :RUBY_ENGINE if Object.const_defined? :RUBY_ENGINE
- end
-
- after :all do
- $VERBOSE = @verbose
- if @ruby_engine
- Object.const_set :RUBY_ENGINE, @ruby_engine
- else
- Object.send :remove_const, :RUBY_ENGINE
- end
- end
-
before :each do
ScratchPad.clear
end
it "raises an Exception when passed :ruby" do
- Object.const_set :RUBY_ENGINE, "jruby"
+ stub_const "RUBY_ENGINE", "jruby"
lambda {
not_supported_on(:ruby) { ScratchPad.record :yield }
}.should raise_error(Exception)
@@ -30,19 +15,19 @@ describe Object, "#not_supported_on" do
end
it "does not yield when #implementation? returns true" do
- Object.const_set :RUBY_ENGINE, "jruby"
+ stub_const "RUBY_ENGINE", "jruby"
not_supported_on(:jruby) { ScratchPad.record :yield }
ScratchPad.recorded.should_not == :yield
end
it "yields when #standard? returns true" do
- Object.const_set :RUBY_ENGINE, "ruby"
+ stub_const "RUBY_ENGINE", "ruby"
not_supported_on(:rubinius) { ScratchPad.record :yield }
ScratchPad.recorded.should == :yield
end
it "yields when #implementation? returns false" do
- Object.const_set :RUBY_ENGINE, "jruby"
+ stub_const "RUBY_ENGINE", "jruby"
not_supported_on(:rubinius) { ScratchPad.record :yield }
ScratchPad.recorded.should == :yield
end
diff --git a/spec/mspec/spec/helpers/io_spec.rb b/spec/mspec/spec/helpers/io_spec.rb
index 6dfd81ee56..3219f59947 100644
--- a/spec/mspec/spec/helpers/io_spec.rb
+++ b/spec/mspec/spec/helpers/io_spec.rb
@@ -60,9 +60,9 @@ describe Object, "#new_fd" do
rm_r @name
end
- it "returns a Fixnum that can be used to create an IO instance" do
+ it "returns a Integer that can be used to create an IO instance" do
fd = new_fd @name
- fd.should be_an_instance_of(Fixnum)
+ fd.should be_kind_of(Integer)
@io = IO.new fd, fmode('w:utf-8')
@io.sync = true
@@ -74,7 +74,7 @@ describe Object, "#new_fd" do
it "accepts an options Hash" do
FeatureGuard.stub(:enabled?).and_return(true)
fd = new_fd @name, { :mode => 'w:utf-8' }
- fd.should be_an_instance_of(Fixnum)
+ fd.should be_kind_of(Integer)
@io = IO.new fd, fmode('w:utf-8')
@io.sync = true
diff --git a/spec/mspec/spec/matchers/be_kind_of_spec.rb b/spec/mspec/spec/matchers/be_kind_of_spec.rb
index 554ae6aa82..7c4a59f7b9 100644
--- a/spec/mspec/spec/matchers/be_kind_of_spec.rb
+++ b/spec/mspec/spec/matchers/be_kind_of_spec.rb
@@ -4,8 +4,8 @@ require 'mspec/matchers'
describe BeKindOfMatcher do
it "matches when actual is a kind_of? expected" do
- BeKindOfMatcher.new(Integer).matches?(1).should == true
- BeKindOfMatcher.new(Fixnum).matches?(2).should == true
+ BeKindOfMatcher.new(Numeric).matches?(1).should == true
+ BeKindOfMatcher.new(Integer).matches?(2).should == true
BeKindOfMatcher.new(Regexp).matches?(/m/).should == true
end
diff --git a/spec/mspec/spec/matchers/have_class_variable_spec.rb b/spec/mspec/spec/matchers/have_class_variable_spec.rb
index e440050056..01ba9d0f57 100644
--- a/spec/mspec/spec/matchers/have_class_variable_spec.rb
+++ b/spec/mspec/spec/matchers/have_class_variable_spec.rb
@@ -2,13 +2,13 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-class IVarModMock; end
-
-shared_examples_for "have_class_variable, on all Ruby versions" do
- after :all do
- Object.const_set :RUBY_VERSION, @ruby_version
+class IVarModMock
+ def self.class_variables
+ [:@foo]
end
+end
+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
@@ -47,16 +47,3 @@ shared_examples_for "have_class_variable, on all Ruby versions" do
]
end
end
-
-describe HaveClassVariableMatcher, "on RUBY_VERSION >= 1.9" do
- before :all do
- @ruby_version = Object.const_get :RUBY_VERSION
- Object.const_set :RUBY_VERSION, '1.9.0'
-
- def IVarModMock.class_variables
- [:@foo]
- end
- end
-
- it_should_behave_like "have_class_variable, on all Ruby versions"
-end
diff --git a/spec/mspec/spec/matchers/have_instance_variable_spec.rb b/spec/mspec/spec/matchers/have_instance_variable_spec.rb
index ababb38bc7..4122c6551b 100644
--- a/spec/mspec/spec/matchers/have_instance_variable_spec.rb
+++ b/spec/mspec/spec/matchers/have_instance_variable_spec.rb
@@ -2,9 +2,12 @@ require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'
-shared_examples_for "have_instance_variable, on all Ruby versions" do
- after :all do
- Object.const_set :RUBY_VERSION, @ruby_version
+describe HaveInstanceVariableMatcher do
+ before :each do
+ @object = Object.new
+ def @object.instance_variables
+ [:@foo]
+ end
end
it "matches when object has the instance variable, given as string" do
@@ -45,17 +48,3 @@ shared_examples_for "have_instance_variable, on all Ruby versions" do
]
end
end
-
-describe HaveInstanceVariableMatcher, "on RUBY_VERSION >= 1.9" do
- before :all do
- @ruby_version = Object.const_get :RUBY_VERSION
- Object.const_set :RUBY_VERSION, '1.9.0'
-
- @object = Object.new
- def @object.instance_variables
- [:@foo]
- end
- end
-
- it_should_behave_like "have_instance_variable, on all Ruby versions"
-end
diff --git a/spec/mspec/spec/runner/context_spec.rb b/spec/mspec/spec/runner/context_spec.rb
index f8759b639d..d9c20aa0cf 100644
--- a/spec/mspec/spec/runner/context_spec.rb
+++ b/spec/mspec/spec/runner/context_spec.rb
@@ -9,7 +9,7 @@ require 'mspec/runner/example'
describe ContextState, "#describe" do
before :each do
@state = ContextState.new "C#m"
- @proc = lambda {|*| ScratchPad.record :a }
+ @proc = proc { ScratchPad.record :a }
ScratchPad.clear
end
diff --git a/spec/mspec/spec/runner/mspec_spec.rb b/spec/mspec/spec/runner/mspec_spec.rb
index 9b8142414e..91338c6ddb 100644
--- a/spec/mspec/spec/runner/mspec_spec.rb
+++ b/spec/mspec/spec/runner/mspec_spec.rb
@@ -58,8 +58,8 @@ end
describe MSpec, ".retrieve" do
it "accesses .store'd data" do
- MSpec.register :action, :first
- MSpec.retrieve(:action).should == [:first]
+ MSpec.register :retrieve, :first
+ MSpec.retrieve(:retrieve).should == [:first]
end
end
diff --git a/spec/mspec/spec/spec_helper.rb b/spec/mspec/spec/spec_helper.rb
index 93e383ebb0..0d497f6627 100644
--- a/spec/mspec/spec/spec_helper.rb
+++ b/spec/mspec/spec/spec_helper.rb
@@ -48,7 +48,7 @@ def run_mspec(command, args)
ret = $?
out = out.sub(/\A\$.+\n/, '') # Remove printed command line
out = out.sub(RUBY_DESCRIPTION, "RUBY_DESCRIPTION")
- out = out.gsub(/\d\.\d{6}/, "D.DDDDDD") # Specs total time
+ out = out.gsub(/\d+\.\d{6}/, "D.DDDDDD") # Specs total time
out = out.gsub(/\d{2}:\d{2}:\d{2}/, "00:00:00") # Progress bar time
out = out.gsub(cwd, "CWD")
return out, ret