summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/mspec/lib/mspec/commands/mspec-ci.rb1
-rw-r--r--spec/mspec/lib/mspec/commands/mspec-run.rb1
-rw-r--r--spec/mspec/lib/mspec/commands/mspec-tag.rb1
-rw-r--r--spec/mspec/lib/mspec/guards.rb1
-rw-r--r--spec/mspec/lib/mspec/guards/block_device.rb6
-rw-r--r--spec/mspec/lib/mspec/guards/bug.rb6
-rw-r--r--spec/mspec/lib/mspec/guards/conflict.rb14
-rw-r--r--spec/mspec/lib/mspec/guards/endian.rb12
-rw-r--r--spec/mspec/lib/mspec/guards/feature.rb58
-rw-r--r--spec/mspec/lib/mspec/guards/guard.rb1
-rw-r--r--spec/mspec/lib/mspec/guards/platform.rb16
-rw-r--r--spec/mspec/lib/mspec/guards/quarantine.rb6
-rw-r--r--spec/mspec/lib/mspec/guards/superuser.rb12
-rw-r--r--spec/mspec/lib/mspec/guards/support.rb6
-rw-r--r--spec/mspec/lib/mspec/guards/version.rb6
-rw-r--r--spec/mspec/lib/mspec/helpers/argf.rb66
-rw-r--r--spec/mspec/lib/mspec/helpers/argv.rb82
-rw-r--r--spec/mspec/lib/mspec/helpers/datetime.rb82
-rw-r--r--spec/mspec/lib/mspec/helpers/fixture.rb46
-rw-r--r--spec/mspec/lib/mspec/helpers/flunk.rb6
-rw-r--r--spec/mspec/lib/mspec/helpers/fs.rb104
-rw-r--r--spec/mspec/lib/mspec/helpers/io.rb82
-rw-r--r--spec/mspec/lib/mspec/helpers/mock_to_path.rb12
-rw-r--r--spec/mspec/lib/mspec/helpers/numeric.rb104
-rw-r--r--spec/mspec/lib/mspec/helpers/ruby_exe.rb168
-rw-r--r--spec/mspec/lib/mspec/helpers/tmp.rb18
-rw-r--r--spec/mspec/lib/mspec/helpers/warning.rb14
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/html.rb2
-rw-r--r--spec/mspec/lib/mspec/runner/formatters/junit.rb3
-rw-r--r--spec/mspec/lib/mspec/utils/options.rb8
-rw-r--r--spec/mspec/lib/mspec/utils/ruby_name.rb8
-rw-r--r--spec/mspec/spec/commands/mspec_ci_spec.rb5
-rw-r--r--spec/mspec/spec/commands/mspec_run_spec.rb5
-rw-r--r--spec/mspec/spec/commands/mspec_tag_spec.rb5
-rw-r--r--spec/mspec/spec/guards/bug_spec.rb12
-rw-r--r--spec/mspec/spec/guards/platform_spec.rb38
-rw-r--r--spec/mspec/spec/guards/support_spec.rb16
-rw-r--r--spec/mspec/spec/helpers/ruby_exe_spec.rb32
-rw-r--r--spec/mspec/spec/runner/formatters/html_spec.rb7
-rw-r--r--spec/mspec/spec/utils/options_spec.rb24
-rw-r--r--spec/mspec/tool/sync/sync-rubyspec.rb7
41 files changed, 500 insertions, 603 deletions
diff --git a/spec/mspec/lib/mspec/commands/mspec-ci.rb b/spec/mspec/lib/mspec/commands/mspec-ci.rb
index 225d2bb96d..cb0193f42d 100644
--- a/spec/mspec/lib/mspec/commands/mspec-ci.rb
+++ b/spec/mspec/lib/mspec/commands/mspec-ci.rb
@@ -22,7 +22,6 @@ class MSpecCI < MSpecScript
options.chdir
options.prefix
options.configure { |f| load f }
- options.name
options.pretend
options.interrupt
diff --git a/spec/mspec/lib/mspec/commands/mspec-run.rb b/spec/mspec/lib/mspec/commands/mspec-run.rb
index 45b26e88ad..249f9f5771 100644
--- a/spec/mspec/lib/mspec/commands/mspec-run.rb
+++ b/spec/mspec/lib/mspec/commands/mspec-run.rb
@@ -32,7 +32,6 @@ class MSpecRun < MSpecScript
options.chdir
options.prefix
options.configure { |f| load f }
- options.name
options.randomize
options.repeat
options.pretend
diff --git a/spec/mspec/lib/mspec/commands/mspec-tag.rb b/spec/mspec/lib/mspec/commands/mspec-tag.rb
index 7582015916..8bc3382e91 100644
--- a/spec/mspec/lib/mspec/commands/mspec-tag.rb
+++ b/spec/mspec/lib/mspec/commands/mspec-tag.rb
@@ -30,7 +30,6 @@ class MSpecTag < MSpecScript
options.doc "\n How to modify the execution"
options.configure { |f| load f }
- options.name
options.pretend
options.unguarded
options.interrupt
diff --git a/spec/mspec/lib/mspec/guards.rb b/spec/mspec/lib/mspec/guards.rb
index 0d7d300c64..454ac0c776 100644
--- a/spec/mspec/lib/mspec/guards.rb
+++ b/spec/mspec/lib/mspec/guards.rb
@@ -1,4 +1,3 @@
-require 'mspec/utils/ruby_name'
require 'mspec/guards/block_device'
require 'mspec/guards/bug'
require 'mspec/guards/conflict'
diff --git a/spec/mspec/lib/mspec/guards/block_device.rb b/spec/mspec/lib/mspec/guards/block_device.rb
index 327f6e564e..ae736a2d4e 100644
--- a/spec/mspec/lib/mspec/guards/block_device.rb
+++ b/spec/mspec/lib/mspec/guards/block_device.rb
@@ -11,8 +11,6 @@ class BlockDeviceGuard < SpecGuard
end
end
-class Object
- def with_block_device(&block)
- BlockDeviceGuard.new.run_if(:with_block_device, &block)
- end
+def with_block_device(&block)
+ BlockDeviceGuard.new.run_if(:with_block_device, &block)
end
diff --git a/spec/mspec/lib/mspec/guards/bug.rb b/spec/mspec/lib/mspec/guards/bug.rb
index 31de6e080d..b1bfc6413e 100644
--- a/spec/mspec/lib/mspec/guards/bug.rb
+++ b/spec/mspec/lib/mspec/guards/bug.rb
@@ -23,8 +23,6 @@ class BugGuard < VersionGuard
end
end
-class Object
- def ruby_bug(bug, version, &block)
- BugGuard.new(bug, version).run_unless(:ruby_bug, &block)
- end
+def ruby_bug(bug, version, &block)
+ BugGuard.new(bug, version).run_unless(:ruby_bug, &block)
end
diff --git a/spec/mspec/lib/mspec/guards/conflict.rb b/spec/mspec/lib/mspec/guards/conflict.rb
index c1d33e3512..7a27671c1e 100644
--- a/spec/mspec/lib/mspec/guards/conflict.rb
+++ b/spec/mspec/lib/mspec/guards/conflict.rb
@@ -8,12 +8,10 @@ class ConflictsGuard < SpecGuard
end
end
-class Object
- # In some cases, libraries will modify another Ruby method's
- # behavior. The specs for the method's behavior will then fail
- # if that library is loaded. This guard will not run if any of
- # the specified constants exist in Object.constants.
- def conflicts_with(*modules, &block)
- ConflictsGuard.new(*modules).run_unless(:conflicts_with, &block)
- end
+# In some cases, libraries will modify another Ruby method's
+# behavior. The specs for the method's behavior will then fail
+# if that library is loaded. This guard will not run if any of
+# the specified constants exist in Object.constants.
+def conflicts_with(*modules, &block)
+ ConflictsGuard.new(*modules).run_unless(:conflicts_with, &block)
end
diff --git a/spec/mspec/lib/mspec/guards/endian.rb b/spec/mspec/lib/mspec/guards/endian.rb
index 6bb01263c7..79335a8933 100644
--- a/spec/mspec/lib/mspec/guards/endian.rb
+++ b/spec/mspec/lib/mspec/guards/endian.rb
@@ -16,12 +16,10 @@ class BigEndianGuard < EndianGuard
end
end
-class Object
- def big_endian(&block)
- BigEndianGuard.new.run_if(:big_endian, &block)
- end
+def big_endian(&block)
+ BigEndianGuard.new.run_if(:big_endian, &block)
+end
- def little_endian(&block)
- BigEndianGuard.new.run_unless(:little_endian, &block)
- end
+def little_endian(&block)
+ BigEndianGuard.new.run_unless(:little_endian, &block)
end
diff --git a/spec/mspec/lib/mspec/guards/feature.rb b/spec/mspec/lib/mspec/guards/feature.rb
index 346212bda0..30984e0cc5 100644
--- a/spec/mspec/lib/mspec/guards/feature.rb
+++ b/spec/mspec/lib/mspec/guards/feature.rb
@@ -10,34 +10,32 @@ class FeatureGuard < SpecGuard
end
end
-class Object
- # Provides better documentation in the specs by
- # naming sets of features that work together as
- # a whole. Examples include :encoding, :fiber,
- # :continuation, :fork.
- #
- # Usage example:
- #
- # with_feature :encoding do
- # # specs for a method that provides aspects
- # # of the encoding feature
- # end
- #
- # Multiple features must all be enabled for the
- # guard to run:
- #
- # with_feature :one, :two do
- # # these specs will run if features :one AND
- # # :two are enabled.
- # end
- #
- # The implementation must explicitly enable a feature
- # by adding code like the following to the .mspec
- # configuration file:
- #
- # MSpec.enable_feature :encoding
- #
- def with_feature(*features, &block)
- FeatureGuard.new(*features).run_if(:with_feature, &block)
- end
+# Provides better documentation in the specs by
+# naming sets of features that work together as
+# a whole. Examples include :encoding, :fiber,
+# :continuation, :fork.
+#
+# Usage example:
+#
+# with_feature :encoding do
+# # specs for a method that provides aspects
+# # of the encoding feature
+# end
+#
+# Multiple features must all be enabled for the
+# guard to run:
+#
+# with_feature :one, :two do
+# # these specs will run if features :one AND
+# # :two are enabled.
+# end
+#
+# The implementation must explicitly enable a feature
+# by adding code like the following to the .mspec
+# configuration file:
+#
+# MSpec.enable_feature :encoding
+#
+def with_feature(*features, &block)
+ FeatureGuard.new(*features).run_if(:with_feature, &block)
end
diff --git a/spec/mspec/lib/mspec/guards/guard.rb b/spec/mspec/lib/mspec/guards/guard.rb
index c95d8f7923..88adbba260 100644
--- a/spec/mspec/lib/mspec/guards/guard.rb
+++ b/spec/mspec/lib/mspec/guards/guard.rb
@@ -1,6 +1,5 @@
require 'mspec/runner/mspec'
require 'mspec/runner/actions/tally'
-require 'mspec/utils/ruby_name'
class SpecGuard
def self.report
diff --git a/spec/mspec/lib/mspec/guards/platform.rb b/spec/mspec/lib/mspec/guards/platform.rb
index 875aef6c9c..96176b8753 100644
--- a/spec/mspec/lib/mspec/guards/platform.rb
+++ b/spec/mspec/lib/mspec/guards/platform.rb
@@ -5,9 +5,9 @@ class PlatformGuard < SpecGuard
args.any? do |name|
case name
when :rubinius
- RUBY_NAME.start_with?('rbx')
+ RUBY_ENGINE.start_with?('rbx')
when :ruby, :jruby, :truffleruby, :ironruby, :macruby, :maglev, :topaz, :opal
- RUBY_NAME.start_with?(name.to_s)
+ RUBY_ENGINE.start_with?(name.to_s)
else
raise "unknown implementation #{name}"
end
@@ -67,12 +67,10 @@ class PlatformGuard < SpecGuard
end
end
-class Object
- def platform_is(*args, &block)
- PlatformGuard.new(*args).run_if(:platform_is, &block)
- end
+def platform_is(*args, &block)
+ PlatformGuard.new(*args).run_if(:platform_is, &block)
+end
- def platform_is_not(*args, &block)
- PlatformGuard.new(*args).run_unless(:platform_is_not, &block)
- end
+def platform_is_not(*args, &block)
+ PlatformGuard.new(*args).run_unless(:platform_is_not, &block)
end
diff --git a/spec/mspec/lib/mspec/guards/quarantine.rb b/spec/mspec/lib/mspec/guards/quarantine.rb
index 4724613a0f..ec4d01f9ea 100644
--- a/spec/mspec/lib/mspec/guards/quarantine.rb
+++ b/spec/mspec/lib/mspec/guards/quarantine.rb
@@ -6,8 +6,6 @@ class QuarantineGuard < SpecGuard
end
end
-class Object
- def quarantine!(&block)
- QuarantineGuard.new.run_unless(:quarantine!, &block)
- end
+def quarantine!(&block)
+ QuarantineGuard.new.run_unless(:quarantine!, &block)
end
diff --git a/spec/mspec/lib/mspec/guards/superuser.rb b/spec/mspec/lib/mspec/guards/superuser.rb
index 6e447198a7..e92ea7e862 100644
--- a/spec/mspec/lib/mspec/guards/superuser.rb
+++ b/spec/mspec/lib/mspec/guards/superuser.rb
@@ -6,12 +6,10 @@ class SuperUserGuard < SpecGuard
end
end
-class Object
- def as_superuser(&block)
- SuperUserGuard.new.run_if(:as_superuser, &block)
- end
+def as_superuser(&block)
+ SuperUserGuard.new.run_if(:as_superuser, &block)
+end
- def as_user(&block)
- SuperUserGuard.new.run_unless(:as_user, &block)
- end
+def as_user(&block)
+ SuperUserGuard.new.run_unless(:as_user, &block)
end
diff --git a/spec/mspec/lib/mspec/guards/support.rb b/spec/mspec/lib/mspec/guards/support.rb
index f1760ece2e..790bea1077 100644
--- a/spec/mspec/lib/mspec/guards/support.rb
+++ b/spec/mspec/lib/mspec/guards/support.rb
@@ -9,8 +9,6 @@ class SupportedGuard < SpecGuard
end
end
-class Object
- def not_supported_on(*args, &block)
- SupportedGuard.new(*args).run_unless(:not_supported_on, &block)
- end
+def not_supported_on(*args, &block)
+ SupportedGuard.new(*args).run_unless(:not_supported_on, &block)
end
diff --git a/spec/mspec/lib/mspec/guards/version.rb b/spec/mspec/lib/mspec/guards/version.rb
index 110853e082..cb08fdac73 100644
--- a/spec/mspec/lib/mspec/guards/version.rb
+++ b/spec/mspec/lib/mspec/guards/version.rb
@@ -32,8 +32,6 @@ class VersionGuard < SpecGuard
end
end
-class Object
- def ruby_version_is(*args, &block)
- VersionGuard.new(*args).run_if(:ruby_version_is, &block)
- end
+def ruby_version_is(*args, &block)
+ VersionGuard.new(*args).run_if(:ruby_version_is, &block)
end
diff --git a/spec/mspec/lib/mspec/helpers/argf.rb b/spec/mspec/lib/mspec/helpers/argf.rb
index 1ba48b9378..4d3e0f46b3 100644
--- a/spec/mspec/lib/mspec/helpers/argf.rb
+++ b/spec/mspec/lib/mspec/helpers/argf.rb
@@ -1,37 +1,35 @@
-class Object
- # Convenience helper for specs using ARGF.
- # Set @argf to an instance of ARGF.class with the given +argv+.
- # That instance must be used instead of ARGF as ARGF is global
- # and it is not always possible to reset its state correctly.
- #
- # The helper yields to the block and then close
- # the files open by the instance. Example:
- #
- # describe "That" do
- # it "does something" do
- # argf ['a', 'b'] do
- # # do something
- # end
- # end
- # end
- def argf(argv)
- if argv.empty? or argv.length > 2
- raise "Only 1 or 2 filenames are allowed for the argf helper so files can be properly closed: #{argv.inspect}"
- end
- @argf ||= nil
- raise "Cannot nest calls to the argf helper" if @argf
+# Convenience helper for specs using ARGF.
+# Set @argf to an instance of ARGF.class with the given +argv+.
+# That instance must be used instead of ARGF as ARGF is global
+# and it is not always possible to reset its state correctly.
+#
+# The helper yields to the block and then close
+# the files open by the instance. Example:
+#
+# describe "That" do
+# it "does something" do
+# argf ['a', 'b'] do
+# # do something
+# end
+# end
+# end
+def argf(argv)
+ if argv.empty? or argv.length > 2
+ raise "Only 1 or 2 filenames are allowed for the argf helper so files can be properly closed: #{argv.inspect}"
+ end
+ @argf ||= nil
+ raise "Cannot nest calls to the argf helper" if @argf
- @argf = ARGF.class.new(*argv)
- @__mspec_saved_argf_file__ = @argf.file
- begin
- yield
- ensure
- file1 = @__mspec_saved_argf_file__
- file2 = @argf.file # Either the first file or the second
- file1.close if !file1.closed? and file1 != STDIN
- file2.close if !file2.closed? and file2 != STDIN
- @argf = nil
- @__mspec_saved_argf_file__ = nil
- end
+ @argf = ARGF.class.new(*argv)
+ @__mspec_saved_argf_file__ = @argf.file
+ begin
+ yield
+ ensure
+ file1 = @__mspec_saved_argf_file__
+ file2 = @argf.file # Either the first file or the second
+ file1.close if !file1.closed? and file1 != STDIN
+ file2.close if !file2.closed? and file2 != STDIN
+ @argf = nil
+ @__mspec_saved_argf_file__ = nil
end
end
diff --git a/spec/mspec/lib/mspec/helpers/argv.rb b/spec/mspec/lib/mspec/helpers/argv.rb
index c8cbbf2ac3..9dac384dbd 100644
--- a/spec/mspec/lib/mspec/helpers/argv.rb
+++ b/spec/mspec/lib/mspec/helpers/argv.rb
@@ -1,45 +1,43 @@
-class Object
- # Convenience helper for altering ARGV. Saves the
- # value of ARGV and sets it to +args+. If a block
- # is given, yields to the block and then restores
- # the value of ARGV. The previously saved value of
- # ARGV can be restored by passing +:restore+. The
- # former is useful in a single spec. The latter is
- # useful in before/after actions. For example:
- #
- # describe "This" do
- # before do
- # argv ['a', 'b']
- # end
- #
- # after do
- # argv :restore
- # end
- #
- # it "does something" do
- # # do something
- # end
- # end
- #
- # describe "That" do
- # it "does something" do
- # argv ['a', 'b'] do
- # # do something
- # end
- # end
- # end
- def argv(args)
- if args == :restore
- ARGV.replace(@__mspec_saved_argv__ || [])
- else
- @__mspec_saved_argv__ = ARGV.dup
- ARGV.replace args
- if block_given?
- begin
- yield
- ensure
- argv :restore
- end
+# Convenience helper for altering ARGV. Saves the
+# value of ARGV and sets it to +args+. If a block
+# is given, yields to the block and then restores
+# the value of ARGV. The previously saved value of
+# ARGV can be restored by passing +:restore+. The
+# former is useful in a single spec. The latter is
+# useful in before/after actions. For example:
+#
+# describe "This" do
+# before do
+# argv ['a', 'b']
+# end
+#
+# after do
+# argv :restore
+# end
+#
+# it "does something" do
+# # do something
+# end
+# end
+#
+# describe "That" do
+# it "does something" do
+# argv ['a', 'b'] do
+# # do something
+# end
+# end
+# end
+def argv(args)
+ if args == :restore
+ ARGV.replace(@__mspec_saved_argv__ || [])
+ else
+ @__mspec_saved_argv__ = ARGV.dup
+ ARGV.replace args
+ if block_given?
+ begin
+ yield
+ ensure
+ argv :restore
end
end
end
diff --git a/spec/mspec/lib/mspec/helpers/datetime.rb b/spec/mspec/lib/mspec/helpers/datetime.rb
index 4cb57bdaa1..1520b971ea 100644
--- a/spec/mspec/lib/mspec/helpers/datetime.rb
+++ b/spec/mspec/lib/mspec/helpers/datetime.rb
@@ -1,51 +1,47 @@
-class Object
- # The new_datetime helper makes writing DateTime specs more simple by
- # providing default constructor values and accepting a Hash of only the
- # constructor values needed for the particular spec. For example:
- #
- # new_datetime :hour => 1, :minute => 20
- #
- # Possible keys are:
- # :year, :month, :day, :hour, :minute, :second, :offset and :sg.
+# The new_datetime helper makes writing DateTime specs more simple by
+# providing default constructor values and accepting a Hash of only the
+# constructor values needed for the particular spec. For example:
+#
+# new_datetime :hour => 1, :minute => 20
+#
+# Possible keys are:
+# :year, :month, :day, :hour, :minute, :second, :offset and :sg.
+def new_datetime(opts={})
+ require 'date'
+
+ value = {
+ :year => -4712,
+ :month => 1,
+ :day => 1,
+ :hour => 0,
+ :minute => 0,
+ :second => 0,
+ :offset => 0,
+ :sg => Date::ITALY
+ }.merge opts
+
+ DateTime.new value[:year], value[:month], value[:day], value[:hour],
+ value[:minute], value[:second], value[:offset], value[:sg]
+end
- def new_datetime(opts={})
- require 'date'
+def with_timezone(name, offset = nil, daylight_saving_zone = "")
+ zone = name.dup
- value = {
- :year => -4712,
- :month => 1,
- :day => 1,
- :hour => 0,
- :minute => 0,
- :second => 0,
- :offset => 0,
- :sg => Date::ITALY
- }.merge opts
+ if offset
+ # TZ convention is backwards
+ offset = -offset
- DateTime.new value[:year], value[:month], value[:day], value[:hour],
- value[:minute], value[:second], value[:offset], value[:sg]
+ zone += offset.to_s
+ zone += ":00:00"
end
+ zone += daylight_saving_zone
- def with_timezone(name, offset = nil, daylight_saving_zone = "")
- zone = name.dup
-
- if offset
- # TZ convention is backwards
- offset = -offset
-
- zone += offset.to_s
- zone += ":00:00"
- end
- zone += daylight_saving_zone
+ old = ENV["TZ"]
+ ENV["TZ"] = zone
- old = ENV["TZ"]
- ENV["TZ"] = zone
-
- begin
- yield
- ensure
- ENV["TZ"] = old
- end
+ begin
+ yield
+ ensure
+ ENV["TZ"] = old
end
-
end
diff --git a/spec/mspec/lib/mspec/helpers/fixture.rb b/spec/mspec/lib/mspec/helpers/fixture.rb
index 718c1b7a94..f3bbe423bd 100644
--- a/spec/mspec/lib/mspec/helpers/fixture.rb
+++ b/spec/mspec/lib/mspec/helpers/fixture.rb
@@ -1,26 +1,24 @@
-class Object
- # Returns the name of a fixture file by adjoining the directory
- # of the +file+ argument with "fixtures" and the contents of the
- # +args+ array. For example,
- #
- # +file+ == "some/example_spec.rb"
- #
- # and
- #
- # +args+ == ["subdir", "file.txt"]
- #
- # then the result is the expanded path of
- #
- # "some/fixtures/subdir/file.txt".
- def fixture(file, *args)
- path = File.dirname(file)
- path = path[0..-7] if path[-7..-1] == "/shared"
- fixtures = path[-9..-1] == "/fixtures" ? "" : "fixtures"
- if File.respond_to?(:realpath)
- path = File.realpath(path)
- else
- path = File.expand_path(path)
- end
- File.join(path, fixtures, args)
+# Returns the name of a fixture file by adjoining the directory
+# of the +file+ argument with "fixtures" and the contents of the
+# +args+ array. For example,
+#
+# +file+ == "some/example_spec.rb"
+#
+# and
+#
+# +args+ == ["subdir", "file.txt"]
+#
+# then the result is the expanded path of
+#
+# "some/fixtures/subdir/file.txt".
+def fixture(file, *args)
+ path = File.dirname(file)
+ path = path[0..-7] if path[-7..-1] == "/shared"
+ fixtures = path[-9..-1] == "/fixtures" ? "" : "fixtures"
+ if File.respond_to?(:realpath)
+ path = File.realpath(path)
+ else
+ path = File.expand_path(path)
end
+ File.join(path, fixtures, args)
end
diff --git a/spec/mspec/lib/mspec/helpers/flunk.rb b/spec/mspec/lib/mspec/helpers/flunk.rb
index 35bd939b85..68fb3cadac 100644
--- a/spec/mspec/lib/mspec/helpers/flunk.rb
+++ b/spec/mspec/lib/mspec/helpers/flunk.rb
@@ -1,5 +1,3 @@
-class Object
- def flunk(msg="This example is a failure")
- SpecExpectation.fail_with "Failed:", msg
- end
+def flunk(msg="This example is a failure")
+ SpecExpectation.fail_with "Failed:", msg
end
diff --git a/spec/mspec/lib/mspec/helpers/fs.rb b/spec/mspec/lib/mspec/helpers/fs.rb
index c41389e755..fb2c0f702c 100644
--- a/spec/mspec/lib/mspec/helpers/fs.rb
+++ b/spec/mspec/lib/mspec/helpers/fs.rb
@@ -1,72 +1,70 @@
-class Object
- # Copies a file
- def cp(source, dest)
- File.open(dest, "wb") do |d|
- File.open(source, "rb") do |s|
- while data = s.read(1024)
- d.write data
- end
+# Copies a file
+def cp(source, dest)
+ File.open(dest, "wb") do |d|
+ File.open(source, "rb") do |s|
+ while data = s.read(1024)
+ d.write data
end
end
end
+end
- # Creates each directory in path that does not exist.
- def mkdir_p(path)
- parts = File.expand_path(path).split %r[/|\\]
- name = parts.shift
- parts.each do |part|
- name = File.join name, part
+# Creates each directory in path that does not exist.
+def mkdir_p(path)
+ parts = File.expand_path(path).split %r[/|\\]
+ name = parts.shift
+ parts.each do |part|
+ name = File.join name, part
- if File.file? name
- raise ArgumentError, "path component of #{path} is a file"
- end
+ if File.file? name
+ raise ArgumentError, "path component of #{path} is a file"
+ end
- unless File.directory? name
- begin
- Dir.mkdir name
- rescue Errno::EEXIST => e
- if File.directory? name
- # OK, another process/thread created the same directory
- else
- raise e
- end
+ unless File.directory? name
+ begin
+ Dir.mkdir name
+ rescue Errno::EEXIST => e
+ if File.directory? name
+ # OK, another process/thread created the same directory
+ else
+ raise e
end
end
end
end
+end
- # Recursively removes all files and directories in +path+
- # if +path+ is a directory. Removes the file if +path+ is
- # a file.
- def rm_r(*paths)
- paths.each do |path|
- path = File.expand_path path
+# Recursively removes all files and directories in +path+
+# if +path+ is a directory. Removes the file if +path+ is
+# a file.
+def rm_r(*paths)
+ paths.each do |path|
+ path = File.expand_path path
- prefix = SPEC_TEMP_DIR
- unless path[0, prefix.size] == prefix
- raise ArgumentError, "#{path} is not prefixed by #{prefix}"
- end
+ prefix = SPEC_TEMP_DIR
+ unless path[0, prefix.size] == prefix
+ raise ArgumentError, "#{path} is not prefixed by #{prefix}"
+ end
- # File.symlink? needs to be checked first as
- # File.exist? returns false for dangling symlinks
- if File.symlink? path
- File.unlink path
- elsif File.directory? path
- Dir.entries(path).each { |x| rm_r "#{path}/#{x}" unless x =~ /^\.\.?$/ }
- Dir.rmdir path
- elsif File.exist? path
- File.delete path
- end
+ # File.symlink? needs to be checked first as
+ # File.exist? returns false for dangling symlinks
+ if File.symlink? path
+ File.unlink path
+ elsif File.directory? path
+ Dir.entries(path).each { |x| rm_r "#{path}/#{x}" unless x =~ /^\.\.?$/ }
+ Dir.rmdir path
+ elsif File.exist? path
+ File.delete path
end
end
+end
- # Creates a file +name+. Creates the directory for +name+
- # if it does not exist.
- def touch(name, mode="w")
- mkdir_p File.dirname(name)
+# Creates a file +name+. Creates the directory for +name+
+# if it does not exist.
+def touch(name, mode="w")
+ mkdir_p File.dirname(name)
- File.open(name, mode) do |f|
- yield f if block_given?
- end
+ File.open(name, mode) do |f|
+ yield f if block_given?
end
end
diff --git a/spec/mspec/lib/mspec/helpers/io.rb b/spec/mspec/lib/mspec/helpers/io.rb
index 83d14441a7..57dc0d53a4 100644
--- a/spec/mspec/lib/mspec/helpers/io.rb
+++ b/spec/mspec/lib/mspec/helpers/io.rb
@@ -61,53 +61,51 @@ class IOStub
end
end
-class Object
- # Creates a "bare" file descriptor (i.e. one that is not associated
- # with any Ruby object). The file descriptor can safely be passed
- # to IO.new without creating a Ruby object alias to the fd.
- def new_fd(name, mode="w:utf-8")
- mode = options_or_mode(mode)
-
- if mode.kind_of? Hash
- if mode.key? :mode
- mode = mode[:mode]
- else
- raise ArgumentError, "new_fd options Hash must include :mode"
- end
+# Creates a "bare" file descriptor (i.e. one that is not associated
+# with any Ruby object). The file descriptor can safely be passed
+# to IO.new without creating a Ruby object alias to the fd.
+def new_fd(name, mode="w:utf-8")
+ mode = options_or_mode(mode)
+
+ if mode.kind_of? Hash
+ if mode.key? :mode
+ mode = mode[:mode]
+ else
+ raise ArgumentError, "new_fd options Hash must include :mode"
end
-
- IO.sysopen name, fmode(mode)
end
- # Creates an IO instance for a temporary file name. The file
- # must be deleted.
- def new_io(name, mode="w:utf-8")
- IO.new new_fd(name, options_or_mode(mode)), options_or_mode(mode)
- end
+ IO.sysopen name, fmode(mode)
+end
- # This helper simplifies passing file access modes regardless of
- # whether the :encoding feature is enabled. Only the access specifier
- # itself will be returned if :encoding is not enabled. Otherwise,
- # the full mode string will be returned (i.e. the helper is a no-op).
- def fmode(mode)
- if FeatureGuard.enabled? :encoding
- mode
- else
- mode.split(':').first
- end
- end
+# Creates an IO instance for a temporary file name. The file
+# must be deleted.
+def new_io(name, mode="w:utf-8")
+ IO.new new_fd(name, options_or_mode(mode)), options_or_mode(mode)
+end
- # This helper simplifies passing file access modes or options regardless of
- # whether the :encoding feature is enabled. Only the access specifier itself
- # will be returned if :encoding is not enabled. Otherwise, the full mode
- # string or option will be returned (i.e. the helper is a no-op).
- def options_or_mode(oom)
- return fmode(oom) if oom.kind_of? String
+# This helper simplifies passing file access modes regardless of
+# whether the :encoding feature is enabled. Only the access specifier
+# itself will be returned if :encoding is not enabled. Otherwise,
+# the full mode string will be returned (i.e. the helper is a no-op).
+def fmode(mode)
+ if FeatureGuard.enabled? :encoding
+ mode
+ else
+ mode.split(':').first
+ end
+end
- if FeatureGuard.enabled? :encoding
- oom
- else
- fmode(oom[:mode] || "r:utf-8")
- end
+# This helper simplifies passing file access modes or options regardless of
+# whether the :encoding feature is enabled. Only the access specifier itself
+# will be returned if :encoding is not enabled. Otherwise, the full mode
+# string or option will be returned (i.e. the helper is a no-op).
+def options_or_mode(oom)
+ return fmode(oom) if oom.kind_of? String
+
+ if FeatureGuard.enabled? :encoding
+ oom
+ else
+ fmode(oom[:mode] || "r:utf-8")
end
end
diff --git a/spec/mspec/lib/mspec/helpers/mock_to_path.rb b/spec/mspec/lib/mspec/helpers/mock_to_path.rb
index 683bb1d9d6..2780afc54a 100644
--- a/spec/mspec/lib/mspec/helpers/mock_to_path.rb
+++ b/spec/mspec/lib/mspec/helpers/mock_to_path.rb
@@ -1,8 +1,6 @@
-class Object
- def mock_to_path(path)
- # Cannot use our Object#mock here since it conflicts with RSpec
- obj = MockObject.new('path')
- obj.should_receive(:to_path).and_return(path)
- obj
- end
+def mock_to_path(path)
+ # Cannot use our Object#mock here since it conflicts with RSpec
+ obj = MockObject.new('path')
+ obj.should_receive(:to_path).and_return(path)
+ obj
end
diff --git a/spec/mspec/lib/mspec/helpers/numeric.rb b/spec/mspec/lib/mspec/helpers/numeric.rb
index ff30cf2b83..312aafae35 100644
--- a/spec/mspec/lib/mspec/helpers/numeric.rb
+++ b/spec/mspec/lib/mspec/helpers/numeric.rb
@@ -1,72 +1,70 @@
require 'mspec/guards/platform'
-class Object
- def nan_value
- 0/0.0
- end
-
- def infinity_value
- 1/0.0
- end
-
- def bignum_value(plus=0)
- 0x8000_0000_0000_0000 + plus
- end
+def nan_value
+ 0/0.0
+end
- # This is a bit hairy, but we need to be able to write specs that cover the
- # boundary between Fixnum and Bignum for operations like Fixnum#<<. Since
- # this boundary is implementation-dependent, we use these helpers to write
- # specs based on the relationship between values rather than specific
- # values.
- if PlatformGuard.standard? or PlatformGuard.implementation? :topaz
- if PlatformGuard.wordsize? 32
- def fixnum_max
- (2**30) - 1
- end
+def infinity_value
+ 1/0.0
+end
- def fixnum_min
- -(2**30)
- end
- elsif PlatformGuard.wordsize? 64
- def fixnum_max
- (2**62) - 1
- end
+def bignum_value(plus=0)
+ 0x8000_0000_0000_0000 + plus
+end
- def fixnum_min
- -(2**62)
- end
- end
- elsif PlatformGuard.implementation? :opal
+# This is a bit hairy, but we need to be able to write specs that cover the
+# boundary between Fixnum and Bignum for operations like Fixnum#<<. Since
+# this boundary is implementation-dependent, we use these helpers to write
+# specs based on the relationship between values rather than specific
+# values.
+if PlatformGuard.standard? or PlatformGuard.implementation? :topaz
+ if PlatformGuard.wordsize? 32
def fixnum_max
- Integer::MAX
+ (2**30) - 1
end
def fixnum_min
- Integer::MIN
+ -(2**30)
end
- elsif PlatformGuard.implementation? :rubinius
+ elsif PlatformGuard.wordsize? 64
def fixnum_max
- Fixnum::MAX
+ (2**62) - 1
end
def fixnum_min
- Fixnum::MIN
- end
- elsif PlatformGuard.implementation?(:jruby) || PlatformGuard.implementation?(:truffleruby)
- def fixnum_max
- 9223372036854775807
+ -(2**62)
end
+ end
+elsif PlatformGuard.implementation? :opal
+ def fixnum_max
+ Integer::MAX
+ end
- def fixnum_min
- -9223372036854775808
- end
- else
- def fixnum_max
- raise "unknown implementation for fixnum_max() helper"
- end
+ def fixnum_min
+ Integer::MIN
+ end
+elsif PlatformGuard.implementation? :rubinius
+ def fixnum_max
+ Fixnum::MAX
+ end
- def fixnum_min
- raise "unknown implementation for fixnum_min() helper"
- end
+ def fixnum_min
+ Fixnum::MIN
+ end
+elsif PlatformGuard.implementation?(:jruby) || PlatformGuard.implementation?(:truffleruby)
+ def fixnum_max
+ 9223372036854775807
+ end
+
+ def fixnum_min
+ -9223372036854775808
+ end
+else
+ def fixnum_max
+ raise "unknown implementation for fixnum_max() helper"
+ end
+
+ def fixnum_min
+ raise "unknown implementation for fixnum_min() helper"
end
end
diff --git a/spec/mspec/lib/mspec/helpers/ruby_exe.rb b/spec/mspec/lib/mspec/helpers/ruby_exe.rb
index a025be6c81..7c3d6a36cf 100644
--- a/spec/mspec/lib/mspec/helpers/ruby_exe.rb
+++ b/spec/mspec/lib/mspec/helpers/ruby_exe.rb
@@ -1,4 +1,3 @@
-require 'mspec/utils/ruby_name'
require 'mspec/guards/platform'
require 'mspec/helpers/tmp'
@@ -46,8 +45,8 @@ require 'mspec/helpers/tmp'
# constructed as follows:
#
# 1. the value of ENV['RUBY_EXE']
-# 2. an explicit value based on RUBY_NAME
-# 3. cwd/(RUBY_NAME + $(EXEEXT) || $(exeext) || '')
+# 2. an explicit value based on RUBY_ENGINE
+# 3. cwd/(RUBY_ENGINE + $(EXEEXT) || $(exeext) || '')
# 4. $(bindir)/$(RUBY_INSTALL_NAME)
#
# The value will only be used if the file exists and is executable.
@@ -64,8 +63,7 @@ require 'mspec/helpers/tmp'
# 2. Running the specs while developing an alternative
# Ruby implementation. This explicitly names the
# executable in the development directory based on
-# the value of RUBY_NAME, which is probably initialized
-# from the value of RUBY_ENGINE.
+# the value of RUBY_ENGINE.
# 3. Running the specs within the source directory for
# some implementation. (E.g. a local build directory.)
# 4. Running the specs against some installed Ruby
@@ -76,103 +74,101 @@ require 'mspec/helpers/tmp'
# will be appended to RUBY_EXE so that the interpreter
# is always called with those flags.
-class Object
- def ruby_exe_options(option)
- case option
- when :env
- ENV['RUBY_EXE']
- when :engine
- case RUBY_NAME
- when 'rbx'
- "bin/rbx"
- when 'jruby'
- "bin/jruby"
- when 'maglev'
- "maglev-ruby"
- when 'topaz'
- "topaz"
- when 'ironruby'
- "ir"
- end
- when :name
- require 'rbconfig'
- bin = RUBY_NAME + (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
- File.join(".", bin)
- when :install_name
- require 'rbconfig'
- bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"] || RbConfig::CONFIG["ruby_install_name"]
- bin << (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
- File.join(RbConfig::CONFIG['bindir'], bin)
+def ruby_exe_options(option)
+ case option
+ when :env
+ ENV['RUBY_EXE']
+ when :engine
+ case RUBY_ENGINE
+ when 'rbx'
+ "bin/rbx"
+ when 'jruby'
+ "bin/jruby"
+ when 'maglev'
+ "maglev-ruby"
+ when 'topaz'
+ "topaz"
+ when 'ironruby'
+ "ir"
end
+ when :name
+ require 'rbconfig'
+ bin = RUBY_ENGINE + (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
+ File.join(".", bin)
+ when :install_name
+ require 'rbconfig'
+ bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"] || RbConfig::CONFIG["ruby_install_name"]
+ bin << (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
+ File.join(RbConfig::CONFIG['bindir'], bin)
end
+end
- def resolve_ruby_exe
- [:env, :engine, :name, :install_name].each do |option|
- next unless exe = ruby_exe_options(option)
+def resolve_ruby_exe
+ [:env, :engine, :name, :install_name].each do |option|
+ next unless exe = ruby_exe_options(option)
- if File.file?(exe) and File.executable?(exe)
- exe = File.expand_path(exe)
- exe = exe.tr('/', '\\') if PlatformGuard.windows?
- flags = ENV['RUBY_FLAGS']
- if flags and !flags.empty?
- return exe + ' ' + flags
- else
- return exe
- end
+ if File.file?(exe) and File.executable?(exe)
+ exe = File.expand_path(exe)
+ exe = exe.tr('/', '\\') if PlatformGuard.windows?
+ flags = ENV['RUBY_FLAGS']
+ if flags and !flags.empty?
+ return exe + ' ' + flags
+ else
+ return exe
end
end
- raise Exception, "Unable to find a suitable ruby executable."
end
+ raise Exception, "Unable to find a suitable ruby executable."
+end
- def ruby_exe(code, opts = {})
- if opts[:dir]
- raise "ruby_exe(..., dir: dir) is no longer supported, use Dir.chdir"
- end
-
- env = opts[:env] || {}
- saved_env = {}
- env.each do |key, value|
- key = key.to_s
- saved_env[key] = ENV[key] if ENV.key? key
- ENV[key] = value
- end
-
- escape = opts.delete(:escape)
- if code and !File.exist?(code) and escape != false
- tmpfile = tmp("rubyexe.rb")
- File.open(tmpfile, "w") { |f| f.write(code) }
- code = tmpfile
- end
+def ruby_exe(code, opts = {})
+ if opts[:dir]
+ raise "ruby_exe(..., dir: dir) is no longer supported, use Dir.chdir"
+ end
- begin
- platform_is_not :opal do
- `#{ruby_cmd(code, opts)}`
- end
- ensure
- saved_env.each { |key, value| ENV[key] = value }
- env.keys.each do |key|
- key = key.to_s
- ENV.delete key unless saved_env.key? key
- end
- File.delete tmpfile if tmpfile
- end
+ env = opts[:env] || {}
+ saved_env = {}
+ env.each do |key, value|
+ key = key.to_s
+ saved_env[key] = ENV[key] if ENV.key? key
+ ENV[key] = value
end
- def ruby_cmd(code, opts = {})
- body = code
+ escape = opts.delete(:escape)
+ if code and !File.exist?(code) and escape != false
+ tmpfile = tmp("rubyexe.rb")
+ File.open(tmpfile, "w") { |f| f.write(code) }
+ code = tmpfile
+ end
- if opts[:escape]
- raise "escape: true is no longer supported in ruby_cmd, use ruby_exe or a fixture"
+ begin
+ platform_is_not :opal do
+ `#{ruby_cmd(code, opts)}`
end
-
- if code and !File.exist?(code)
- body = "-e #{code.inspect}"
+ ensure
+ saved_env.each { |key, value| ENV[key] = value }
+ env.keys.each do |key|
+ key = key.to_s
+ ENV.delete key unless saved_env.key? key
end
+ File.delete tmpfile if tmpfile
+ end
+end
+
+def ruby_cmd(code, opts = {})
+ body = code
- [RUBY_EXE, opts[:options], body, opts[:args]].compact.join(' ')
+ if opts[:escape]
+ raise "escape: true is no longer supported in ruby_cmd, use ruby_exe or a fixture"
end
- unless Object.const_defined?(:RUBY_EXE) and RUBY_EXE
- RUBY_EXE = resolve_ruby_exe
+ if code and !File.exist?(code)
+ body = "-e #{code.inspect}"
end
+
+ [RUBY_EXE, opts[:options], body, opts[:args]].compact.join(' ')
+end
+
+unless Object.const_defined?(:RUBY_EXE) and RUBY_EXE
+ RUBY_EXE = resolve_ruby_exe
end
diff --git a/spec/mspec/lib/mspec/helpers/tmp.rb b/spec/mspec/lib/mspec/helpers/tmp.rb
index 742eb57fdc..4e1273dcfe 100644
--- a/spec/mspec/lib/mspec/helpers/tmp.rb
+++ b/spec/mspec/lib/mspec/helpers/tmp.rb
@@ -30,16 +30,14 @@ all specs are cleaning up temporary files:
end
end
-class Object
- def tmp(name, uniquify=true)
- Dir.mkdir SPEC_TEMP_DIR unless Dir.exist? SPEC_TEMP_DIR
-
- if uniquify and !name.empty?
- slash = name.rindex "/"
- index = slash ? slash + 1 : 0
- name.insert index, "#{SPEC_TEMP_UNIQUIFIER.succ!}-"
- end
+def tmp(name, uniquify=true)
+ Dir.mkdir SPEC_TEMP_DIR unless Dir.exist? SPEC_TEMP_DIR
- File.join SPEC_TEMP_DIR, name
+ if uniquify and !name.empty?
+ slash = name.rindex "/"
+ index = slash ? slash + 1 : 0
+ name.insert index, "#{SPEC_TEMP_UNIQUIFIER.succ!}-"
end
+
+ File.join SPEC_TEMP_DIR, name
end
diff --git a/spec/mspec/lib/mspec/helpers/warning.rb b/spec/mspec/lib/mspec/helpers/warning.rb
index 44d0e35dc5..9e093074e5 100644
--- a/spec/mspec/lib/mspec/helpers/warning.rb
+++ b/spec/mspec/lib/mspec/helpers/warning.rb
@@ -1,9 +1,7 @@
-class Object
- def suppress_warning
- verbose = $VERBOSE
- $VERBOSE = nil
- yield
- ensure
- $VERBOSE = verbose
- end
+def suppress_warning
+ verbose = $VERBOSE
+ $VERBOSE = nil
+ yield
+ensure
+ $VERBOSE = verbose
end
diff --git a/spec/mspec/lib/mspec/runner/formatters/html.rb b/spec/mspec/lib/mspec/runner/formatters/html.rb
index 060d2732f0..fd64cd0d20 100644
--- a/spec/mspec/lib/mspec/runner/formatters/html.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/html.rb
@@ -15,7 +15,7 @@ class HtmlFormatter < DottedFormatter
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
-<title>Spec Output For #{RUBY_NAME} (#{RUBY_VERSION})</title>
+<title>Spec Output For #{RUBY_ENGINE} (#{RUBY_VERSION})</title>
<style type="text/css">
ul {
list-style: none;
diff --git a/spec/mspec/lib/mspec/runner/formatters/junit.rb b/spec/mspec/lib/mspec/runner/formatters/junit.rb
index 647deee7e1..76d46c2414 100644
--- a/spec/mspec/lib/mspec/runner/formatters/junit.rb
+++ b/spec/mspec/lib/mspec/runner/formatters/junit.rb
@@ -1,5 +1,4 @@
require 'mspec/expectations/expectations'
-require 'mspec/utils/ruby_name'
require 'mspec/runner/formatters/yaml'
class JUnitFormatter < YamlFormatter
@@ -39,7 +38,7 @@ class JUnitFormatter < YamlFormatter
errors="#{errors}"
failures="#{failures}"
time="#{time}"
- name="Spec Output For #{::RUBY_NAME} (#{::RUBY_VERSION})">
+ name="Spec Output For #{::RUBY_ENGINE} (#{::RUBY_VERSION})">
XML
@tests.each do |h|
description = encode_for_xml h[:test].description
diff --git a/spec/mspec/lib/mspec/utils/options.rb b/spec/mspec/lib/mspec/utils/options.rb
index 122ef6e135..f6e5304062 100644
--- a/spec/mspec/lib/mspec/utils/options.rb
+++ b/spec/mspec/lib/mspec/utils/options.rb
@@ -200,13 +200,6 @@ class MSpecOptions
"Load FILE containing configuration options", &block)
end
- def name
- on("-n", "--name", "RUBY_NAME",
- "Set the value of RUBY_NAME (used to determine the implementation)") do |n|
- Object.const_set :RUBY_NAME, n
- end
- end
-
def targets
on("-t", "--target", "TARGET",
"Implementation to run the specs, where TARGET is:") do |t|
@@ -469,7 +462,6 @@ class MSpecOptions
# Generated with:
# puts File.read(__FILE__).scan(/def (\w+).*\n\s*on\(/)
configure {}
- name
targets
formatters
filters
diff --git a/spec/mspec/lib/mspec/utils/ruby_name.rb b/spec/mspec/lib/mspec/utils/ruby_name.rb
deleted file mode 100644
index e381e387f6..0000000000
--- a/spec/mspec/lib/mspec/utils/ruby_name.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-unless Object.const_defined?(:RUBY_NAME) and RUBY_NAME
- if Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE
- RUBY_NAME = RUBY_ENGINE
- else
- require 'rbconfig'
- RUBY_NAME = RbConfig::CONFIG["RUBY_INSTALL_NAME"] || RbConfig::CONFIG["ruby_install_name"]
- end
-end
diff --git a/spec/mspec/spec/commands/mspec_ci_spec.rb b/spec/mspec/spec/commands/mspec_ci_spec.rb
index 1e8949b0d3..5221363953 100644
--- a/spec/mspec/spec/commands/mspec_ci_spec.rb
+++ b/spec/mspec/spec/commands/mspec_ci_spec.rb
@@ -33,11 +33,6 @@ describe MSpecCI, "#options" do
@script.options ["-B", "cfg.mspec"]
end
- it "enables the name option" do
- @options.should_receive(:name)
- @script.options
- end
-
it "enables the dry run option" do
@options.should_receive(:pretend)
@script.options
diff --git a/spec/mspec/spec/commands/mspec_run_spec.rb b/spec/mspec/spec/commands/mspec_run_spec.rb
index 4d350cdc02..90a42bd62b 100644
--- a/spec/mspec/spec/commands/mspec_run_spec.rb
+++ b/spec/mspec/spec/commands/mspec_run_spec.rb
@@ -56,11 +56,6 @@ describe MSpecRun, "#options" do
@script.options ["-B", "cfg.mspec", one_spec]
end
- it "enables the name option" do
- @options.should_receive(:name)
- @script.options @argv
- end
-
it "enables the randomize option to runs specs in random order" do
@options.should_receive(:randomize)
@script.options @argv
diff --git a/spec/mspec/spec/commands/mspec_tag_spec.rb b/spec/mspec/spec/commands/mspec_tag_spec.rb
index 3c2e94db52..cdb3ac1a60 100644
--- a/spec/mspec/spec/commands/mspec_tag_spec.rb
+++ b/spec/mspec/spec/commands/mspec_tag_spec.rb
@@ -61,11 +61,6 @@ describe MSpecTag, "#options" do
@script.options ["-B", "cfg.mspec", one_spec]
end
- it "enables the name option" do
- @options.should_receive(:name)
- @script.options @argv
- end
-
it "enables the dry run option" do
@options.should_receive(:pretend)
@script.options @argv
diff --git a/spec/mspec/spec/guards/bug_spec.rb b/spec/mspec/spec/guards/bug_spec.rb
index 93c549041a..c8529a49f7 100644
--- a/spec/mspec/spec/guards/bug_spec.rb
+++ b/spec/mspec/spec/guards/bug_spec.rb
@@ -14,12 +14,12 @@ describe BugGuard, "#match? when #implementation? is 'ruby'" do
before :each do
hide_deprecation_warnings
stub_const "VersionGuard::FULL_RUBY_VERSION", SpecVersion.new('1.8.6')
- @ruby_name = Object.const_get :RUBY_NAME
- Object.const_set :RUBY_NAME, 'ruby'
+ @ruby_engine = Object.const_get :RUBY_ENGINE
+ Object.const_set :RUBY_ENGINE, 'ruby'
end
after :each do
- Object.const_set :RUBY_NAME, @ruby_name
+ Object.const_set :RUBY_ENGINE, @ruby_engine
end
it "returns false when version argument is less than RUBY_VERSION" do
@@ -76,15 +76,15 @@ describe BugGuard, "#match? when #implementation? is not 'ruby'" do
before :each do
hide_deprecation_warnings
@ruby_version = Object.const_get :RUBY_VERSION
- @ruby_name = Object.const_get :RUBY_NAME
+ @ruby_engine = Object.const_get :RUBY_ENGINE
Object.const_set :RUBY_VERSION, '1.8.6'
- Object.const_set :RUBY_NAME, 'jruby'
+ Object.const_set :RUBY_ENGINE, 'jruby'
end
after :each do
Object.const_set :RUBY_VERSION, @ruby_version
- Object.const_set :RUBY_NAME, @ruby_name
+ Object.const_set :RUBY_ENGINE, @ruby_engine
end
it "returns false when version argument is less than RUBY_VERSION" do
diff --git a/spec/mspec/spec/guards/platform_spec.rb b/spec/mspec/spec/guards/platform_spec.rb
index 578773e476..f0af12c1f8 100644
--- a/spec/mspec/spec/guards/platform_spec.rb
+++ b/spec/mspec/spec/guards/platform_spec.rb
@@ -120,56 +120,56 @@ describe PlatformGuard, ".implementation?" do
end
before :each do
- @ruby_name = Object.const_get :RUBY_NAME
+ @ruby_engine = Object.const_get :RUBY_ENGINE
end
after :each do
- Object.const_set :RUBY_NAME, @ruby_name
+ Object.const_set :RUBY_ENGINE, @ruby_engine
end
- it "returns true if passed :ruby and RUBY_NAME == 'ruby'" do
- Object.const_set :RUBY_NAME, 'ruby'
+ it "returns true if passed :ruby and RUBY_ENGINE == 'ruby'" do
+ Object.const_set :RUBY_ENGINE, 'ruby'
PlatformGuard.implementation?(:ruby).should == true
end
- it "returns true if passed :rubinius and RUBY_NAME == 'rbx'" do
- Object.const_set :RUBY_NAME, 'rbx'
+ it "returns true if passed :rubinius and RUBY_ENGINE == 'rbx'" do
+ Object.const_set :RUBY_ENGINE, 'rbx'
PlatformGuard.implementation?(:rubinius).should == true
end
- it "returns true if passed :jruby and RUBY_NAME == 'jruby'" do
- Object.const_set :RUBY_NAME, 'jruby'
+ it "returns true if passed :jruby and RUBY_ENGINE == 'jruby'" do
+ Object.const_set :RUBY_ENGINE, 'jruby'
PlatformGuard.implementation?(:jruby).should == true
end
- it "returns true if passed :ironruby and RUBY_NAME == 'ironruby'" do
- Object.const_set :RUBY_NAME, 'ironruby'
+ it "returns true if passed :ironruby and RUBY_ENGINE == 'ironruby'" do
+ Object.const_set :RUBY_ENGINE, 'ironruby'
PlatformGuard.implementation?(:ironruby).should == true
end
- it "returns true if passed :maglev and RUBY_NAME == 'maglev'" do
- Object.const_set :RUBY_NAME, 'maglev'
+ it "returns true if passed :maglev and RUBY_ENGINE == 'maglev'" do
+ Object.const_set :RUBY_ENGINE, 'maglev'
PlatformGuard.implementation?(:maglev).should == true
end
- it "returns true if passed :topaz and RUBY_NAME == 'topaz'" do
- Object.const_set :RUBY_NAME, 'topaz'
+ it "returns true if passed :topaz and RUBY_ENGINE == 'topaz'" do
+ Object.const_set :RUBY_ENGINE, 'topaz'
PlatformGuard.implementation?(:topaz).should == true
end
- it "returns true if passed :ruby and RUBY_NAME matches /^ruby/" do
- Object.const_set :RUBY_NAME, 'ruby'
+ it "returns true if passed :ruby and RUBY_ENGINE matches /^ruby/" do
+ Object.const_set :RUBY_ENGINE, 'ruby'
PlatformGuard.implementation?(:ruby).should == true
- Object.const_set :RUBY_NAME, 'ruby1.8'
+ Object.const_set :RUBY_ENGINE, 'ruby1.8'
PlatformGuard.implementation?(:ruby).should == true
- Object.const_set :RUBY_NAME, 'ruby1.9'
+ Object.const_set :RUBY_ENGINE, 'ruby1.9'
PlatformGuard.implementation?(:ruby).should == true
end
it "raises an error when passed an unrecognized name" do
- Object.const_set :RUBY_NAME, 'ruby'
+ Object.const_set :RUBY_ENGINE, 'ruby'
lambda {
PlatformGuard.implementation?(:python)
}.should raise_error(/unknown implementation/)
diff --git a/spec/mspec/spec/guards/support_spec.rb b/spec/mspec/spec/guards/support_spec.rb
index 43a7e76f06..f899ad02f6 100644
--- a/spec/mspec/spec/guards/support_spec.rb
+++ b/spec/mspec/spec/guards/support_spec.rb
@@ -5,15 +5,15 @@ describe Object, "#not_supported_on" do
before :all do
@verbose = $VERBOSE
$VERBOSE = nil
- @ruby_name = Object.const_get :RUBY_NAME if Object.const_defined? :RUBY_NAME
+ @ruby_engine = Object.const_get :RUBY_ENGINE if Object.const_defined? :RUBY_ENGINE
end
after :all do
$VERBOSE = @verbose
- if @ruby_name
- Object.const_set :RUBY_NAME, @ruby_name
+ if @ruby_engine
+ Object.const_set :RUBY_ENGINE, @ruby_engine
else
- Object.send :remove_const, :RUBY_NAME
+ Object.send :remove_const, :RUBY_ENGINE
end
end
@@ -22,7 +22,7 @@ describe Object, "#not_supported_on" do
end
it "raises an Exception when passed :ruby" do
- Object.const_set :RUBY_NAME, "jruby"
+ Object.const_set :RUBY_ENGINE, "jruby"
lambda {
not_supported_on(:ruby) { ScratchPad.record :yield }
}.should raise_error(Exception)
@@ -30,19 +30,19 @@ describe Object, "#not_supported_on" do
end
it "does not yield when #implementation? returns true" do
- Object.const_set :RUBY_NAME, "jruby"
+ Object.const_set :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_NAME, "ruby"
+ Object.const_set :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_NAME, "jruby"
+ Object.const_set :RUBY_ENGINE, "jruby"
not_supported_on(:rubinius) { ScratchPad.record :yield }
ScratchPad.recorded.should == :yield
end
diff --git a/spec/mspec/spec/helpers/ruby_exe_spec.rb b/spec/mspec/spec/helpers/ruby_exe_spec.rb
index debfc3b1ca..474ad7b51a 100644
--- a/spec/mspec/spec/helpers/ruby_exe_spec.rb
+++ b/spec/mspec/spec/helpers/ruby_exe_spec.rb
@@ -4,6 +4,10 @@ require 'mspec/helpers'
require 'rbconfig'
class RubyExeSpecs
+ public :ruby_exe_options
+ public :resolve_ruby_exe
+ public :ruby_cmd
+ public :ruby_exe
end
describe "#ruby_exe_options" do
@@ -11,14 +15,14 @@ describe "#ruby_exe_options" do
@verbose = $VERBOSE
$VERBOSE = nil
- @ruby_name = Object.const_get :RUBY_NAME
+ @ruby_engine = Object.const_get :RUBY_ENGINE
@ruby_exe_env = ENV['RUBY_EXE']
@script = RubyExeSpecs.new
end
after :all do
- Object.const_set :RUBY_NAME, @ruby_name
+ Object.const_set :RUBY_ENGINE, @ruby_engine
ENV['RUBY_EXE'] = @ruby_exe_env
$VERBOSE = @verbose
end
@@ -32,33 +36,33 @@ describe "#ruby_exe_options" do
@script.ruby_exe_options(:env).should == "kowabunga"
end
- it "returns 'bin/jruby' when passed :engine and RUBY_NAME is 'jruby'" do
- Object.const_set :RUBY_NAME, 'jruby'
+ it "returns 'bin/jruby' when passed :engine and RUBY_ENGINE is 'jruby'" do
+ Object.const_set :RUBY_ENGINE, 'jruby'
@script.ruby_exe_options(:engine).should == 'bin/jruby'
end
- it "returns 'bin/rbx' when passed :engine, RUBY_NAME is 'rbx'" do
- Object.const_set :RUBY_NAME, 'rbx'
+ it "returns 'bin/rbx' when passed :engine, RUBY_ENGINE is 'rbx'" do
+ Object.const_set :RUBY_ENGINE, 'rbx'
@script.ruby_exe_options(:engine).should == 'bin/rbx'
end
- it "returns 'ir' when passed :engine and RUBY_NAME is 'ironruby'" do
- Object.const_set :RUBY_NAME, 'ironruby'
+ it "returns 'ir' when passed :engine and RUBY_ENGINE is 'ironruby'" do
+ Object.const_set :RUBY_ENGINE, 'ironruby'
@script.ruby_exe_options(:engine).should == 'ir'
end
- it "returns 'maglev-ruby' when passed :engine and RUBY_NAME is 'maglev'" do
- Object.const_set :RUBY_NAME, 'maglev'
+ it "returns 'maglev-ruby' when passed :engine and RUBY_ENGINE is 'maglev'" do
+ Object.const_set :RUBY_ENGINE, 'maglev'
@script.ruby_exe_options(:engine).should == 'maglev-ruby'
end
- it "returns 'topaz' when passed :engine and RUBY_NAME is 'topaz'" do
- Object.const_set :RUBY_NAME, 'topaz'
+ it "returns 'topaz' when passed :engine and RUBY_ENGINE is 'topaz'" do
+ Object.const_set :RUBY_ENGINE, 'topaz'
@script.ruby_exe_options(:engine).should == 'topaz'
end
- it "returns RUBY_NAME + $(EXEEXT) when passed :name" do
- bin = RUBY_NAME + (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
+ it "returns RUBY_ENGINE + $(EXEEXT) when passed :name" do
+ bin = RUBY_ENGINE + (RbConfig::CONFIG['EXEEXT'] || RbConfig::CONFIG['exeext'] || '')
name = File.join ".", bin
@script.ruby_exe_options(:name).should == name
end
diff --git a/spec/mspec/spec/runner/formatters/html_spec.rb b/spec/mspec/spec/runner/formatters/html_spec.rb
index d2aff1b2a7..3783ab6a89 100644
--- a/spec/mspec/spec/runner/formatters/html_spec.rb
+++ b/spec/mspec/spec/runner/formatters/html_spec.rb
@@ -1,5 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require 'mspec/utils/ruby_name'
require 'mspec/guards/guard'
require 'mspec/runner/formatters/html'
require 'mspec/runner/mspec'
@@ -32,14 +31,14 @@ describe HtmlFormatter, "#start" do
it "prints the HTML head" do
@formatter.start
- ruby_name = RUBY_NAME
- ruby_name.should =~ /^#{ruby_name}/
+ ruby_engine = RUBY_ENGINE
+ ruby_engine.should =~ /^#{ruby_engine}/
@out.should ==
%[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
-<title>Spec Output For #{ruby_name} (#{RUBY_VERSION})</title>
+<title>Spec Output For #{ruby_engine} (#{RUBY_VERSION})</title>
<style type="text/css">
ul {
list-style: none;
diff --git a/spec/mspec/spec/utils/options_spec.rb b/spec/mspec/spec/utils/options_spec.rb
index 26c52bdbd0..face909286 100644
--- a/spec/mspec/spec/utils/options_spec.rb
+++ b/spec/mspec/spec/utils/options_spec.rb
@@ -507,30 +507,6 @@ describe "The --prefix STR option" do
end
end
-describe "The -n, --name RUBY_NAME option" do
- before :each do
- @verbose, $VERBOSE = $VERBOSE, nil
- @options, @config = new_option
- end
-
- after :each do
- $VERBOSE = @verbose
- end
-
- it "is enabled with #name" do
- @options.should_receive(:on).with("-n", "--name", "RUBY_NAME",
- an_instance_of(String))
- @options.name
- end
-
- it "sets RUBY_NAME when invoked" do
- Object.should_receive(:const_set).with(:RUBY_NAME, "name").twice
- @options.name
- @options.parse ["-n", "name"]
- @options.parse ["--name", "name"]
- end
-end
-
describe "The -t, --target TARGET option" do
before :each do
@options, @config = new_option
diff --git a/spec/mspec/tool/sync/sync-rubyspec.rb b/spec/mspec/tool/sync/sync-rubyspec.rb
index e7f054ca60..be5082e240 100644
--- a/spec/mspec/tool/sync/sync-rubyspec.rb
+++ b/spec/mspec/tool/sync/sync-rubyspec.rb
@@ -24,6 +24,9 @@ raise RUBYSPEC_REPO unless Dir.exist?(RUBYSPEC_REPO)
NOW = Time.now
+BRIGHT_YELLOW = "\e[33;1m"
+RESET = "\e[0m"
+
class RubyImplementation
attr_reader :name
@@ -110,7 +113,7 @@ def rebase_commits(impl)
rebased = impl.rebased_branch
if branch?(rebased)
- puts "#{rebased} already exists, assuming it correct"
+ puts "#{BRIGHT_YELLOW}#{rebased} already exists, assuming it correct#{RESET}"
sh "git", "checkout", rebased
else
sh "git", "checkout", impl.name
@@ -118,7 +121,7 @@ def rebase_commits(impl)
if ENV["LAST_MERGE"]
last_merge = `git log -n 1 --format='%H %ct' #{ENV["LAST_MERGE"]}`
else
- last_merge = `git log --grep='#{impl.last_merge_message}' -n 1 --format='%H %ct'`
+ last_merge = `git log --grep='^#{impl.last_merge_message}' -n 1 --format='%H %ct'`
end
last_merge, commit_timestamp = last_merge.chomp.split(' ')