Skip to content

Commit

Permalink
Updated MSpec source to f0d9d3f0.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed May 12, 2014
1 parent 26b715b commit e8b848e
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 39 deletions.
14 changes: 8 additions & 6 deletions mspec/lib/mspec/guards/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def initialize(version)
when String
@version = SpecVersion.new version
when Range
a = SpecVersion.new version.first
b = SpecVersion.new version.last
a = SpecVersion.new version.begin
b = SpecVersion.new version.end
@version = version.exclude_end? ? a...b : a..b
end
self.parameters = [version]
Expand All @@ -30,9 +30,11 @@ def match?
class Object
def ruby_version_is(*args)
g = VersionGuard.new(*args)
g.name = :ruby_version_is
yield if g.yield?
ensure
g.unregister
begin
g.name = :ruby_version_is
yield if g.yield?
ensure
g.unregister
end
end
end
4 changes: 2 additions & 2 deletions mspec/lib/mspec/helpers/fs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ def rm_r(*paths)
end

# File.symlink? needs to be checked first as
# File.exists? returns false for dangling symlinks
# 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.exists? path
elsif File.exist? path
File.delete path
end
end
Expand Down
6 changes: 5 additions & 1 deletion mspec/lib/mspec/helpers/io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ def print(*str)
end

def puts(*str)
write(str.collect { |s| s.to_s.chomp }.concat([nil]).join("\n"))
if str.empty?
write "\n"
else
write(str.collect { |s| s.to_s.chomp }.concat([nil]).join("\n"))
end
end

def printf(format, *args)
Expand Down
4 changes: 2 additions & 2 deletions mspec/lib/mspec/helpers/ruby_exe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def resolve_ruby_exe
# 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))
if File.exist?(exe) and (PlatformGuard.windows? or File.executable?(exe))
return [File.expand_path(exe), *rest].join(" ")
end
end
Expand Down Expand Up @@ -142,7 +142,7 @@ def ruby_exe(code, opts = {})
def ruby_cmd(code, opts = {})
body = code

if code and not File.exists?(code)
if code and not File.exist?(code)
if opts[:escape]
code = "'#{code}'"
else
Expand Down
2 changes: 1 addition & 1 deletion mspec/lib/mspec/helpers/tmp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

class Object
def tmp(name, uniquify=true)
Dir.mkdir SPEC_TEMP_DIR unless File.exists? SPEC_TEMP_DIR
Dir.mkdir SPEC_TEMP_DIR unless File.exist? SPEC_TEMP_DIR

if uniquify and !name.empty?
slash = name.rindex "/"
Expand Down
2 changes: 1 addition & 1 deletion mspec/lib/mspec/runner/mspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,6 @@ def self.delete_tag(tag)
# Removes the tag file associated with a spec file.
def self.delete_tags
file = tags_file
File.delete file if File.exists? file
File.delete file if File.exist? file
end
end
2 changes: 1 addition & 1 deletion mspec/lib/mspec/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'mspec/utils/version'

module MSpec
VERSION = SpecVersion.new "1.5.20"
VERSION = SpecVersion.new "1.5.21"
end
32 changes: 16 additions & 16 deletions mspec/spec/helpers/fs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
end

after :each do
File.delete @source if File.exists? @source
File.delete @copy if File.exists? @copy
File.delete @source if File.exist? @source
File.delete @copy if File.exist? @copy
end

it "copies a file" do
Expand All @@ -30,17 +30,17 @@
end

after :each do
File.delete @name if File.exists? @name
File.delete @name if File.exist? @name
end

it "creates a file" do
touch @name
File.exists?(@name).should be_true
File.exist?(@name).should be_true
end

it "accepts an optional mode argument" do
touch @name, "wb"
File.exists?(@name).should be_true
File.exist?(@name).should be_true
end

it "overwrites an existing file" do
Expand Down Expand Up @@ -68,7 +68,7 @@

it "creates all the directories in the path to the file" do
touch @name
File.exists?(@name).should be_true
File.exist?(@name).should be_true
end
end

Expand Down Expand Up @@ -113,10 +113,10 @@
end

after :each do
File.delete @link if File.exists? @link or File.symlink? @link
File.delete @socket if File.exists? @socket
File.delete @subfile if File.exists? @subfile
File.delete @topfile if File.exists? @topfile
File.delete @link if File.exist? @link or File.symlink? @link
File.delete @socket if File.exist? @socket
File.delete @subfile if File.exist? @subfile
File.delete @topfile if File.exist? @topfile

Dir.rmdir @subdir2 if File.directory? @subdir2
Dir.rmdir @subdir1 if File.directory? @subdir1
Expand All @@ -129,20 +129,20 @@

it "removes a single file" do
rm_r @subfile
File.exists?(@subfile).should be_false
File.exist?(@subfile).should be_false
end

it "removes multiple files" do
rm_r @topfile, @subfile
File.exists?(@topfile).should be_false
File.exists?(@subfile).should be_false
File.exist?(@topfile).should be_false
File.exist?(@subfile).should be_false
end

platform_is_not :windows do
it "removes a symlink to a file" do
File.symlink @topfile, @link
rm_r @link
File.exists?(@link).should be_false
File.exist?(@link).should be_false
end

it "removes a symlink to a directory" do
Expand All @@ -151,7 +151,7 @@
lambda do
File.lstat(@link)
end.should raise_error(Errno::ENOENT)
File.exists?(@subdir1).should be_true
File.exist?(@subdir1).should be_true
end

it "removes a dangling symlink" do
Expand All @@ -166,7 +166,7 @@
require 'socket'
UNIXServer.new(@socket).close
rm_r @socket
File.exists?(@socket).should be_false
File.exist?(@socket).should be_false
end
end

Expand Down
5 changes: 5 additions & 0 deletions mspec/spec/helpers/io_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
@out.should == "hello\n1\n2\n3\n"
end

it "provides a puts method that appends separator if argument not given" do
@out.puts
@out.should == "\n"
end

it "provides a printf method" do
@out.printf "%-10s, %03d, %2.1f", "test", 42, 4.2
@out.should == "test , 042, 4.2"
Expand Down
16 changes: 8 additions & 8 deletions mspec/spec/helpers/ruby_exe_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class RubyExeSpecs
it "returns the value returned by #ruby_exe_options if it exists and is executable" do
PlatformGuard.stub!(:windows?).and_return(false)
@script.should_receive(:ruby_exe_options).and_return(@name)
File.should_receive(:exists?).with(@name).and_return(true)
File.should_receive(:exist?).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
Expand All @@ -117,7 +117,7 @@ class RubyExeSpecs
it "returns the value returned by #ruby_exe_options if it exists on Windows platforms" do
PlatformGuard.stub!(:windows?).and_return(true)
@script.should_receive(:ruby_exe_options).and_return(@name)
File.should_receive(:exists?).with(@name).and_return(true)
File.should_receive(:exist?).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
Expand All @@ -126,14 +126,14 @@ class RubyExeSpecs
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(:exist?).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)
File.should_receive(:exist?).at_least(:once).and_return(false)
@script.resolve_ruby_exe.should be_nil
end
end
Expand Down Expand Up @@ -162,23 +162,23 @@ class RubyExeSpecs
end

it "returns a command that runs the given file if it is a file that exists" do
File.should_receive(:exists?).with(@file).and_return(true)
File.should_receive(:exist?).with(@file).and_return(true)
@script.ruby_cmd(@file).should == "ruby_spec_exe -w -Q some/ruby/file.rb"
end

it "includes the given options and arguments with a file" do
File.should_receive(:exists?).with(@file).and_return(true)
File.should_receive(:exist?).with(@file).and_return(true)
@script.ruby_cmd(@file, :options => "-w -Cdir", :args => "< file.txt").should ==
"ruby_spec_exe -w -Q -w -Cdir some/ruby/file.rb < file.txt"
end

it "returns a command that runs code using -e" do
File.should_receive(:exists?).with(@code).and_return(false)
File.should_receive(:exist?).with(@code).and_return(false)
@script.ruby_cmd(@code).should == %(ruby_spec_exe -w -Q -e "some \\"real\\" 'ruby' code")
end

it "includes the given options and arguments with -e" do
File.should_receive(:exists?).with(@code).and_return(false)
File.should_receive(:exist?).with(@code).and_return(false)
@script.ruby_cmd(@code, :options => "-W0 -Cdir", :args => "< file.txt").should ==
%(ruby_spec_exe -w -Q -W0 -Cdir -e "some \\"real\\" 'ruby' code" < file.txt)
end
Expand Down
2 changes: 1 addition & 1 deletion mspec/spec/runner/mspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@

it "deletes the tag file" do
MSpec.delete_tags
File.exists?(@tags).should be_false
File.exist?(@tags).should be_false
end
end

Expand Down

0 comments on commit e8b848e

Please sign in to comment.