Permalink
Browse files

update mspec to 8a0be99b4844a9f6dfc1eef7092901e6045e5222

  • Loading branch information...
1 parent 1070a0d commit ca1401b0b36bc46c36161c0362c0cada99d82405 @Watson1978 Watson1978 committed Apr 3, 2012
View
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in mspec.gemspec
gemspec
+
+gem 'ruby-debug', :platform => :ruby_18
+gem 'ruby-debug19', :platform => :ruby_19, :require => 'ruby-debug'
@@ -37,4 +37,13 @@ def dev_null
"/dev/null"
end
end
+
+ def hostname
+ commands = ['hostname', 'uname -n']
+ commands.each do |command|
+ name = `#{command}`
+ return name.strip if $?.success?
+ end
+ raise Exception, "hostname: unable to find a working command"
+ end
end
@@ -102,13 +102,13 @@ def ruby_exe_options(option)
def resolve_ruby_exe
[:env, :engine, :name, :install_name].each do |option|
next unless cmd = ruby_exe_options(option)
- exe = cmd.split.first
+ exe, *rest = cmd.split(" ")
# It has been reported that File.executable is not reliable
# on Windows platforms (see commit 56bc555c). So, we check the
# platform.
if File.exists?(exe) and (PlatformGuard.windows? or File.executable?(exe))
- return cmd
+ return [File.expand_path(exe), *rest].join(" ")
end
end
nil
@@ -15,7 +15,8 @@
-----------------------------------------------------
The rubyspec temp directory is not empty. Ensure that
-all specs are cleaning up temporary files.
+all specs are cleaning up temporary files:
+ #{SPEC_TEMP_DIR}
-----------------------------------------------------
EOM
@@ -10,7 +10,8 @@ def matches?(array)
@value = line.pop
@arguments = line
@arguments += @args
- return false unless @receiver.send(@method, *@arguments) == @value
+ @actual = @receiver.send(@method, *@arguments)
+ return false unless @actual == @value
end
return true
@@ -25,7 +26,7 @@ def method_call
end
def failure_message
- ["Expected #{@value.inspect}", "to be computed by #{method_call}"]
+ ["Expected #{@value.inspect}", "to be computed by #{method_call} (computed #{@actual.inspect} instead)"]
end
end
@@ -1,7 +1,8 @@
class BeValidDNSName
# http://stackoverflow.com/questions/106179/regular-expression-to-match-hostname-or-ip-address
# ftp://ftp.rfc-editor.org/in-notes/rfc3696.txt
- VALID_DNS = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\.?$/
+ # http://domainkeys.sourceforge.net/underscore.html
+ VALID_DNS = /^(([a-zA-Z0-9_]|[a-zA-Z0-9_][a-zA-Z0-9\-_]*[a-zA-Z0-9_])\.)*([A-Za-z_]|[A-Za-z_][A-Za-z0-9\-_]*[A-Za-z0-9_])\.?$/
def matches?(actual)
@actual = actual
@@ -10,7 +10,7 @@ def initialize(expected)
def matches?(actual)
@actual = actual
- clean_yaml(@actual) == @expected
+ clean_yaml(@actual) == clean_yaml(@expected)
end
def failure_message
@@ -24,7 +24,7 @@ def negative_failure_message
protected
def clean_yaml(yaml)
- yaml.gsub(/([^-])\s+\n/, "\\1\n")
+ yaml.gsub(/([^-]|^---)\s+\n/, "\\1\n")
end
def valid_yaml?(obj)
View
@@ -34,5 +34,4 @@ Gem::Specification.new do |gem|
gem.add_development_dependency "rake", "~> 0.9"
gem.add_development_dependency "rspec", "~> 2.8"
- gem.add_development_dependency "ruby-debug", "~> 0.10"
end
@@ -38,7 +38,7 @@
end
it "returns a DateTime instance with the specified offset value" do
- d = new_datetime :offset => 3
- d.offset.should == 3
+ d = new_datetime :offset => Rational(3,24)
+ d.offset.should == Rational(3,24)
end
end
@@ -105,6 +105,7 @@ class RubyExeSpecs
@script.should_receive(:ruby_exe_options).and_return(@name)
File.should_receive(:exists?).with(@name).and_return(true)
File.should_receive(:executable?).with(@name).and_return(true)
+ File.should_receive(:expand_path).with(@name).and_return(@name)
@script.resolve_ruby_exe.should == @name
end
@@ -113,9 +114,19 @@ class RubyExeSpecs
@script.should_receive(:ruby_exe_options).and_return(@name)
File.should_receive(:exists?).with(@name).and_return(true)
File.should_not_receive(:executable?)
+ File.should_receive(:expand_path).with(@name).and_return(@name)
@script.resolve_ruby_exe.should == @name
end
+ it "expands the path portion of the result of #ruby_exe_options" do
+ PlatformGuard.stub!(:windows?).and_return(false)
+ @script.should_receive(:ruby_exe_options).and_return("#{@name} -Xfoo")
+ File.should_receive(:exists?).with(@name).and_return(true)
+ File.should_receive(:executable?).with(@name).and_return(true)
+ File.should_receive(:expand_path).with(@name).and_return("/usr/bin/#{@name}")
+ @script.resolve_ruby_exe.should == "/usr/bin/#{@name} -Xfoo"
+ end
+
it "returns nil if no exe is found" do
File.should_receive(:exists?).at_least(:once).and_return(false)
@script.resolve_ruby_exe.should be_nil
@@ -177,6 +188,13 @@ class RubyExeSpecs
@script.ruby_exe nil, :options => "-c", :args => "> file.txt"
end
+ describe "with :dir option" do
+ it "executes the command in the given working directory" do
+ Dir.should_receive(:chdir).with("tmp")
+ @script.ruby_exe nil, :dir => "tmp"
+ end
+ end
+
describe "with :env option" do
before :each do
@script.stub!(:`)
@@ -37,6 +37,6 @@
[91, "Z" ] ]
matcher = BeComputedByMatcher.new(:chr)
matcher.matches?(array)
- matcher.failure_message.should == ["Expected \"Z\"", "to be computed by 91.chr"]
+ matcher.failure_message.should == ["Expected \"Z\"", "to be computed by 91.chr (computed \"[\" instead)"]
end
end
@@ -34,7 +34,12 @@ class UnexpectedException < Exception; end
end
it "does not match when the proc raises the expected exception with an unexpected message" do
- proc = Proc.new { raise UnexpectedException, "unexpected" }
+ proc = Proc.new { raise ExpectedException, "unexpected" }
+ RaiseErrorMatcher.new(ExpectedException, "expected").matches?(proc).should == false
+ end
+
+ it "does not match when the proc does not raise an exception" do
+ proc = Proc.new {}
RaiseErrorMatcher.new(ExpectedException, "expected").matches?(proc).should == false
end
@@ -9,7 +9,7 @@
describe ContextState, "#describe" do
before :each do
@state = ContextState.new "C#m"
- @proc = lambda { ScratchPad.record :a }
+ @proc = lambda {|*| ScratchPad.record :a }
ScratchPad.clear
end
@@ -90,7 +90,7 @@
describe ContextState, "#it" do
before :each do
@state = ContextState.new ""
- @proc = lambda { }
+ @proc = lambda {|*| }
@ex = ExampleState.new("", "", &@proc)
end
@@ -129,7 +129,7 @@
describe ContextState, "#before" do
before :each do
@state = ContextState.new ""
- @proc = lambda { }
+ @proc = lambda {|*| }
end
it "records the block for :each" do
@@ -146,7 +146,7 @@
describe ContextState, "#after" do
before :each do
@state = ContextState.new ""
- @proc = lambda { }
+ @proc = lambda {|*| }
end
it "records the block for :each" do
@@ -162,9 +162,9 @@
describe ContextState, "#pre" do
before :each do
- @a = lambda { }
- @b = lambda { }
- @c = lambda { }
+ @a = lambda {|*| }
+ @b = lambda {|*| }
+ @c = lambda {|*| }
parent = ContextState.new ""
parent.before(:each, &@c)
@@ -189,9 +189,9 @@
describe ContextState, "#post" do
before :each do
- @a = lambda { }
- @b = lambda { }
- @c = lambda { }
+ @a = lambda {|*| }
+ @b = lambda {|*| }
+ @c = lambda {|*| }
parent = ContextState.new ""
parent.after(:each, &@c)
@@ -217,9 +217,9 @@
describe ContextState, "#protect" do
before :each do
ScratchPad.record []
- @a = lambda { ScratchPad << :a }
- @b = lambda { ScratchPad << :b }
- @c = lambda { raise Exception, "Fail!" }
+ @a = lambda {|*| ScratchPad << :a }
+ @b = lambda {|*| ScratchPad << :b }
+ @c = lambda {|*| raise Exception, "Fail!" }
end
it "returns true and does execute any blocks if check and MSpec.mode?(:pretend) are true" do
@@ -374,8 +374,8 @@
@state = ContextState.new ""
@state.describe { }
- @a = lambda { ScratchPad << :a }
- @b = lambda { ScratchPad << :b }
+ @a = lambda {|*| ScratchPad << :a }
+ @b = lambda {|*| ScratchPad << :b }
ScratchPad.record []
end
@@ -658,8 +658,8 @@ def example.example(state, spec)
@state = ContextState.new ""
@state.describe { }
- @a = lambda { ScratchPad << :a }
- @b = lambda { ScratchPad << :b }
+ @a = lambda {|*| ScratchPad << :a }
+ @b = lambda {|*| ScratchPad << :b }
ScratchPad.record []
@state.before(:all) { raise Exception, "Fail!" }
@@ -718,8 +718,8 @@ def example.example(state, spec)
@state = ContextState.new ""
@state.describe { }
- @a = lambda { ScratchPad << :a }
- @b = lambda { ScratchPad << :b }
+ @a = lambda {|*| ScratchPad << :a }
+ @b = lambda {|*| ScratchPad << :b }
ScratchPad.record []
@state.before(:each) { raise Exception, "Fail!" }
@@ -815,8 +815,8 @@ def example.example(state, spec)
@state = ContextState.new ""
@state.describe { }
- @a = lambda { ScratchPad << :a }
- @b = lambda { ScratchPad << :b }
+ @a = lambda {|*| ScratchPad << :a }
+ @b = lambda {|*| ScratchPad << :b }
ScratchPad.record []
end
@@ -921,8 +921,8 @@ def example.example(state, spec)
MSpec.stub!(:retrieve_shared).and_return(@shared)
@state = ContextState.new "Top level"
- @a = lambda { }
- @b = lambda { }
+ @a = lambda {|*| }
+ @b = lambda {|*| }
end
it "raises an Exception if unable to find the shared ContextState" do
@@ -74,7 +74,6 @@ def n; end
DTracer
NameMap
OptionParser
- YAML
]
excluded.each do |const|
View
@@ -1 +1 @@
-d664929940b1f38f6686a6c2aea041feb975418b
+8a0be99b4844a9f6dfc1eef7092901e6045e5222

0 comments on commit ca1401b

Please sign in to comment.