[macruby-changes] [3879] MacRuby/trunk/mspec

source_changes at macosforge.org source_changes at macosforge.org
Sun Mar 28 13:02:44 PDT 2010


Revision: 3879
          http://trac.macosforge.org/projects/ruby/changeset/3879
Author:   eloy.de.enige at gmail.com
Date:     2010-03-28 13:02:44 -0700 (Sun, 28 Mar 2010)
Log Message:
-----------
Update MSpec to 26e25432f613856640a591fe098bec5ed80f40a1

Modified Paths:
--------------
    MacRuby/trunk/mspec/Rakefile
    MacRuby/trunk/mspec/bin/mkspec
    MacRuby/trunk/mspec/bin/mspec
    MacRuby/trunk/mspec/bin/mspec-ci
    MacRuby/trunk/mspec/bin/mspec-run
    MacRuby/trunk/mspec/bin/mspec-tag
    MacRuby/trunk/mspec/lib/mspec/commands/mkspec.rb
    MacRuby/trunk/mspec/lib/mspec/helpers/io.rb
    MacRuby/trunk/mspec/lib/mspec/helpers/tmp.rb
    MacRuby/trunk/mspec/lib/mspec/mocks/mock.rb
    MacRuby/trunk/mspec/lib/mspec/mocks/proxy.rb
    MacRuby/trunk/mspec/lib/mspec/utils/name_map.rb
    MacRuby/trunk/mspec/lib/mspec/utils/options.rb
    MacRuby/trunk/mspec/lib/mspec/version.rb
    MacRuby/trunk/mspec/spec/commands/mkspec_spec.rb
    MacRuby/trunk/mspec/spec/helpers/enumerator_class_spec.rb
    MacRuby/trunk/mspec/spec/helpers/fs_spec.rb
    MacRuby/trunk/mspec/spec/helpers/io_spec.rb
    MacRuby/trunk/mspec/spec/helpers/tmp_spec.rb
    MacRuby/trunk/mspec/spec/mocks/mock_spec.rb
    MacRuby/trunk/mspec/spec/mocks/proxy_spec.rb
    MacRuby/trunk/mspec/spec/runner/mspec_spec.rb
    MacRuby/trunk/mspec/spec/utils/options_spec.rb
    MacRuby/trunk/mspec/upstream

Modified: MacRuby/trunk/mspec/Rakefile
===================================================================
--- MacRuby/trunk/mspec/Rakefile	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/Rakefile	2010-03-28 20:02:44 UTC (rev 3879)
@@ -18,7 +18,7 @@
 
   s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
   s.authors                   = ["Brian Ford"]
-  s.date                      = %q{2010-02-08}
+  s.date                      = %q{2010-03-13}
   s.email                     = %q{bford at engineyard.com}
   s.has_rdoc                  = true
   s.extra_rdoc_files          = %w[ README LICENSE ]

Modified: MacRuby/trunk/mspec/bin/mkspec
===================================================================
--- MacRuby/trunk/mspec/bin/mkspec	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/bin/mkspec	2010-03-28 20:02:44 UTC (rev 3879)
@@ -1,6 +1,6 @@
 #!/usr/bin/env ruby
 
-$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+$:.unshift File.expand_path('../../lib', __FILE__)
 
 require 'mspec/commands/mkspec'
 

Modified: MacRuby/trunk/mspec/bin/mspec
===================================================================
--- MacRuby/trunk/mspec/bin/mspec	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/bin/mspec	2010-03-28 20:02:44 UTC (rev 3879)
@@ -1,6 +1,6 @@
 #!/usr/bin/env ruby
 
-$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+$:.unshift File.expand_path('../../lib', __FILE__)
 
 require 'mspec/commands/mspec'
 

Modified: MacRuby/trunk/mspec/bin/mspec-ci
===================================================================
--- MacRuby/trunk/mspec/bin/mspec-ci	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/bin/mspec-ci	2010-03-28 20:02:44 UTC (rev 3879)
@@ -1,6 +1,6 @@
 #!/usr/bin/env ruby
 
-$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+$:.unshift File.expand_path('../../lib', __FILE__)
 
 require 'mspec/commands/mspec-ci'
 require 'mspec'

Modified: MacRuby/trunk/mspec/bin/mspec-run
===================================================================
--- MacRuby/trunk/mspec/bin/mspec-run	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/bin/mspec-run	2010-03-28 20:02:44 UTC (rev 3879)
@@ -1,6 +1,6 @@
 #!/usr/bin/env ruby
 
-$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+$:.unshift File.expand_path('../../lib', __FILE__)
 
 require 'mspec/commands/mspec-run'
 require 'mspec'

Modified: MacRuby/trunk/mspec/bin/mspec-tag
===================================================================
--- MacRuby/trunk/mspec/bin/mspec-tag	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/bin/mspec-tag	2010-03-28 20:02:44 UTC (rev 3879)
@@ -1,6 +1,6 @@
 #!/usr/bin/env ruby
 
-$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+$:.unshift File.expand_path('../../lib', __FILE__)
 
 require 'mspec/commands/mspec-tag'
 require 'mspec'

Modified: MacRuby/trunk/mspec/lib/mspec/commands/mkspec.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/commands/mkspec.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/lib/mspec/commands/mkspec.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -16,13 +16,14 @@
     @config = {
       :constants => [],
       :requires  => [],
-      :base      => "spec/ruby/1.8/core"
+      :base      => "core",
+      :version   => nil
     }
-    @map = NameMap.new
+    @map = NameMap.new true
   end
 
   def options(argv=ARGV)
-    options = MSpecOptions.new "mkspec [options]"
+    options = MSpecOptions.new "mkspec [options]", 32
 
     options.on("-c", "--constant", "CONSTANT",
                "Class or Module to generate spec stubs for") do |name|
@@ -36,6 +37,10 @@
                "A library to require") do |file|
       config[:requires] << file
     end
+    options.on("-V", "--version-guard", "VERSION",
+               "Specify version for ruby_version_is guards") do |version|
+      config[:version] = version
+    end
     options.version MSpec::VERSION
     options.help
 
@@ -45,7 +50,7 @@
     options.doc "   2. To create spec stubs for Fixnum\n"
     options.doc "     $ mkspec -c Fixnum\n"
     options.doc "   3. To create spec stubs for Complex in 'superspec/complex'\n"
-    options.doc "     $ mkspec -c Complex -rcomplex -b superspec"
+    options.doc "     $ mkspec -c Complex -r complex -b superspec"
     options.doc ""
 
     options.parse argv
@@ -71,13 +76,24 @@
     parents = '../' * ($1.split('/').length + 1)
 
     File.open file, 'w' do |f|
-      f.puts "require File.dirname(__FILE__) + '/#{parents}spec_helper'"
+      f.puts "require File.expand_path('../#{parents}spec_helper', __FILE__)"
       config[:requires].each do |lib|
         f.puts "require '#{lib}'"
       end
     end
   end
 
+  def write_version(f)
+    f.puts ""
+    if version = config[:version]
+      f.puts "ruby_version_is #{version} do"
+      yield "  "
+      f.puts "end"
+    else
+      yield ""
+    end
+  end
+
   def write_spec(file, meth, exists)
     if exists
       out = `#{ruby} #{MSPEC_HOME}/bin/mspec-run --dry-run -fs -e '#{meth}' #{file}`
@@ -85,12 +101,13 @@
     end
 
     File.open file, 'a' do |f|
-      f.puts <<-EOS
-
-describe "#{meth}" do
-  it "needs to be reviewed for spec completeness"
-end
+      write_version(f) do |indent|
+        f.puts <<-EOS
+#{indent}describe "#{meth}" do
+#{indent}  it "needs to be reviewed for spec completeness"
+#{indent}end
 EOS
+      end
     end
 
     puts file
@@ -107,7 +124,7 @@
   def run
     config[:requires].each { |lib| require lib }
     constants = config[:constants]
-    constants = @map.filter(Object.constants) if constants.empty?
+    constants = Object.constants if constants.empty?
 
     @map.map({}, constants).each do |mod, methods|
       name = mod.chop

Modified: MacRuby/trunk/mspec/lib/mspec/helpers/io.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/helpers/io.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/lib/mspec/helpers/io.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -19,3 +19,18 @@
     self
   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")
+    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, fmode(mode))
+  end
+end

Modified: MacRuby/trunk/mspec/lib/mspec/helpers/tmp.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/helpers/tmp.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/lib/mspec/helpers/tmp.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -5,6 +5,8 @@
 
 SPEC_TEMP_DIR = "#{File.expand_path(Dir.pwd)}/rubyspec_temp"
 
+SPEC_TEMP_UNIQUIFIER = "0"
+
 at_exit do
   begin
     Dir.delete SPEC_TEMP_DIR if File.directory? SPEC_TEMP_DIR
@@ -24,9 +26,15 @@
 end
 
 class Object
-  def tmp(name)
+  def tmp(name, uniquify=true)
     Dir.mkdir SPEC_TEMP_DIR unless File.exists? SPEC_TEMP_DIR
 
+    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
 end

Modified: MacRuby/trunk/mspec/lib/mspec/mocks/mock.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/mocks/mock.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/lib/mspec/mocks/mock.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -156,7 +156,12 @@
 
         if pass
           proxy.called
-          return proxy.returning
+
+          if proxy.raising?
+            raise proxy.raising
+          else
+            return proxy.returning
+          end
         end
       end
     end

Modified: MacRuby/trunk/mspec/lib/mspec/mocks/proxy.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/mocks/proxy.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/lib/mspec/mocks/proxy.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -24,9 +24,12 @@
 end
 
 class MockProxy
+  attr_reader :raising, :yielding
+
   def initialize(type=nil)
     @multiple_returns = nil
     @returning = nil
+    @raising   = nil
     @yielding  = []
     @arguments = :any_args
     @type      = type || :mock
@@ -122,15 +125,23 @@
     self
   end
 
+  def and_raise(exception)
+    if exception.kind_of? String
+      @raising = RuntimeError.new exception
+    else
+      @raising = exception
+    end
+  end
+
+  def raising?
+    @raising != nil
+  end
+
   def and_yield(*args)
     @yielding << args
     self
   end
 
-  def yielding
-    @yielding
-  end
-
   def yielding?
     !@yielding.empty?
   end

Modified: MacRuby/trunk/mspec/lib/mspec/utils/name_map.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/utils/name_map.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/lib/mspec/utils/name_map.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -60,8 +60,14 @@
     MSpecScript
     MkSpec
     DTracer
+    Etc
+    FileUtils
+    MSpecOption
+    MSpecOptions
     NameMap
     OptionParser
+    RbConfig
+    SpecVersion
     YAML
   ]
 

Modified: MacRuby/trunk/mspec/lib/mspec/utils/options.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/utils/options.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/lib/mspec/utils/options.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -229,14 +229,14 @@
     end
 
     doc ""
-    doc "     r or ruby              invokes ruby in PATH"
-    doc "     r19, ruby19 or ruby1.9 invokes ruby1.9 in PATH"
-    doc "     x or rubinius          invokes ./bin/rbx"
-    doc "     X or rbx               invokes rbx in PATH"
-    doc "     j or jruby             invokes jruby in PATH"
-    doc "     i or ironruby          invokes ir in PATH"
-    doc "     m or maglev            invokes maglev-ruby in PATH"
-    doc "     full path to EXE       invokes EXE directly\n"
+    doc "     r or ruby        invokes ruby in PATH"
+    doc "     r19, ruby19      invokes ruby1.9 in PATH"
+    doc "     x or rubinius    invokes ./bin/rbx"
+    doc "     X or rbx         invokes rbx in PATH"
+    doc "     j or jruby       invokes jruby in PATH"
+    doc "     i or ironruby    invokes ir in PATH"
+    doc "     m or maglev      invokes maglev-ruby in PATH"
+    doc "     full path to EXE invokes EXE directly\n"
 
     on("-T", "--target-opt", "OPT",
        "Pass OPT as a flag to the target implementation") do |t|

Modified: MacRuby/trunk/mspec/lib/mspec/version.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/version.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/lib/mspec/version.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -1,5 +1,5 @@
 require 'mspec/utils/version'
 
 module MSpec
-  VERSION = SpecVersion.new "1.5.16"
+  VERSION = SpecVersion.new "1.5.17"
 end

Modified: MacRuby/trunk/mspec/spec/commands/mkspec_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/commands/mkspec_spec.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/spec/commands/mkspec_spec.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -74,6 +74,30 @@
   end
 end
 
+describe "The -V, --version-guard VERSION option" do
+  before :each do
+    @options = MSpecOptions.new
+    MSpecOptions.stub!(:new).and_return(@options)
+    @script = MkSpec.new
+    @config = @script.config
+  end
+
+  it "is enabled by #options" do
+    @options.stub!(:on)
+    @options.should_receive(:on).with("-V", "--version-guard", "VERSION",
+      an_instance_of(String))
+    @script.options
+  end
+
+  it "sets the version for the ruby_version_is guards to VERSION" do
+    ["-r", "--require"].each do |opt|
+      @config[:requires] = []
+      @script.options [opt, "libspec"]
+      @config[:requires].should include("libspec")
+    end
+  end
+end
+
 describe MkSpec, "#options" do
   before :each do
     @options = MSpecOptions.new
@@ -143,13 +167,13 @@
   end
 
   it "writes the spec_helper require line" do
-    @file.should_receive(:puts).with("require File.dirname(__FILE__) + '/../../../spec_helper'")
+    @file.should_receive(:puts).with("require File.expand_path('../../../../spec_helper', __FILE__)")
     @script.write_requires("spec/core/tcejbo", "spec/core/tcejbo/inspect_spec.rb")
   end
 
   it "writes require lines for each library specified on the command line" do
     @file.stub!(:puts)
-    @file.should_receive(:puts).with("require File.dirname(__FILE__) + '/../../../spec_helper'")
+    @file.should_receive(:puts).with("require File.expand_path('../../../../spec_helper', __FILE__)")
     @file.should_receive(:puts).with("require 'complex'")
     @script.config[:requires] << 'complex'
     @script.write_requires("spec/core/tcejbo", "spec/core/tcejbo/inspect_spec.rb")
@@ -158,8 +182,7 @@
 
 describe MkSpec, "#write_spec" do
   before :each do
-    @file = mock("file")
-    @file.stub!(:puts)
+    @file = IOStub.new
     File.stub!(:open).and_yield(@file)
 
     @script = MkSpec.new
@@ -198,29 +221,43 @@
   end
 
   it "writes a template spec to the file if the spec file does not exist" do
-    @file.should_receive(:puts)
+    @file.should_receive(:puts).twice
     @script.should_receive(:puts).with("spec/core/tcejbo/inspect_spec.rb")
     @script.write_spec("spec/core/tcejbo/inspect_spec.rb", "Object#inspect", false)
   end
 
   it "writes a template spec to the file if it exists but contains no spec for the method" do
     @response.should_receive(:=~).and_return(false)
-    @file.should_receive(:puts)
+    @file.should_receive(:puts).twice
     @script.should_receive(:puts).with("spec/core/tcejbo/inspect_spec.rb")
     @script.write_spec("spec/core/tcejbo/inspect_spec.rb", "Object#inspect", true)
   end
 
   it "writes a template spec" do
-    @file.should_receive(:puts).with(<<EOS)
+    @script.write_spec("spec/core/tcejbo/inspect_spec.rb", "Object#inspect", true)
+    @file.should == <<EOS
 
 describe "Object#inspect" do
   it "needs to be reviewed for spec completeness"
 end
 EOS
+  end
+
+  it "writes a template spec with version guard" do
+    @script.config[:version] = '""..."1.9"'
     @script.write_spec("spec/core/tcejbo/inspect_spec.rb", "Object#inspect", true)
+    @file.should == <<EOS
+
+ruby_version_is ""..."1.9" do
+  describe "Object#inspect" do
+    it "needs to be reviewed for spec completeness"
   end
 end
+EOS
 
+  end
+end
+
 describe MkSpec, "#create_file" do
   before :each do
     @script = MkSpec.new
@@ -283,14 +320,6 @@
     @script.run
   end
 
-  it "creates a map of Object.constants if not constants are specified" do
-    @script.config[:constants] = []
-    Object.stub!(:constants).and_return(["Object"])
-    @map.should_receive(:filter).with(["Object"]).and_return(["Object"])
-    @map.should_receive(:map).with({}, ["Object"]).and_return({})
-    @script.run
-  end
-
   it "calls #create_directory for each class/module in the map" do
     @script.should_receive(:create_directory).with("MkSpec").twice
     @script.run

Modified: MacRuby/trunk/mspec/spec/helpers/enumerator_class_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/helpers/enumerator_class_spec.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/spec/helpers/enumerator_class_spec.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -1,5 +1,6 @@
 require File.dirname(__FILE__) + '/../spec_helper'
 require 'mspec/helpers/enumerator_class'
+require 'mspec/guards'
 
 describe "#enumerator_class" do
 

Modified: MacRuby/trunk/mspec/spec/helpers/fs_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/helpers/fs_spec.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/spec/helpers/fs_spec.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -59,13 +59,11 @@
 
 describe Object, "#touch" do
   before :all do
-    @dir = tmp("subdir")
     @name = tmp("subdir/touched.txt")
   end
 
   after :each do
-    File.delete @name if File.exists? @name
-    Dir.rmdir @dir if File.directory? @dir
+    rm_r File.dirname(@name)
   end
 
   it "creates all the directories in the path to the file" do

Modified: MacRuby/trunk/mspec/spec/helpers/io_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/helpers/io_spec.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/spec/helpers/io_spec.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -1,4 +1,7 @@
 require File.dirname(__FILE__) + '/../spec_helper'
+require 'mspec/helpers/io'
+require 'mspec/helpers/fs'
+require 'mspec/helpers/tmp'
 
 describe IOStub do
   before :each do
@@ -41,3 +44,56 @@
     @out.flush.should == @out
   end
 end
+
+describe Object, "#new_fd" do
+  before :each do
+    @name = tmp("io_specs")
+  end
+
+  after :each do
+    @io.close unless @io.closed?
+    rm_r @name
+  end
+
+  it "returns a Fixnum that can be used to create an IO instance" do
+    fd = new_fd @name
+    fd.should be_an_instance_of(Fixnum)
+
+    @io = IO.new fd
+    @io.sync = true
+    @io.print "io data"
+
+    IO.read(@name).should == "io data"
+  end
+end
+
+describe Object, "#new_io" do
+  before :each do
+    @name = tmp("io_specs.txt")
+  end
+
+  after :each do
+    @io.close if @io and !@io.closed?
+    rm_r @name
+  end
+
+  it "returns an IO instance" do
+    @io = new_io @name
+    @io.should be_an_instance_of(IO)
+  end
+
+  it "opens the IO for reading if passed 'r'" do
+    touch(@name) { |f| f.print "io data" }
+    @io = new_io @name, "r"
+    @io.read.should == "io data"
+    lambda { @io.puts "more data" }.should raise_error(IOError)
+  end
+
+  it "opens the IO for writing if passed 'w'" do
+    @io = new_io @name, "w"
+    @io.sync = true
+
+    @io.print "io data"
+    IO.read(@name).should == "io data"
+  end
+end

Modified: MacRuby/trunk/mspec/spec/helpers/tmp_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/helpers/tmp_spec.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/spec/helpers/tmp_spec.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -2,9 +2,25 @@
 require 'mspec/helpers/tmp'
 
 describe Object, "#tmp" do
+  before :all do
+    @dir = "#{File.expand_path(Dir.pwd)}/rubyspec_temp"
+  end
+
   it "returns a name relative to the current working directory" do
-    dir = "#{File.expand_path(Dir.pwd)}/rubyspec_temp"
+    tmp("test.txt").should == "#{@dir}/#{SPEC_TEMP_UNIQUIFIER}-test.txt"
+  end
 
-    tmp("test.txt").should == dir + "/test.txt"
+  it "returns a 'unique' name on repeated calls" do
+    a = tmp("text.txt")
+    b = tmp("text.txt")
+    a.should_not == b
   end
+
+  it "does not 'uniquify' the name if requested not to" do
+    tmp("test.txt", false).should == "#{@dir}/test.txt"
+  end
+
+  it "returns the name of the temporary directory when passed an empty string" do
+    tmp("").should == "#{@dir}/"
+  end
 end

Modified: MacRuby/trunk/mspec/spec/mocks/mock_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/mocks/mock_spec.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/spec/mocks/mock_spec.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -207,6 +207,8 @@
   end
 end
 
+class MockAndRaiseError < Exception; end
+
 describe Mock, ".verify_call" do
   before :each do
     MSpec.stub!(:actions)
@@ -304,6 +306,13 @@
       Mock.verify_call(@mock, :method_call) {|*a|}
     }.should_not raise_error(SpecExpectationNotMetError)
   end
+
+  it "raises an exception when expected to" do
+    @proxy.and_raise(MockAndRaiseError)
+    lambda {
+      Mock.verify_call @mock, :method_call
+    }.should raise_error(MockAndRaiseError)
+  end
 end
 
 describe Mock, ".verify_count" do

Modified: MacRuby/trunk/mspec/spec/mocks/proxy_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/mocks/proxy_spec.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/spec/mocks/proxy_spec.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -330,6 +330,29 @@
   end
 end
 
+describe MockProxy, "#raising" do
+  before :each do
+    @proxy = MockProxy.new
+  end
+
+  it "returns nil by default" do
+    @proxy.raising.should be_nil
+  end
+
+  it "returns the exception object passed to #and_raise" do
+    exc = mock("exception")
+    @proxy.and_raise(exc)
+    @proxy.raising.should equal(exc)
+  end
+
+  it "returns an instance of RuntimeError when a String is passed to #and_raise" do
+    @proxy.and_raise("an error")
+    exc = @proxy.raising
+    exc.should be_an_instance_of(RuntimeError)
+    exc.message.should == "an error"
+  end
+end
+
 describe MockProxy, "#yielding" do
   before :each do
     @proxy = MockProxy.new

Modified: MacRuby/trunk/mspec/spec/runner/mspec_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/runner/mspec_spec.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/spec/runner/mspec_spec.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -1,5 +1,6 @@
 require File.dirname(__FILE__) + '/../spec_helper'
 require 'mspec/helpers/tmp'
+require 'mspec/helpers/fs'
 require 'mspec/matchers/base'
 require 'mspec/runner/mspec'
 require 'mspec/runner/example'
@@ -418,12 +419,12 @@
 describe MSpec, ".read_tags" do
   before :each do
     @tag = SpecTag.new "fails:Some#method"
-    File.open(tmp("tags.txt"), "w") do |f|
+    File.open(tmp("tags.txt", false), "w") do |f|
       f.puts ""
       f.puts @tag
       f.puts ""
     end
-    MSpec.stub!(:tags_file).and_return(tmp("tags.txt"))
+    MSpec.stub!(:tags_file).and_return(tmp("tags.txt", false))
   end
 
   it "does not return a tag object for empty lines" do
@@ -433,24 +434,24 @@
 
 describe MSpec, ".write_tags" do
   before :each do
-    FileUtils.cp File.dirname(__FILE__) + "/tags.txt", tmp("tags.txt")
-    MSpec.stub!(:tags_file).and_return(tmp("tags.txt"))
+    FileUtils.cp File.dirname(__FILE__) + "/tags.txt", tmp("tags.txt", false)
+    MSpec.stub!(:tags_file).and_return(tmp("tags.txt", false))
     @tag1 = SpecTag.new "check(broken):Tag#rewrite works"
     @tag2 = SpecTag.new "broken:Tag#write_tags fails"
   end
 
   after :all do
-    File.delete tmp("tags.txt") rescue nil
+    rm_r tmp("tags.txt", false)
   end
 
   it "overwrites the tags in the tag file" do
-    IO.read(tmp("tags.txt")).should == %[fail(broken):Some#method? works
+    IO.read(tmp("tags.txt", false)).should == %[fail(broken):Some#method? works
 incomplete(20%):The#best method ever
 benchmark(0.01825):The#fastest method today
 extended():\"Multi-line\\ntext\\ntag\"
 ]
     MSpec.write_tags [@tag1, @tag2]
-    IO.read(tmp("tags.txt")).should == %[check(broken):Tag#rewrite works
+    IO.read(tmp("tags.txt", false)).should == %[check(broken):Tag#rewrite works
 broken:Tag#write_tags fails
 ]
   end
@@ -459,40 +460,40 @@
 describe MSpec, ".write_tag" do
   before :each do
     FileUtils.stub!(:mkdir_p)
-    MSpec.stub!(:tags_file).and_return(tmp("tags.txt"))
+    MSpec.stub!(:tags_file).and_return(tmp("tags.txt", false))
     @tag = SpecTag.new "fail(broken):Some#method works"
   end
 
   after :all do
-    File.delete tmp("tags.txt") rescue nil
+    rm_r tmp("tags.txt", false)
   end
 
   it "writes a tag to the tags file for the current spec file" do
     MSpec.write_tag @tag
-    IO.read(tmp("tags.txt")).should == "fail(broken):Some#method works\n"
+    IO.read(tmp("tags.txt", false)).should == "fail(broken):Some#method works\n"
   end
 
   it "does not write a duplicate tag" do
-    File.open(tmp("tags.txt"), "w") { |f| f.puts @tag }
+    File.open(tmp("tags.txt", false), "w") { |f| f.puts @tag }
     MSpec.write_tag @tag
-    IO.read(tmp("tags.txt")).should == "fail(broken):Some#method works\n"
+    IO.read(tmp("tags.txt", false)).should == "fail(broken):Some#method works\n"
   end
 end
 
 describe MSpec, ".delete_tag" do
   before :each do
-    FileUtils.cp File.dirname(__FILE__) + "/tags.txt", tmp("tags.txt")
-    MSpec.stub!(:tags_file).and_return(tmp("tags.txt"))
+    FileUtils.cp File.dirname(__FILE__) + "/tags.txt", tmp("tags.txt", false)
+    MSpec.stub!(:tags_file).and_return(tmp("tags.txt", false))
     @tag = SpecTag.new "fail(Comments don't matter):Some#method? works"
   end
 
   after :each do
-    File.delete tmp("tags.txt") rescue nil
+    rm_r tmp("tags.txt", false)
   end
 
   it "deletes the tag if it exists" do
     MSpec.delete_tag(@tag).should == true
-    IO.read(tmp("tags.txt")).should == %[incomplete(20%):The#best method ever
+    IO.read(tmp("tags.txt", false)).should == %[incomplete(20%):The#best method ever
 benchmark(0.01825):The#fastest method today
 extended():\"Multi-line\\ntext\\ntag\"
 ]
@@ -500,7 +501,7 @@
 
   it "deletes a tag with escaped newlines" do
     MSpec.delete_tag(SpecTag.new('extended:"Multi-line\ntext\ntag"')).should == true
-    IO.read(tmp("tags.txt")).should == %[fail(broken):Some#method? works
+    IO.read(tmp("tags.txt", false)).should == %[fail(broken):Some#method? works
 incomplete(20%):The#best method ever
 benchmark(0.01825):The#fastest method today
 ]
@@ -509,7 +510,7 @@
   it "does not change the tags file contents if the tag doesn't exist" do
     @tag.tag = "failed"
     MSpec.delete_tag(@tag).should == false
-    IO.read(tmp("tags.txt")).should == %[fail(broken):Some#method? works
+    IO.read(tmp("tags.txt", false)).should == %[fail(broken):Some#method? works
 incomplete(20%):The#best method ever
 benchmark(0.01825):The#fastest method today
 extended():\"Multi-line\\ntext\\ntag\"
@@ -521,13 +522,13 @@
     MSpec.delete_tag(SpecTag.new("incomplete:The#best method ever")).should == true
     MSpec.delete_tag(SpecTag.new("benchmark:The#fastest method today")).should == true
     MSpec.delete_tag(SpecTag.new("extended:\"Multi-line\ntext\ntag\"")).should == true
-    File.exist?(tmp("tags.txt")).should == false
+    File.exist?(tmp("tags.txt", false)).should == false
   end
 end
 
 describe MSpec, ".delete_tags" do
   before :each do
-    @tags = tmp("tags.txt")
+    @tags = tmp("tags.txt", false)
     FileUtils.cp File.dirname(__FILE__) + "/tags.txt", @tags
     MSpec.stub!(:tags_file).and_return(@tags)
   end

Modified: MacRuby/trunk/mspec/spec/utils/options_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/utils/options_spec.rb	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/spec/utils/options_spec.rb	2010-03-28 20:02:44 UTC (rev 3879)
@@ -544,16 +544,20 @@
     @options.targets
   end
 
-  it "sets the target to 'ruby' and flags to verbose with TARGET 'ruby'" do
+  it "sets the target to 'ruby' and flags to verbose with TARGET 'r' or 'ruby'" do
     ["-t", "--target"].each do |opt|
-      @options.parse [opt, "ruby"]
-      @config[:target].should == "ruby"
+      ["r", "ruby"].each do |t|
+        @config[:target] = nil
+        @options.parse [opt, t]
+        @config[:target].should == "ruby"
+      end
     end
   end
 
   it "sets the target to 'ruby1.9' with TARGET 'r19', 'ruby19' or 'ruby1.9'" do
     ["-t", "--target"].each do |opt|
-      ["r19", "ruby19", "ruby1.9"].each do |t|
+      ["r19", "ruby19"].each do |t|
+        @config[:target] = nil
         @options.parse [opt, t]
         @config[:target].should == "ruby1.9"
       end
@@ -563,6 +567,7 @@
   it "sets the target to 'jruby' with TARGET 'j' or 'jruby'" do
     ["-t", "--target"].each do |opt|
       ["j", "jruby"].each do |t|
+        @config[:target] = nil
         @options.parse [opt, t]
         @config[:target].should == "jruby"
       end
@@ -572,6 +577,7 @@
   it "sets the target to 'shotgun/rubinius' with TARGET 'x' or 'rubinius'" do
     ["-t", "--target"].each do |opt|
       ["x", "rubinius"].each do |t|
+        @config[:target] = nil
         @options.parse [opt, t]
         @config[:target].should == "./bin/rbx"
       end
@@ -581,6 +587,7 @@
   it "set the target to 'rbx' with TARGET 'rbx'" do
     ["-t", "--target"].each do |opt|
       ["X", "rbx"].each do |t|
+        @config[:target] = nil
         @options.parse [opt, t]
         @config[:target].should == "rbx"
       end
@@ -590,6 +597,7 @@
   it "sets the target to 'maglev' with TARGET 'm' or 'maglev'" do
     ["-t", "--target"].each do |opt|
       ["m", "maglev"].each do |t|
+        @config[:target] = nil
         @options.parse [opt, t]
         @config[:target].should == "maglev-ruby"
       end
@@ -598,6 +606,7 @@
 
   it "sets the target to TARGET" do
     ["-t", "--target"].each do |opt|
+      @config[:target] = nil
       @options.parse [opt, "whateva"]
       @config[:target].should == "whateva"
     end

Modified: MacRuby/trunk/mspec/upstream
===================================================================
--- MacRuby/trunk/mspec/upstream	2010-03-28 20:02:17 UTC (rev 3878)
+++ MacRuby/trunk/mspec/upstream	2010-03-28 20:02:44 UTC (rev 3879)
@@ -1 +1 @@
-88d85da83cbf2e595ec956651520ce119d429e8f
\ No newline at end of file
+26e25432f613856640a591fe098bec5ed80f40a1
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100328/fd35a244/attachment-0001.html>


More information about the macruby-changes mailing list