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

source_changes at macosforge.org source_changes at macosforge.org
Sun Aug 22 06:13:18 PDT 2010


Revision: 4439
          http://trac.macosforge.org/projects/ruby/changeset/4439
Author:   eloy.de.enige at gmail.com
Date:     2010-08-22 06:13:15 -0700 (Sun, 22 Aug 2010)
Log Message:
-----------
Update MSpec to 66c9eb68ccdc473025d2f6fb34019fc3a977c252

Modified Paths:
--------------
    MacRuby/trunk/mspec/lib/mspec/commands/mspec.rb
    MacRuby/trunk/mspec/lib/mspec/helpers/environment.rb
    MacRuby/trunk/mspec/lib/mspec/helpers/ruby_exe.rb
    MacRuby/trunk/mspec/lib/mspec/helpers.rb
    MacRuby/trunk/mspec/lib/mspec/matchers/have_data.rb
    MacRuby/trunk/mspec/lib/mspec/matchers/raise_error.rb
    MacRuby/trunk/mspec/lib/mspec/matchers.rb
    MacRuby/trunk/mspec/lib/mspec/mocks/mock.rb
    MacRuby/trunk/mspec/lib/mspec/mocks/proxy.rb
    MacRuby/trunk/mspec/lib/mspec/runner/actions.rb
    MacRuby/trunk/mspec/lib/mspec/runner/filters/match.rb
    MacRuby/trunk/mspec/lib/mspec/runner/formatters.rb
    MacRuby/trunk/mspec/lib/mspec/runner/mspec.rb
    MacRuby/trunk/mspec/lib/mspec/runner/shared.rb
    MacRuby/trunk/mspec/lib/mspec/utils/options.rb
    MacRuby/trunk/mspec/spec/commands/mkspec_spec.rb
    MacRuby/trunk/mspec/spec/helpers/enumerator_class_spec.rb
    MacRuby/trunk/mspec/spec/helpers/environment_spec.rb
    MacRuby/trunk/mspec/spec/helpers/fs_spec.rb
    MacRuby/trunk/mspec/spec/helpers/io_spec.rb
    MacRuby/trunk/mspec/spec/matchers/have_data_spec.rb
    MacRuby/trunk/mspec/spec/matchers/have_private_instance_method_spec.rb
    MacRuby/trunk/mspec/spec/matchers/raise_error_spec.rb
    MacRuby/trunk/mspec/spec/runner/shared_spec.rb
    MacRuby/trunk/mspec/upstream

Added Paths:
-----------
    MacRuby/trunk/mspec/lib/mspec/helpers/numeric.rb
    MacRuby/trunk/mspec/lib/mspec/matchers/be_computed_by.rb
    MacRuby/trunk/mspec/lib/mspec/matchers/have_private_method.rb
    MacRuby/trunk/mspec/spec/helpers/numeric_spec.rb
    MacRuby/trunk/mspec/spec/matchers/be_computed_by_spec.rb
    MacRuby/trunk/mspec/spec/matchers/have_private_method_spec.rb

Removed Paths:
-------------
    MacRuby/trunk/mspec/lib/mspec/helpers/bignum.rb
    MacRuby/trunk/mspec/lib/mspec/helpers/infinity.rb
    MacRuby/trunk/mspec/lib/mspec/helpers/nan.rb
    MacRuby/trunk/mspec/lib/mspec/runner/actions/macruby_stats.rb
    MacRuby/trunk/mspec/lib/mspec/runner/formatters/macruby.rb
    MacRuby/trunk/mspec/spec/helpers/bignum_spec.rb
    MacRuby/trunk/mspec/spec/helpers/infinity_spec.rb
    MacRuby/trunk/mspec/spec/helpers/nan_spec.rb

Modified: MacRuby/trunk/mspec/lib/mspec/commands/mspec.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/commands/mspec.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/commands/mspec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -8,6 +8,7 @@
 require 'mspec/helpers/tmp'
 require 'mspec/runner/actions/timer'
 
+
 class MSpecMain < MSpecScript
   def initialize
     config[:includes] = []

Deleted: MacRuby/trunk/mspec/lib/mspec/helpers/bignum.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/helpers/bignum.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/helpers/bignum.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -1,5 +0,0 @@
-class Object
-  def bignum_value(plus=0)
-    0x8000_0000_0000_0000 + plus
-  end
-end

Modified: MacRuby/trunk/mspec/lib/mspec/helpers/environment.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/helpers/environment.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/helpers/environment.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -13,7 +13,7 @@
 
   def windows_env_echo(var)
     `cmd.exe /C ECHO %#{var}%`.strip
-  end  
+  end
 
   def username
     user = ""
@@ -28,5 +28,13 @@
   def home_directory
     return ENV['HOME'] unless PlatformGuard.windows?
     windows_env_echo('HOMEDRIVE') + windows_env_echo('HOMEPATH')
-  end  
+  end
+
+  def dev_null
+    if PlatformGuard.windows?
+      "NUL"
+    else
+      "/dev/null"
+    end
+  end
 end

Deleted: MacRuby/trunk/mspec/lib/mspec/helpers/infinity.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/helpers/infinity.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/helpers/infinity.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -1,5 +0,0 @@
-class Object
-  def infinity_value
-    1/0.0
-  end
-end

Deleted: MacRuby/trunk/mspec/lib/mspec/helpers/nan.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/helpers/nan.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/helpers/nan.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -1,5 +0,0 @@
-class Object
-  def nan_value
-    0/0.0
-  end
-end

Added: MacRuby/trunk/mspec/lib/mspec/helpers/numeric.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/helpers/numeric.rb	                        (rev 0)
+++ MacRuby/trunk/mspec/lib/mspec/helpers/numeric.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -0,0 +1,89 @@
+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
+
+  # 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.
+  guard = SpecGuard.new
+
+  if guard.standard?
+    if guard.wordsize? 32
+      def fixnum_max()
+        (2**30) - 1
+      end
+
+      def fixnum_min()
+        -(2**30)
+      end
+    elsif guard.wordsize? 64
+      def fixnum_max()
+        (2**62) - 1
+      end
+
+      def fixnum_min()
+        -(2**62)
+      end
+    end
+  elsif guard.implementation? :rubinius
+    def fixnum_max()
+      Fixnum::MAX
+    end
+
+    def fixnum_min()
+      Fixnum::MIN
+    end
+  elsif guard.implementation? :jruby
+    # Values from jruby/test/testFixnumBignumAutoconversion.rb
+    def fixnum_max()
+      9223372036854775807
+    end
+
+    def fixnum_min()
+      -9223372036854775808
+    end
+  elsif guard.implementation? :ironruby
+    def fixnum_max()
+      raise "fixnum_max() helper not implemented"
+    end
+
+    def fixnum_min()
+      raise "fixnum_min() helper not implemented"
+    end
+  elsif guard.implementation? :maglev
+    def fixnum_max()
+      raise "fixnum_max() helper not implemented"
+    end
+
+    def fixnum_min()
+      raise "fixnum_min() helper not implemented"
+    end
+  elsif guard.implementation? :macruby
+    def fixnum_max()
+      raise "fixnum_max() helper not implemented"
+    end
+
+    def fixnum_min()
+      raise "fixnum_min() helper not implemented"
+    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
+end

Modified: MacRuby/trunk/mspec/lib/mspec/helpers/ruby_exe.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/helpers/ruby_exe.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/helpers/ruby_exe.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -116,8 +116,6 @@
     end
   end
 
-  RUBY_EXE = './miniruby'
-
   unless Object.const_defined?(:RUBY_EXE) and RUBY_EXE
     require 'rbconfig'
 

Modified: MacRuby/trunk/mspec/lib/mspec/helpers.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/helpers.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/helpers.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -1,5 +1,4 @@
 require 'mspec/helpers/argv'
-require 'mspec/helpers/bignum'
 require 'mspec/helpers/const_lookup'
 require 'mspec/helpers/ducktype'
 require 'mspec/helpers/encode'
@@ -10,12 +9,11 @@
 require 'mspec/helpers/fmode'
 require 'mspec/helpers/fs'
 require 'mspec/helpers/hash'
-require 'mspec/helpers/infinity'
 require 'mspec/helpers/io'
 require 'mspec/helpers/language_version'
 require 'mspec/helpers/metaclass'
 require 'mspec/helpers/mock_to_path'
-require 'mspec/helpers/nan'
+require 'mspec/helpers/numeric'
 require 'mspec/helpers/ruby_exe'
 require 'mspec/helpers/scratch'
 require 'mspec/helpers/tmp'

Added: MacRuby/trunk/mspec/lib/mspec/matchers/be_computed_by.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/matchers/be_computed_by.rb	                        (rev 0)
+++ MacRuby/trunk/mspec/lib/mspec/matchers/be_computed_by.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -0,0 +1,36 @@
+class BeComputedByMatcher
+  def initialize(sym, *args)
+    @method = sym
+    @args = args
+  end
+
+  def matches?(array)
+    array.each do |line|
+      @receiver = line.shift
+      @value = line.pop
+      @arguments = line
+      @arguments += @args
+      return false unless @receiver.send(@method, *@arguments) == @value
+    end
+
+    return true
+  end
+
+  def method_call
+    method_call = "#{@receiver.inspect}.#{@method}"
+    unless @arguments.empty?
+      method_call << " from #{@arguments.map { |x| x.inspect }.join(", ")}"
+    end
+    method_call
+  end
+
+  def failure_message
+    ["Expected #{@value.inspect}", "to be computed by #{method_call}"]
+  end
+end
+
+class Object
+  def be_computed_by(sym, *args)
+    BeComputedByMatcher.new(sym, *args)
+  end
+end

Modified: MacRuby/trunk/mspec/lib/mspec/matchers/have_data.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/matchers/have_data.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/matchers/have_data.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -2,8 +2,9 @@
 require 'mspec/helpers/fmode'
 
 class HaveDataMatcher
-  def initialize(data)
+  def initialize(data, mode="rb:binary")
     @data = data
+    @mode = mode
   end
 
   def matches?(name)
@@ -15,7 +16,7 @@
       size = @data.size
     end
 
-    File.open @name, fmode("rb:binary") do |f|
+    File.open @name, fmode(@mode) do |f|
       return f.read(size) == @data
     end
   end
@@ -42,7 +43,7 @@
   # passes if the file @name has "123" as the first 3 bytes. The
   # file can contain more bytes than +data+. The extra bytes do not
   # affect the result.
-  def have_data(data)
-    HaveDataMatcher.new(data)
+  def have_data(data, mode="rb:binary")
+    HaveDataMatcher.new(data, mode)
   end
 end

Added: MacRuby/trunk/mspec/lib/mspec/matchers/have_private_method.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/matchers/have_private_method.rb	                        (rev 0)
+++ MacRuby/trunk/mspec/lib/mspec/matchers/have_private_method.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -0,0 +1,24 @@
+require 'mspec/matchers/method'
+
+class HavePrivateMethodMatcher < MethodMatcher
+  def matches?(mod)
+    @mod = mod
+    mod.private_methods(@include_super).include? @method
+  end
+
+  def failure_message
+    ["Expected #{@mod} to have private method '#{@method.to_s}'",
+     "but it does not"]
+  end
+
+  def negative_failure_message
+    ["Expected #{@mod} NOT to have private method '#{@method.to_s}'",
+     "but it does"]
+  end
+end
+
+class Object
+  def have_private_method(method, include_super=true)
+    HavePrivateMethodMatcher.new method, include_super
+  end
+end

Modified: MacRuby/trunk/mspec/lib/mspec/matchers/raise_error.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/matchers/raise_error.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/matchers/raise_error.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -37,7 +37,9 @@
   end
 
   def negative_failure_message
-    ["Expected to not get #{@exception}#{%[ (#{@message})] if @message}", ""]
+    message = ["Expected to not get #{@exception}#{%[ (#{@message})] if @message}", ""]
+    message[1] = "but got #{@actual.class}#{%[ (#{@actual.message})] if @actual.message}" unless @actual.class == @exception
+    message
   end
 end
 

Modified: MacRuby/trunk/mspec/lib/mspec/matchers.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/matchers.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/matchers.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -2,6 +2,7 @@
 require 'mspec/matchers/be_an_instance_of'
 require 'mspec/matchers/be_ancestor_of'
 require 'mspec/matchers/be_close'
+require 'mspec/matchers/be_computed_by'
 require 'mspec/matchers/be_empty'
 require 'mspec/matchers/be_false'
 require 'mspec/matchers/be_kind_of'
@@ -19,6 +20,8 @@
 require 'mspec/matchers/have_instance_variable'
 require 'mspec/matchers/have_method'
 require 'mspec/matchers/have_private_instance_method'
+require 'mspec/matchers/have_private_method'
+require 'mspec/matchers/have_protected_instance_method'
 require 'mspec/matchers/have_public_instance_method'
 require 'mspec/matchers/include'
 require 'mspec/matchers/match_yaml'

Modified: MacRuby/trunk/mspec/lib/mspec/mocks/mock.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/mocks/mock.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/mocks/mock.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -118,7 +118,8 @@
 
   def self.verify_call(obj, sym, *args, &block)
     compare = *args
-    if (behaves_like_ruby_1_9 = *[])
+    behaves_like_ruby_1_9 = *[]
+    if (behaves_like_ruby_1_9)
       compare = compare.first if compare.length <= 1
     end
 

Modified: MacRuby/trunk/mspec/lib/mspec/mocks/proxy.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/mocks/proxy.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/mocks/proxy.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -105,7 +105,8 @@
   def with(*args)
     raise ArgumentError, "you must specify the expected arguments" if args.empty?
     @arguments = *args
-    if (behaves_like_ruby_1_9 = *[])
+    behaves_like_ruby_1_9 = *[]
+    if (behaves_like_ruby_1_9)
       @arguments = @arguments.first if @arguments.length <= 1
     end
     self

Deleted: MacRuby/trunk/mspec/lib/mspec/runner/actions/macruby_stats.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/runner/actions/macruby_stats.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/runner/actions/macruby_stats.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -1,103 +0,0 @@
-class MacRubySpecStats
-  attr_accessor :categories
-  attr_reader :category, :subcategory, :file, :tag_files
-  
-  def initialize
-    @categories = {}
-    @tag_files  = []
-  end 
-  
-  # return the current arborescence
-  def push_file(path)
-    category = parse_path(path)
-    @categories[category] ||= {:files => 0, :examples => 0, :expectations => 0, :failures => 0, :errors => 0, :skipped => 0}  
-    @categories[category][:files] += 1
-    category
-  end
-  
-  def push_skipped(category, amount)
-    increase_stats(category, :skipped, amount)
-  end
-  
-  # increases the amount of examples in the category
-  def example!(category)
-    increase_stats(category, :examples)
-  end
-  
-  def expectation!(category) 
-    increase_stats(category, :expectations)
-  end
-  
-  def failure!(category)
-    increase_stats(category, :failures) 
-  end
-  
-  def error!(category)
-    increase_stats(category, :errors) 
-  end
-  
-  protected
-  
-  # Return the spec category
-  def parse_path(path)
-    /spec\/(frozen|macruby)\/(.+?)\//  =~ path
-    $2 
-  end
-  
-  def increase_stats(category, type, amount=1)
-    @categories[category][type] += amount
-  end
-  
-end
-
-
-class MacRubyStatsAction
-  
-  attr_reader :current_category
-  
-  def initialize  
-    @stats = MacRubySpecStats.new
-  end
-  
-  def register
-    MSpec.register :load,        self
-    MSpec.register :exception,   self
-    MSpec.register :example,     self
-    MSpec.register :expectation, self
-  end
-
-  def unregister
-    MSpec.unregister :load,        self
-    MSpec.unregister :exception,   self
-    MSpec.unregister :example,     self
-    MSpec.unregister :expectation, self
-  end
-  
-  def load
-    @current_category = @stats.push_file(MSpec.retrieve(:file))
-    skilled_specs = MSpec.read_tags(['critical', 'fails']).size
-    @stats.push_skipped(current_category, skilled_specs) if skilled_specs > 0 
-    print "."
-  end
-  
-  def example(state, block)
-    @stats.example!(current_category)
-  end
-  
-  def expectation(state)
-    @stats.expectation!(current_category)
-  end
-  
-  def exception(exception)
-    exception.failure? ? @stats.failure!(current_category) : @stats.error!(current_category)
-  end 
-  
-  def categories
-    @stats.categories
-  end
-  
-  def tags
-    @stats.tag_files
-  end
-  
-end
\ No newline at end of file

Modified: MacRuby/trunk/mspec/lib/mspec/runner/actions.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/runner/actions.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/runner/actions.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -6,4 +6,3 @@
 require 'mspec/runner/actions/tagpurge'
 require 'mspec/runner/actions/debug'
 require 'mspec/runner/actions/gdb'
-require 'mspec/runner/actions/macruby_stats'
\ No newline at end of file

Modified: MacRuby/trunk/mspec/lib/mspec/runner/filters/match.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/runner/filters/match.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/runner/filters/match.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -1,11 +1,7 @@
 class MatchFilter
   def initialize(what, *strings)
     @what = what
-    
-    # MR Hack: roxor does not work nicely with encodings yet,
-    # until it does let's assume that no regexps are used in the tags.
-    #@descriptions = to_regexp(*strings)
-    @descriptions = strings
+    @descriptions = to_regexp(*strings)
   end
 
   def to_regexp(*strings)

Deleted: MacRuby/trunk/mspec/lib/mspec/runner/formatters/macruby.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/runner/formatters/macruby.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/runner/formatters/macruby.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -1,72 +0,0 @@
-require 'mspec/expectations/expectations'
-require 'mspec/runner/formatters/dotted'
-require 'mspec/runner/actions/macruby_stats'
-
-class MacRubyFormatter < DottedFormatter
-  def initialize(out=nil)
-    @exception = @failure = false
-    @exceptions = []
-    @count = 0
-    @out = $stdout
-
-    if out.nil?
-      @finish = $stdout
-    else
-      @finish = File.open out, "w"
-    end
-  end
-
-  def switch
-    @out = @finish
-  end
-
-  def after(state)
-  end
-  
-  def register
-    super
-    (@stats = MacRubyStatsAction.new).register
-  end
-  
-  def sum_skipped
-    @stats.categories.inject(0){|sum, cat_info| sum += cat_info.last[:skipped].to_i}
-  end
-
-  def gen_rate(passed, skipped)
-    "%0.2f" % [passed* (100 / (passed + skipped).to_f)]
-  end
-
-  def finish
-    switch
-
-    @stats.categories.each do |key, details|
-      puts ""
-      puts "#{key.capitalize}:"
-      puts "  files: #{details[:files]}"
-      puts "  examples: #{details[:examples]}"
-      puts "  skipped examples: #{details[:skipped]}"
-      puts "  expectations: #{details[:expectations]}"
-      puts "  failures: #{details[:failures]}"
-      puts "  errors: #{details[:errors]}"
-      puts "  pass rate: #{gen_rate(details[:examples], details[:skipped])}%"
-    end 
-
-    puts "\nSummary:"
-    puts "  files: #{@tally.counter.files}"
-    puts "  examples: #{@tally.counter.examples}"
-    puts "  skipped examples: #{sum_skipped}"
-    puts "  expectations: #{@tally.counter.expectations}"
-    puts "  failures: #{@tally.counter.failures}"
-    puts "  errors: #{@tally.counter.errors}"
-    puts "  pass rate: #{gen_rate(@tally.counter.examples, sum_skipped)}%"
-
-    print "\nExceptions:\n" unless @exceptions.empty?
-    count = 0
-    @exceptions.each do |exc|
-      outcome = exc.failure? ? "FAILED" : "ERROR"
-      print "\n#{count += 1})\n#{exc.description} #{outcome}\n"
-      print exc.message, "\n"
-      print exc.backtrace, "\n"
-    end  
-  end
-end

Modified: MacRuby/trunk/mspec/lib/mspec/runner/formatters.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/runner/formatters.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/runner/formatters.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -8,4 +8,3 @@
 require 'mspec/runner/formatters/spinner'
 require 'mspec/runner/formatters/method'
 require 'mspec/runner/formatters/yaml'
-require 'mspec/runner/formatters/macruby'

Modified: MacRuby/trunk/mspec/lib/mspec/runner/mspec.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/runner/mspec.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/runner/mspec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -278,20 +278,13 @@
     tags = []
     file = tags_file
     if File.exist? file
-      # TODO: roxor workaround, or should mspec just use File.read anyways?
-      # File.open(file, "rb") do |f|
-      #   f.each_line do |line|
-      #     line.chomp!
-      #     next if line.empty?
-      #     tag = SpecTag.new line.chomp
-      #     tags << tag if keys.include? tag.tag
-      #   end
-      # end
-      File.read(file).each_line do |line|
-        line.chomp!
-        next if line.empty?
-        tag = SpecTag.new line.chomp
-        tags << tag if keys.include? tag.tag
+      File.open(file, "rb") do |f|
+        f.each_line do |line|
+          line.chomp!
+          next if line.empty?
+          tag = SpecTag.new line.chomp
+          tags << tag if keys.include? tag.tag
+        end
       end
     end
     tags
@@ -335,9 +328,7 @@
       lines = IO.readlines(file)
       File.open(file, "wb") do |f|
         lines.each do |line|
-          # unless pattern =~ line.chomp
-          # FIXME: This is temporary until the regexp specs are passing
-          unless "#{tag.tag}:#{tag.description}" == line.chomp
+          unless pattern =~ line.chomp
             f.puts line unless line.empty?
           else
             deleted = true

Modified: MacRuby/trunk/mspec/lib/mspec/runner/shared.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/runner/shared.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/runner/shared.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -4,7 +4,7 @@
   def it_behaves_like(desc, meth, obj=nil)
     send :before, :all do
       @method = meth
-      @object = obj if obj
+      @object = obj
     end
 
     send :it_should_behave_like, desc.to_s

Modified: MacRuby/trunk/mspec/lib/mspec/utils/options.rb
===================================================================
--- MacRuby/trunk/mspec/lib/mspec/utils/options.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/lib/mspec/utils/options.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -276,8 +276,6 @@
         config[:formatter] = MethodFormatter
       when 'y', 'yaml'
         config[:formatter] = YamlFormatter
-      when 'mr', 'macruby'
-        config[:formatter] = MacRubyFormatter
       else
         puts "Unknown format: #{o}"
         puts @parser
@@ -295,7 +293,6 @@
     doc "       a, *, spin               SpinnerFormatter"
     doc "       t, method                MethodFormatter"
     doc "       y, yaml                  YamlFormatter\n"
-    doc "       mr, macruby              MacRubyFormatter\n"
 
     on("-o", "--output", "FILE",
        "Write formatter output to FILE") do |f|

Modified: MacRuby/trunk/mspec/spec/commands/mkspec_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/commands/mkspec_spec.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/spec/commands/mkspec_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -194,8 +194,9 @@
   end
 
   it "checks if specs exist for the method if the spec file exists" do
+    name = Regexp.escape(@script.ruby)
     @script.should_receive(:`).with(
-        %r"#{@script.ruby} #{MSPEC_HOME}/bin/mspec-run --dry-run -fs -e 'Object#inspect' spec/core/tcejbo/inspect_spec.rb")
+        %r"#{name} #{MSPEC_HOME}/bin/mspec-run --dry-run -fs -e 'Object#inspect' spec/core/tcejbo/inspect_spec.rb")
     @script.write_spec("spec/core/tcejbo/inspect_spec.rb", "Object#inspect", true)
   end
 

Deleted: MacRuby/trunk/mspec/spec/helpers/bignum_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/helpers/bignum_spec.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/spec/helpers/bignum_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -1,11 +0,0 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/bignum'
-
-describe Object, "#bignum_value" do
-  it "returns a value that is an instance of Bignum on any platform" do
-    bignum_value.should ==  0x8000_0000_0000_0000
-  end
-
-  it "returns the default value incremented by the argument" do
-  end
-end

Modified: MacRuby/trunk/mspec/spec/helpers/enumerator_class_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/helpers/enumerator_class_spec.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/spec/helpers/enumerator_class_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -4,15 +4,14 @@
 
 describe "#enumerator_class" do
 
-  ruby_version_is ''...'1.8.7' do
+  ruby_version_is ''...'1.9' do
     it "returns Enumerable::Enumerator in Ruby 1.8.6-" do
-      lambda { enumerator_class }.should raise_error(NameError)
       require 'enumerator'
       enumerator_class.should == Enumerable::Enumerator
     end
   end
 
-  ruby_version_is '1.8.7' do
+  ruby_version_is '1.9' do
     it "returns Enumerator in Ruby 1.8.7+" do
       enumerator_class.should == Enumerator
     end

Modified: MacRuby/trunk/mspec/spec/helpers/environment_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/helpers/environment_spec.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/spec/helpers/environment_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -61,3 +61,15 @@
     username.should == "john"
   end
 end
+
+describe "dev_null" do
+  it "returns 'NUL' on Windows" do
+    PlatformGuard.should_receive(:windows?).and_return(true)
+    dev_null().should == "NUL"
+  end
+
+  it "returns '/dev/null' on non-Windows" do
+    PlatformGuard.should_receive(:windows?).and_return(false)
+    dev_null().should == "/dev/null"
+  end
+end

Modified: MacRuby/trunk/mspec/spec/helpers/fs_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/helpers/fs_spec.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/spec/helpers/fs_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -1,4 +1,5 @@
 require File.dirname(__FILE__) + '/../spec_helper'
+require 'mspec/guards'
 require 'mspec/helpers/tmp'
 require 'mspec/helpers/fs'
 
@@ -138,17 +139,19 @@
     File.exists?(@subfile).should be_false
   end
 
-  it "removes a symlink" do
-    File.symlink @topfile, @link
-    rm_r @link
-    File.exists?(@link).should be_false
-  end
+  platform_is_not :windows do
+    it "removes a symlink" do
+      File.symlink @topfile, @link
+      rm_r @link
+      File.exists?(@link).should be_false
+    end
 
-  it "removes a socket" do
-    require 'socket'
-    UNIXServer.new(@socket).close
-    rm_r @socket
-    File.exists?(@socket).should be_false
+    it "removes a socket" do
+      require 'socket'
+      UNIXServer.new(@socket).close
+      rm_r @socket
+      File.exists?(@socket).should be_false
+    end
   end
 
   it "removes a single directory" do

Deleted: MacRuby/trunk/mspec/spec/helpers/infinity_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/helpers/infinity_spec.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/spec/helpers/infinity_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -1,8 +0,0 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/infinity'
-
-describe Object, "#infinity_value" do
-  it "returns Infinity" do
-    infinity_value.infinite?.should == 1
-  end
-end

Modified: MacRuby/trunk/mspec/spec/helpers/io_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/helpers/io_spec.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/spec/helpers/io_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -1,6 +1,7 @@
 require File.dirname(__FILE__) + '/../spec_helper'
 require 'mspec/helpers/io'
 require 'mspec/helpers/fs'
+require 'mspec/helpers/fmode'
 require 'mspec/helpers/tmp'
 
 describe IOStub do
@@ -59,7 +60,7 @@
     fd = new_fd @name
     fd.should be_an_instance_of(Fixnum)
 
-    @io = IO.new fd
+    @io = IO.new fd, fmode('w:utf-8')
     @io.sync = true
     @io.print "io data"
 

Deleted: MacRuby/trunk/mspec/spec/helpers/nan_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/helpers/nan_spec.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/spec/helpers/nan_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -1,8 +0,0 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/helpers/nan'
-
-describe Object, "#nan_value" do
-  it "returns NaN" do
-    nan_value.nan?.should be_true
-  end
-end

Added: MacRuby/trunk/mspec/spec/helpers/numeric_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/helpers/numeric_spec.rb	                        (rev 0)
+++ MacRuby/trunk/mspec/spec/helpers/numeric_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -0,0 +1,24 @@
+require File.dirname(__FILE__) + '/../spec_helper'
+require 'mspec/helpers/numeric'
+
+describe Object, "#bignum_value" do
+  it "returns a value that is an instance of Bignum on any platform" do
+    bignum_value.should ==  0x8000_0000_0000_0000
+  end
+
+  it "returns the default value incremented by the argument" do
+    bignum_value(42).should == 0x8000_0000_0000_002a
+  end
+end
+
+describe Object, "#nan_value" do
+  it "returns NaN" do
+    nan_value.nan?.should be_true
+  end
+end
+
+describe Object, "#infinity_value" do
+  it "returns Infinity" do
+    infinity_value.infinite?.should == 1
+  end
+end

Added: MacRuby/trunk/mspec/spec/matchers/be_computed_by_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/matchers/be_computed_by_spec.rb	                        (rev 0)
+++ MacRuby/trunk/mspec/spec/matchers/be_computed_by_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -0,0 +1,42 @@
+require File.dirname(__FILE__) + '/../spec_helper'
+require 'mspec/matchers/be_computed_by'
+
+describe BeComputedByMatcher do
+  it "matches when all entries in the Array compute" do
+    array = [ [65, "A"],
+              [90, "Z"] ]
+    BeComputedByMatcher.new(:chr).matches?(array).should be_true
+  end
+
+  it "matches when all entries in the Array with arguments compute" do
+    array = [ [1, 2, 3],
+              [2, 4, 6] ]
+    BeComputedByMatcher.new(:+).matches?(array).should be_true
+  end
+
+  it "does not match when any entry in the Array does not compute" do
+    array = [ [65, "A" ],
+              [91, "Z" ] ]
+    BeComputedByMatcher.new(:chr).matches?(array).should be_false
+  end
+
+  it "accepts an argument list to apply to each method call" do
+    array = [ [65, "1000001" ],
+              [90, "1011010" ] ]
+    BeComputedByMatcher.new(:to_s, 2).matches?(array).should be_true
+  end
+
+  it "does not match when any entry in the Array with arguments does not compute" do
+    array = [ [1, 2, 3],
+              [2, 4, 7] ]
+    BeComputedByMatcher.new(:+).matches?(array).should be_false
+  end
+
+  it "provides a useful failure message" do
+    array = [ [65, "A" ],
+              [91, "Z" ] ]
+    matcher = BeComputedByMatcher.new(:chr)
+    matcher.matches?(array)
+    matcher.failure_message.should == ["Expected \"Z\"", "to be computed by 91.chr"]
+  end
+end

Modified: MacRuby/trunk/mspec/spec/matchers/have_data_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/matchers/have_data_spec.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/spec/matchers/have_data_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -26,13 +26,16 @@
 
   it "does not match when the named file begins with fewer bytes than data" do
     HaveDataMatcher.new("123abcPQR").matches?(@name).should be_false
-
   end
 
   it "does not match when the named file begins with different bytes than data" do
     HaveDataMatcher.new("abc1").matches?(@name).should be_false
   end
 
+  it "accepts an optional mode argument to open the data file" do
+    HaveDataMatcher.new("123a", "r").matches?(@name).should be_true
+  end
+
   it "provides a useful failure message" do
     matcher = HaveDataMatcher.new("abc1")
     matcher.matches?(@name)

Modified: MacRuby/trunk/mspec/spec/matchers/have_private_instance_method_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/matchers/have_private_instance_method_spec.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/spec/matchers/have_private_instance_method_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -46,7 +46,7 @@
     ]
   end
 
-  it "provides a failure messoge for #should_not" do
+  it "provides a failure message for #should_not" do
     matcher = HavePrivateInstanceMethodMatcher.new :some_method
     matcher.matches?(HPIMMSpecs)
     matcher.negative_failure_message.should == [

Added: MacRuby/trunk/mspec/spec/matchers/have_private_method_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/matchers/have_private_method_spec.rb	                        (rev 0)
+++ MacRuby/trunk/mspec/spec/matchers/have_private_method_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -0,0 +1,44 @@
+require File.dirname(__FILE__) + '/../spec_helper'
+require 'mspec/expectations/expectations'
+require 'mspec/matchers/have_private_method'
+
+class HPMMSpecs
+  def self.private_method
+  end
+
+  private_class_method :private_method
+end
+
+describe HavePrivateMethodMatcher do
+  it "inherits from MethodMatcher" do
+    HavePrivateMethodMatcher.new(:m).should be_kind_of(MethodMatcher)
+  end
+
+  it "matches when mod has the private method" do
+    matcher = HavePrivateMethodMatcher.new :private_method
+    matcher.matches?(HPMMSpecs).should be_true
+  end
+
+  it "does not match when mod does not have the private method" do
+    matcher = HavePrivateMethodMatcher.new :another_method
+    matcher.matches?(HPMMSpecs).should be_false
+  end
+
+  it "provides a failure message for #should" do
+    matcher = HavePrivateMethodMatcher.new :some_method
+    matcher.matches?(HPMMSpecs)
+    matcher.failure_message.should == [
+      "Expected HPMMSpecs to have private method 'some_method'",
+      "but it does not"
+    ]
+  end
+
+  it "provides a failure message for #should_not" do
+    matcher = HavePrivateMethodMatcher.new :some_method
+    matcher.matches?(HPMMSpecs)
+    matcher.negative_failure_message.should == [
+      "Expected HPMMSpecs NOT to have private method 'some_method'",
+      "but it does"
+    ]
+  end
+end

Modified: MacRuby/trunk/mspec/spec/matchers/raise_error_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/matchers/raise_error_spec.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/spec/matchers/raise_error_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -53,4 +53,12 @@
     matcher.negative_failure_message.should ==
       ["Expected to not get ExpectedException (expected)", ""]
   end
+
+  it "provides a useful negative failure message for strict subclasses of the matched exception class" do
+    proc = Proc.new { raise UnexpectedException, "unexpected" }
+    matcher = RaiseErrorMatcher.new(Exception, nil)
+    matcher.matches?(proc)
+    matcher.negative_failure_message.should ==
+      ["Expected to not get Exception", "but got UnexpectedException (unexpected)"]
+  end
 end

Modified: MacRuby/trunk/mspec/spec/runner/shared_spec.rb
===================================================================
--- MacRuby/trunk/mspec/spec/runner/shared_spec.rb	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/spec/runner/shared_spec.rb	2010-08-22 13:13:15 UTC (rev 4439)
@@ -29,6 +29,14 @@
     ScratchPad.recorded.should == object
   end
 
+  it "creates @object if the passed false" do
+    object = false
+    @shared.it("an example") { ScratchPad.record @object }
+    @state.it_behaves_like :shared_spec, :some_method, object
+    @state.process
+    ScratchPad.recorded.should == object
+  end
+
   it "sends :it_should_behave_like" do
     @state.should_receive(:it_should_behave_like)
     @state.it_behaves_like :shared_spec, :some_method

Modified: MacRuby/trunk/mspec/upstream
===================================================================
--- MacRuby/trunk/mspec/upstream	2010-08-20 23:04:56 UTC (rev 4438)
+++ MacRuby/trunk/mspec/upstream	2010-08-22 13:13:15 UTC (rev 4439)
@@ -1 +1 @@
-2bbb538ad9bcbd05b984ed2b387e465665c10c00
\ No newline at end of file
+66c9eb68ccdc473025d2f6fb34019fc3a977c252
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100822/2c89b976/attachment-0001.html>


More information about the macruby-changes mailing list