[macruby-changes] [1348] MacRuby/branches/experimental/mspec
source_changes at macosforge.org
source_changes at macosforge.org
Sat Apr 4 15:37:56 PDT 2009
Revision: 1348
http://trac.macosforge.org/projects/ruby/changeset/1348
Author: eloy.de.enige at gmail.com
Date: 2009-04-04 15:37:55 -0700 (Sat, 04 Apr 2009)
Log Message:
-----------
Get MSpec specs passing on 1.9.
Modified Paths:
--------------
MacRuby/branches/experimental/mspec/lib/mspec/commands/mkspec.rb
MacRuby/branches/experimental/mspec/lib/mspec/expectations/expectations.rb
MacRuby/branches/experimental/mspec/lib/mspec/expectations/should.rb
MacRuby/branches/experimental/mspec/lib/mspec/guards/endian.rb
MacRuby/branches/experimental/mspec/lib/mspec/helpers/const_lookup.rb
MacRuby/branches/experimental/mspec/lib/mspec/helpers/flunk.rb
MacRuby/branches/experimental/mspec/lib/mspec/helpers/io.rb
MacRuby/branches/experimental/mspec/lib/mspec/matchers/base.rb
MacRuby/branches/experimental/mspec/lib/mspec/mocks/mock.rb
MacRuby/branches/experimental/mspec/lib/mspec/runner/context.rb
MacRuby/branches/experimental/mspec/lib/mspec/runner/exception.rb
MacRuby/branches/experimental/mspec/lib/mspec/runner/formatters/dotted.rb
MacRuby/branches/experimental/mspec/lib/mspec/utils/name_map.rb
MacRuby/branches/experimental/mspec/lib/mspec/utils/options.rb
MacRuby/branches/experimental/mspec/lib/mspec/utils/script.rb
MacRuby/branches/experimental/mspec/spec/commands/mkspec_spec.rb
MacRuby/branches/experimental/mspec/spec/expectations/expectations_spec.rb
MacRuby/branches/experimental/mspec/spec/expectations/should_spec.rb
MacRuby/branches/experimental/mspec/spec/guards/endian_spec.rb
MacRuby/branches/experimental/mspec/spec/helpers/flunk_spec.rb
MacRuby/branches/experimental/mspec/spec/matchers/base_spec.rb
MacRuby/branches/experimental/mspec/spec/matchers/be_an_instance_of_spec.rb
MacRuby/branches/experimental/mspec/spec/matchers/be_close_spec.rb
MacRuby/branches/experimental/mspec/spec/matchers/be_kind_of_spec.rb
MacRuby/branches/experimental/mspec/spec/matchers/equal_utf16_spec.rb
MacRuby/branches/experimental/mspec/spec/matchers/respond_to_spec.rb
MacRuby/branches/experimental/mspec/spec/mocks/mock_spec.rb
MacRuby/branches/experimental/mspec/spec/runner/actions/tally_spec.rb
MacRuby/branches/experimental/mspec/spec/runner/actions/timer_spec.rb
MacRuby/branches/experimental/mspec/spec/runner/context_spec.rb
MacRuby/branches/experimental/mspec/spec/runner/exception_spec.rb
MacRuby/branches/experimental/mspec/spec/runner/formatters/dotted_spec.rb
MacRuby/branches/experimental/mspec/spec/runner/formatters/file_spec.rb
MacRuby/branches/experimental/mspec/spec/runner/formatters/html_spec.rb
MacRuby/branches/experimental/mspec/spec/runner/formatters/method_spec.rb
MacRuby/branches/experimental/mspec/spec/runner/formatters/specdoc_spec.rb
MacRuby/branches/experimental/mspec/spec/runner/formatters/summary_spec.rb
MacRuby/branches/experimental/mspec/spec/utils/options_spec.rb
MacRuby/branches/experimental/mspec/spec/utils/script_spec.rb
Added Paths:
-----------
MacRuby/branches/experimental/mspec/spec/expectations/should.rb
Modified: MacRuby/branches/experimental/mspec/lib/mspec/commands/mkspec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/commands/mkspec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/commands/mkspec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -116,7 +116,7 @@
methods.each { |method| create_file dir, name, method, mod + method }
end
end
-
+
##
# Determine and return the path of the ruby executable.
Modified: MacRuby/branches/experimental/mspec/lib/mspec/expectations/expectations.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/expectations/expectations.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/expectations/expectations.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -1,17 +1,17 @@
-class ExpectationNotMetError < StandardError; end
-class ExpectationNotFoundError < StandardError
+class SpecExpectationNotMetError < StandardError; end
+class SpecExpectationNotFoundError < StandardError
def message
"No behavior expectation was found in the example"
end
end
-class Expectation
+class SpecExpectation
def self.fail_with(expected, actual)
if expected.to_s.size + actual.to_s.size > 80
message = expected.to_s.chomp + "\n" + actual.to_s
else
message = expected.to_s + " " + actual.to_s
end
- Kernel.raise ExpectationNotMetError, message
+ Kernel.raise SpecExpectationNotMetError, message
end
end
Modified: MacRuby/branches/experimental/mspec/lib/mspec/expectations/should.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/expectations/should.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/expectations/should.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -4,10 +4,10 @@
MSpec.actions :expectation, MSpec.current.state
if matcher
unless matcher.matches?(self)
- Expectation.fail_with(*matcher.failure_message)
+ SpecExpectation.fail_with(*matcher.failure_message)
end
else
- PositiveOperatorMatcher.new(self)
+ SpecPositiveOperatorMatcher.new(self)
end
end
@@ -16,10 +16,10 @@
MSpec.actions :expectation, MSpec.current.state
if matcher
if matcher.matches?(self)
- Expectation.fail_with(*matcher.negative_failure_message)
+ SpecExpectation.fail_with(*matcher.negative_failure_message)
end
else
- NegativeOperatorMatcher.new(self)
+ SpecNegativeOperatorMatcher.new(self)
end
end
end
Modified: MacRuby/branches/experimental/mspec/lib/mspec/guards/endian.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/guards/endian.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/guards/endian.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -3,23 +3,20 @@
# Despite that these are inverses, the two classes are
# used to simplify MSpec guard reporting modes
-class BigEndianGuard < SpecGuard
+class EndianGuard < SpecGuard
def pattern
- [1].pack('L')
+ @pattern ||= [1].pack('L')
end
private :pattern
+end
+class BigEndianGuard < EndianGuard
def match?
pattern[-1] == ?\001
end
end
-class LittleEndianGuard < SpecGuard
- def pattern
- [1].pack('L')
- end
- private :pattern
-
+class LittleEndianGuard < EndianGuard
def match?
pattern[-1] == ?\000
end
Modified: MacRuby/branches/experimental/mspec/lib/mspec/helpers/const_lookup.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/helpers/const_lookup.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/helpers/const_lookup.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -3,7 +3,8 @@
names = c.split '::'
names.shift if names.first.empty?
names.inject(Object) do |m, n|
- m.const_defined?(n) ? m.const_get(n) : m.const_missing(n)
+ defined = RUBY_VERSION =~ /^1.9/ ? m.const_defined?(n, false) : m.const_defined?(n)
+ defined ? m.const_get(n) : m.const_missing(n)
end
end
end
Modified: MacRuby/branches/experimental/mspec/lib/mspec/helpers/flunk.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/helpers/flunk.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/helpers/flunk.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -1,5 +1,5 @@
class Object
def flunk(msg="This example is a failure")
- Expectation.fail_with "Failed:", msg
+ SpecExpectation.fail_with "Failed:", msg
end
end
Modified: MacRuby/branches/experimental/mspec/lib/mspec/helpers/io.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/helpers/io.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/helpers/io.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -1,10 +1,10 @@
class IOStub < String
def write(*str)
- self << str.to_s
+ self << str.join
end
def print(*str)
- write(str.to_s + $\.to_s)
+ write(str.join + $\.to_s)
end
def puts(*str)
Modified: MacRuby/branches/experimental/mspec/lib/mspec/matchers/base.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/matchers/base.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/matchers/base.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -1,94 +1,94 @@
-class PositiveOperatorMatcher
+class SpecPositiveOperatorMatcher
def initialize(actual)
@actual = actual
end
def ==(expected)
unless @actual == expected
- Expectation.fail_with("Expected #{@actual.pretty_inspect}",
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
"to equal #{expected.pretty_inspect}")
end
end
def <(expected)
unless @actual < expected
- Expectation.fail_with("Expected #{@actual.pretty_inspect}",
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
"to be less than #{expected.pretty_inspect}")
end
end
def <=(expected)
unless @actual <= expected
- Expectation.fail_with("Expected #{@actual.pretty_inspect}",
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
"to be less than or equal to #{expected.pretty_inspect}")
end
end
def >(expected)
unless @actual > expected
- Expectation.fail_with("Expected #{@actual.pretty_inspect}",
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
"to be greater than #{expected.pretty_inspect}")
end
end
def >=(expected)
unless @actual >= expected
- Expectation.fail_with("Expected #{@actual.pretty_inspect}",
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
"to be greater than or equal to #{expected.pretty_inspect}")
end
end
def =~(expected)
unless @actual =~ expected
- Expectation.fail_with("Expected #{@actual.pretty_inspect}",
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
"to match #{expected.pretty_inspect}")
end
end
end
-class NegativeOperatorMatcher
+class SpecNegativeOperatorMatcher
def initialize(actual)
@actual = actual
end
def ==(expected)
if @actual == expected
- Expectation.fail_with("Expected #{@actual.pretty_inspect}",
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
"not to equal #{expected.pretty_inspect}")
end
end
def <(expected)
if @actual < expected
- Expectation.fail_with("Expected #{@actual.pretty_inspect}",
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
"not to be less than #{expected.pretty_inspect}")
end
end
def <=(expected)
if @actual <= expected
- Expectation.fail_with("Expected #{@actual.pretty_inspect}",
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
"not to be less than or equal to #{expected.pretty_inspect}")
end
end
def >(expected)
if @actual > expected
- Expectation.fail_with("Expected #{@actual.pretty_inspect}",
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
"not to be greater than #{expected.pretty_inspect}")
end
end
def >=(expected)
if @actual >= expected
- Expectation.fail_with("Expected #{@actual.pretty_inspect}",
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
"not to be greater than or equal to #{expected.pretty_inspect}")
end
end
def =~(expected)
if @actual =~ expected
- Expectation.fail_with("Expected #{@actual.pretty_inspect}",
+ SpecExpectation.fail_with("Expected #{@actual.pretty_inspect}",
"not to match #{expected.pretty_inspect}")
end
end
Modified: MacRuby/branches/experimental/mspec/lib/mspec/mocks/mock.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/mocks/mock.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/mocks/mock.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -77,7 +77,7 @@
false
end
unless pass
- Expectation.fail_with(
+ SpecExpectation.fail_with(
"Mock '#{name_or_inspect obj}' expected to receive '#{sym}' " \
"#{qualifier.to_s.sub('_', ' ')} #{count} times",
"but received it #{proxy.calls} times")
@@ -110,14 +110,14 @@
if block.arity == -1 || block.arity == args_to_yield.size
block.call(*args_to_yield)
else
- Expectation.fail_with(
+ SpecExpectation.fail_with(
"Mock '#{name_or_inspect obj}' asked to yield " \
"|#{proxy.yielding.join(', ')}| on #{sym}\n",
"but a block with arity #{block.arity} was passed")
end
end
else
- Expectation.fail_with(
+ SpecExpectation.fail_with(
"Mock '#{name_or_inspect obj}' asked to yield " \
"|[#{proxy.yielding.join('], [')}]| on #{sym}\n",
"but no block was passed")
@@ -133,7 +133,7 @@
if sym.to_sym == :respond_to?
return obj.__send__(replaced_name(obj, sym), compare)
else
- Expectation.fail_with("Mock '#{name_or_inspect obj}': method #{sym}\n",
+ SpecExpectation.fail_with("Mock '#{name_or_inspect obj}': method #{sym}\n",
"called with unexpected arguments (#{Array(compare).join(' ')})")
end
end
@@ -143,7 +143,7 @@
symbols.uniq.each do |replaced, obj, sym|
meta = class << obj; self; end
- if meta.instance_methods.include?(replaced.to_s)
+ if meta.instance_methods.map { |x| x.to_sym }.include?(replaced.to_sym)
meta.__send__ :alias_method, sym.to_sym, replaced
meta.__send__ :remove_method, replaced
else
Modified: MacRuby/branches/experimental/mspec/lib/mspec/runner/context.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/runner/context.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/runner/context.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -34,7 +34,7 @@
@mock_verify = lambda { Mock.verify_count }
@mock_cleanup = lambda { Mock.cleanup }
- @expectation_missing = lambda { raise ExpectationNotFoundError }
+ @expectation_missing = lambda { raise SpecExpectationNotFoundError }
end
# Returns true if this is a shared +ContextState+. Essentially, when
Modified: MacRuby/branches/experimental/mspec/lib/mspec/runner/exception.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/runner/exception.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/runner/exception.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -18,14 +18,14 @@
end
def failure?
- [ExpectationNotMetError, ExpectationNotFoundError].any? { |e| @exception.is_a? e }
+ [SpecExpectationNotMetError, SpecExpectationNotFoundError].any? { |e| @exception.is_a? e }
end
def message
if @exception.message.empty?
"<No message>"
- elsif @exception.class == ExpectationNotMetError ||
- @exception.class == ExpectationNotFoundError
+ elsif @exception.class == SpecExpectationNotMetError ||
+ @exception.class == SpecExpectationNotFoundError
@exception.message
else
"#{@exception.class}: #{@exception.message}"
Modified: MacRuby/branches/experimental/mspec/lib/mspec/runner/formatters/dotted.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/runner/formatters/dotted.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/runner/formatters/dotted.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -65,8 +65,8 @@
# Callback for the MSpec :after event. Prints an indicator
# for the result of evaluating this example as follows:
# . = No failure or error
- # F = An ExpectationNotMetError was raised
- # E = Any exception other than ExpectationNotMetError
+ # F = An SpecExpectationNotMetError was raised
+ # E = Any exception other than SpecExpectationNotMetError
def after(state = nil)
unless exception?
print "."
Modified: MacRuby/branches/experimental/mspec/lib/mspec/utils/name_map.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/utils/name_map.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/utils/name_map.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -96,11 +96,12 @@
next unless m and not @seen[m]
@seen[m] = true
- ms = m.methods false
+ ms = m.methods(false).map { |x| x.to_s }
hash["#{name}."] = ms.sort unless ms.empty?
ms = m.public_instance_methods(false) +
m.protected_instance_methods(false)
+ ms.map! { |x| x.to_s }
hash["#{name}#"] = ms.sort unless ms.empty?
map hash, m.constants, name
Modified: MacRuby/branches/experimental/mspec/lib/mspec/utils/options.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/utils/options.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/utils/options.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -102,8 +102,10 @@
if option.arg?
arg = argv.shift if arg.nil?
raise ParseError, "No argument provided for #{opt}" unless arg
+ option.block[arg] if option.block
+ else
+ option.block[] if option.block
end
- option.block[arg] if option.block
end
option
end
Modified: MacRuby/branches/experimental/mspec/lib/mspec/utils/script.rb
===================================================================
--- MacRuby/branches/experimental/mspec/lib/mspec/utils/script.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/lib/mspec/utils/script.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -171,7 +171,7 @@
patterns.each do |pattern|
expanded = File.expand_path(pattern)
- return [pattern] if File.file?(expanded)
+ return [expanded] if File.file?(expanded)
specs = File.join(pattern, "/**/*_spec.rb")
specs = File.expand_path(specs) rescue specs
Modified: MacRuby/branches/experimental/mspec/spec/commands/mkspec_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/commands/mkspec_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/commands/mkspec_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -297,7 +297,8 @@
end
it "calls #create_file for each method on each class/module in the map" do
- @map.should_receive(:map).with({}, @script.config[:constants]).and_return({"MkSpec#" => "run"})
+ @map.should_receive(:map).with({}, @script.config[:constants]
+ ).and_return({"MkSpec#" => ["run"]})
@script.should_receive(:create_file).with("spec/mkspec", "MkSpec", "run", "MkSpec#run")
@script.run
end
Modified: MacRuby/branches/experimental/mspec/spec/expectations/expectations_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/expectations/expectations_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/expectations/expectations_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -1,29 +1,29 @@
require File.dirname(__FILE__) + '/../spec_helper'
require 'mspec/expectations/expectations'
-describe ExpectationNotMetError do
+describe SpecExpectationNotMetError do
it "is a subclass of StandardError" do
- ExpectationNotMetError.ancestors.should include(StandardError)
+ SpecExpectationNotMetError.ancestors.should include(StandardError)
end
end
-describe ExpectationNotFoundError do
+describe SpecExpectationNotFoundError do
it "is a subclass of StandardError" do
- ExpectationNotFoundError.ancestors.should include(StandardError)
+ SpecExpectationNotFoundError.ancestors.should include(StandardError)
end
end
-describe ExpectationNotFoundError, "#message" do
+describe SpecExpectationNotFoundError, "#message" do
it "returns 'No behavior expectation was found in the example'" do
- m = ExpectationNotFoundError.new.message
+ m = SpecExpectationNotFoundError.new.message
m.should == "No behavior expectation was found in the example"
end
end
-describe Expectation, "#fail_with" do
- it "raises an ExpectationNotMetError" do
+describe SpecExpectation, "#fail_with" do
+ it "raises an SpecExpectationNotMetError" do
lambda {
- Expectation.fail_with "expected this", "to equal that"
- }.should raise_error(ExpectationNotMetError, "expected this to equal that")
+ SpecExpectation.fail_with "expected this", "to equal that"
+ }.should raise_error(SpecExpectationNotMetError, "expected this to equal that")
end
end
Added: MacRuby/branches/experimental/mspec/spec/expectations/should.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/expectations/should.rb (rev 0)
+++ MacRuby/branches/experimental/mspec/spec/expectations/should.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -0,0 +1,71 @@
+$: << File.dirname(__FILE__) + '/../../lib'
+require 'mspec'
+
+# The purpose of these specs is to confirm that the #should
+# and #should_not methods are functioning appropriately. We
+# use a separate spec file that is invoked from the MSpec
+# specs but is run by MSpec. This avoids conflicting with
+# RSpec's #should and #should_not methods.
+
+class ShouldSpecsMonitor
+ def initialize
+ @called = 0
+ end
+
+ def expectation(state)
+ @called += 1
+ end
+
+ def finish
+ puts "I was called #{@called} times"
+ end
+end
+
+# Simplistic runner
+formatter = DottedFormatter.new
+formatter.register
+
+monitor = ShouldSpecsMonitor.new
+MSpec.register :expectation, monitor
+MSpec.register :finish, monitor
+
+at_exit { MSpec.actions :finish }
+
+MSpec.actions :start
+
+# Specs
+describe "MSpec expectation method #should" do
+ it "accepts a matcher" do
+ :sym.should be_kind_of(Symbol)
+ end
+
+ it "causes a failue to be recorded" do
+ 1.should == 2
+ end
+
+ it "registers that an expectation has been encountered" do
+ # an empty example block causes an exception because
+ # no expectation was encountered
+ end
+
+ it "invokes the MSpec :expectation actions" do
+ 1.should == 1
+ end
+end
+
+describe "MSpec expectation method #should_not" do
+ it "accepts a matcher" do
+ "sym".should_not be_kind_of(Symbol)
+ end
+
+ it "causes a failure to be recorded" do
+ 1.should_not == 1
+ end
+
+ it "registers that an expectation has been encountered" do
+ end
+
+ it "invokes the MSpec :expectation actions" do
+ 1.should_not == 2
+ end
+end
Modified: MacRuby/branches/experimental/mspec/spec/expectations/should_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/expectations/should_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/expectations/should_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -1,129 +1,61 @@
require File.dirname(__FILE__) + '/../spec_helper'
-require 'mspec/expectations/expectations'
-require 'mspec/matchers/base'
-require 'mspec/runner/mspec'
+require 'rbconfig'
-class Object
- alias_method :rspec_should, :should
- alias_method :rspec_should_not, :should_not
-end
-require 'mspec/expectations/should'
-class Object
- alias_method :mspec_should, :should
- alias_method :mspec_should_not, :should_not
- alias_method :should, :rspec_should
- alias_method :should_not, :rspec_should_not
-end
-
-# Adapted from RSpec 1.0.8
-describe Object, "#should" do
- before :each do
- class Object; alias_method :should, :mspec_should; end
-
- @state = mock("example state", :null_object => true)
- context = mock("context state", :null_object => true)
- context.stub!(:state).and_return(@state)
- MSpec.stub!(:current).and_return(context)
- MSpec.stub!(:actions)
-
- @target = "target"
- @matcher = mock("matcher", :null_object => true)
+describe MSpec do
+ before :all do
+ path = Config::CONFIG['bindir']
+ exe = Config::CONFIG['ruby_install_name']
+ file = File.dirname(__FILE__) + '/should.rb'
+ @out = `#{path}/#{exe} #{file}`
end
- after :each do
- class Object; alias_method :should, :rspec_should; end
- end
+ describe "#should" do
+ it "records failures" do
+ @out.should =~ Regexp.new(Regexp.escape(%[
+1)
+MSpec expectation method #should causes a failue to be recorded FAILED
+Expected 1
+ to equal 2
+]))
+ end
- it "accepts and interacts with a matcher" do
- @matcher.should_receive(:matches?).with(@target).and_return(true)
- @target.should @matcher
+ it "raises exceptions for examples with no expectations" do
+ @out.should =~ Regexp.new(Regexp.escape(%[
+2)
+MSpec expectation method #should registers that an expectation has been encountered FAILED
+No behavior expectation was found in the example
+]))
+ end
end
- it "calls #failure_message when matcher #matches? returns false" do
- @matcher.should_receive(:matches?).with(@target).and_return(false)
- @matcher.should_receive(:failure_message).and_return(["expected", "actual"])
- @target.should @matcher rescue nil
- end
+ describe "#should_not" do
+ it "records failures" do
+ @out.should =~ Regexp.new(Regexp.escape(%[
+3)
+MSpec expectation method #should_not causes a failure to be recorded FAILED
+Expected 1
+ not to equal 1
+]))
+ end
- it "raises an ExpectationNotMetError when matcher #matches? returns false" do
- @matcher.should_receive(:matches?).with(@target).and_return(false)
- @matcher.should_receive(:failure_message).and_return(["expected", "actual"])
- lambda {
- @target.should @matcher
- }.should raise_error(ExpectationNotMetError, "expected actual")
+ it "raises exceptions for examples with no expectations" do
+ @out.should =~ Regexp.new(Regexp.escape(%[
+4)
+MSpec expectation method #should_not registers that an expectation has been encountered FAILED
+No behavior expectation was found in the example
+]))
+ end
end
- it "returns a PostiveOperatorMatcher instance when not passed a matcher" do
- matcher = should
- class Object; alias_method :should, :rspec_should; end
- matcher.should be_instance_of(PositiveOperatorMatcher)
+ it "prints status information" do
+ @out.should =~ /\.FF\.\.FF\./
end
- it "invokes the MSpec :expectation actions" do
- MSpec.should_receive(:actions).with(:expectation, @state)
- @target.should @matcher
+ it "prints out a summary" do
+ @out.should =~ /0 files, 8 examples, 6 expectations, 4 failures, 0 errors/
end
- it "registers that an expectation has been encountered" do
- MSpec.should_receive(:expectation)
- @target.should @matcher
+ it "records expectations" do
+ @out.should =~ /I was called 6 times/
end
end
-
-describe Object, "#should_not" do
- before :each do
- class Object; alias_method :should, :mspec_should; end
- class Object; alias_method :should_not, :mspec_should_not; end
-
- @state = mock("example state", :null_object => true)
- context = mock("context state", :null_object => true)
- context.stub!(:state).and_return(@state)
- MSpec.stub!(:current).and_return(context)
- MSpec.stub!(:actions)
-
- @target = "target"
- @matcher = mock("matcher", :null_object => true)
- end
-
- after :each do
- class Object; alias_method :should, :rspec_should; end
- class Object; alias_method :should_not, :rspec_should_not; end
- end
-
- it "accepts and interacts with a matcher" do
- @matcher.should_receive(:matches?).with(@target).and_return(false)
- @target.should_not @matcher
- end
-
- it "calls #negative_failure_message when matcher.matches? returns true" do
- @matcher.should_receive(:matches?).with(@target).and_return(true)
- @matcher.should_receive(:negative_failure_message).and_return(["expected", "actual"])
- @target.should_not @matcher rescue nil
- end
-
- it "raises an ExpectationNotMetError when matcher.matches? returns true" do
- @matcher.should_receive(:matches?).with(@target).and_return(true)
- @matcher.should_receive(:negative_failure_message).and_return(["expected", "actual"])
- lambda {
- @target.should_not @matcher
- }.should raise_error(ExpectationNotMetError, "expected actual")
- end
-
- it "returns a NegativeOperatorMatcher instance when not passed a matcher" do
- matcher = should_not nil
- class Object; alias_method :should, :rspec_should; end
- matcher.should be_instance_of(NegativeOperatorMatcher)
- end
-
- it "invokes the MSpec :expectation actions" do
- MSpec.should_receive(:actions).with(:expectation, @state)
- @matcher.should_receive(:negative_failure_message).and_return(["expected", "actual"])
- @target.should_not @matcher rescue nil
- end
-
- it "registers that an expectation has been encountered" do
- MSpec.should_receive(:expectation)
- @matcher.should_receive(:negative_failure_message).and_return(["expected", "actual"])
- @target.should_not @matcher rescue nil
- end
-end
Modified: MacRuby/branches/experimental/mspec/spec/guards/endian_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/guards/endian_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/guards/endian_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -9,13 +9,13 @@
end
it "yields on big-endian platforms" do
- @guard.stub!(:pattern).and_return([1])
+ @guard.stub!(:pattern).and_return([?\001])
big_endian { ScratchPad.record :yield }
ScratchPad.recorded.should == :yield
end
it "does not yield on little-endian platforms" do
- @guard.stub!(:pattern).and_return([0])
+ @guard.stub!(:pattern).and_return([?\000])
big_endian { ScratchPad.record :yield }
ScratchPad.recorded.should_not == :yield
end
@@ -26,7 +26,7 @@
end
it "calls #unregister even when an exception is raised in the guard block" do
- @guard.stub!(:pattern).and_return([1])
+ @guard.stub!(:pattern).and_return([?\001])
@guard.should_receive(:unregister)
lambda do
big_endian { raise Exception }
@@ -42,13 +42,13 @@
end
it "yields on little-endian platforms" do
- @guard.stub!(:pattern).and_return([0])
+ @guard.stub!(:pattern).and_return([?\000])
little_endian { ScratchPad.record :yield }
ScratchPad.recorded.should == :yield
end
it "does not yield on big-endian platforms" do
- @guard.stub!(:pattern).and_return([1])
+ @guard.stub!(:pattern).and_return([?\001])
little_endian { ScratchPad.record :yield }
ScratchPad.recorded.should_not == :yield
end
@@ -59,7 +59,7 @@
end
it "calls #unregister even when an exception is raised in the guard block" do
- @guard.stub!(:pattern).and_return([0])
+ @guard.stub!(:pattern).and_return([?\000])
@guard.should_receive(:unregister)
lambda do
little_endian { raise Exception }
Modified: MacRuby/branches/experimental/mspec/spec/helpers/flunk_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/helpers/flunk_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/helpers/flunk_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -9,11 +9,11 @@
MSpec.stub!(:current).and_return(mock("spec state", :null_object => true))
end
- it "raises an ExpectationNotMetError unconditionally" do
- lambda { flunk }.should raise_error(ExpectationNotMetError)
+ it "raises an SpecExpectationNotMetError unconditionally" do
+ lambda { flunk }.should raise_error(SpecExpectationNotMetError)
end
it "accepts on argument for an optional message" do
- lambda {flunk "test"}.should raise_error(ExpectationNotMetError)
+ lambda {flunk "test"}.should raise_error(SpecExpectationNotMetError)
end
end
Modified: MacRuby/branches/experimental/mspec/spec/matchers/base_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/matchers/base_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/matchers/base_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -3,214 +3,223 @@
require 'mspec/matchers/base'
require 'time'
-describe PositiveOperatorMatcher, "== operator" do
- it "raises an ExpectationNotMetError when expected == actual returns false" do
+describe SpecPositiveOperatorMatcher, "== operator" do
+ it "raises an SpecExpectationNotMetError when expected == actual returns false" do
lambda {
- PositiveOperatorMatcher.new(1) == 2
- }.should raise_error(ExpectationNotMetError)
+ SpecPositiveOperatorMatcher.new(1) == 2
+ }.should raise_error(SpecExpectationNotMetError)
end
it "provides a failure message that 'Expected x to equal y'" do
- Expectation.should_receive(:fail_with).with("Expected 1\n", "to equal 2\n")
- PositiveOperatorMatcher.new(1) == 2
+ SpecExpectation.should_receive(:fail_with).with("Expected 1\n", "to equal 2\n")
+ SpecPositiveOperatorMatcher.new(1) == 2
end
it "does not raise an exception when expected == actual returns true" do
- PositiveOperatorMatcher.new(1) == 1
+ SpecPositiveOperatorMatcher.new(1) == 1
end
end
-describe PositiveOperatorMatcher, "=~ operator" do
- it "raises an ExpectationNotMetError when expected =~ actual returns false" do
+describe SpecPositiveOperatorMatcher, "=~ operator" do
+ it "raises an SpecExpectationNotMetError when expected =~ actual returns false" do
lambda {
- PositiveOperatorMatcher.new('real') =~ /fake/
- }.should raise_error(ExpectationNotMetError)
+ SpecPositiveOperatorMatcher.new('real') =~ /fake/
+ }.should raise_error(SpecExpectationNotMetError)
end
it "provides a failure message that 'Expected \"x\" to match y'" do
- Expectation.should_receive(:fail_with).with("Expected \"real\"\n", "to match /fake/\n")
- PositiveOperatorMatcher.new('real') =~ /fake/
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected \"real\"\n", "to match /fake/\n")
+ SpecPositiveOperatorMatcher.new('real') =~ /fake/
end
it "does not raise an exception when expected =~ actual returns true" do
- PositiveOperatorMatcher.new('real') =~ /real/
+ SpecPositiveOperatorMatcher.new('real') =~ /real/
end
end
-describe PositiveOperatorMatcher, "> operator" do
- it "raises an ExpectationNotMetError when expected > actual returns false" do
+describe SpecPositiveOperatorMatcher, "> operator" do
+ it "raises an SpecExpectationNotMetError when expected > actual returns false" do
lambda {
- PositiveOperatorMatcher.new(4) > 5
- }.should raise_error(ExpectationNotMetError)
+ SpecPositiveOperatorMatcher.new(4) > 5
+ }.should raise_error(SpecExpectationNotMetError)
end
it "provides a failure message that 'Expected x to be greater than y'" do
- Expectation.should_receive(:fail_with).with("Expected 4\n", "to be greater than 5\n")
- PositiveOperatorMatcher.new(4) > 5
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected 4\n", "to be greater than 5\n")
+ SpecPositiveOperatorMatcher.new(4) > 5
end
it "does not raise an exception when expected > actual returns true" do
- PositiveOperatorMatcher.new(5) > 4
+ SpecPositiveOperatorMatcher.new(5) > 4
end
end
-describe PositiveOperatorMatcher, ">= operator" do
- it "raises an ExpectationNotMetError when expected >= actual returns false" do
+describe SpecPositiveOperatorMatcher, ">= operator" do
+ it "raises an SpecExpectationNotMetError when expected >= actual returns false" do
lambda {
- PositiveOperatorMatcher.new(4) >= 5
- }.should raise_error(ExpectationNotMetError)
+ SpecPositiveOperatorMatcher.new(4) >= 5
+ }.should raise_error(SpecExpectationNotMetError)
end
it "provides a failure message that 'Expected x to be greater than or equal to y'" do
- Expectation.should_receive(:fail_with).with("Expected 4\n", "to be greater than or equal to 5\n")
- PositiveOperatorMatcher.new(4) >= 5
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected 4\n", "to be greater than or equal to 5\n")
+ SpecPositiveOperatorMatcher.new(4) >= 5
end
it "does not raise an exception when expected > actual returns true" do
- PositiveOperatorMatcher.new(5) >= 4
- PositiveOperatorMatcher.new(5) >= 5
+ SpecPositiveOperatorMatcher.new(5) >= 4
+ SpecPositiveOperatorMatcher.new(5) >= 5
end
end
-describe PositiveOperatorMatcher, "< operater" do
- it "raises an ExpectationNotMetError when expected < actual returns false" do
+describe SpecPositiveOperatorMatcher, "< operater" do
+ it "raises an SpecExpectationNotMetError when expected < actual returns false" do
lambda {
- PositiveOperatorMatcher.new(5) < 4
- }.should raise_error(ExpectationNotMetError)
+ SpecPositiveOperatorMatcher.new(5) < 4
+ }.should raise_error(SpecExpectationNotMetError)
end
it "provides a failure message that 'Expected x to be less than y'" do
- Expectation.should_receive(:fail_with).with("Expected 5\n", "to be less than 4\n")
- PositiveOperatorMatcher.new(5) < 4
+ SpecExpectation.should_receive(:fail_with).with("Expected 5\n", "to be less than 4\n")
+ SpecPositiveOperatorMatcher.new(5) < 4
end
it "does not raise an exception when expected < actual returns true" do
- PositiveOperatorMatcher.new(4) < 5
+ SpecPositiveOperatorMatcher.new(4) < 5
end
end
-describe PositiveOperatorMatcher, "<= operater" do
- it "raises an ExpectationNotMetError when expected < actual returns false" do
+describe SpecPositiveOperatorMatcher, "<= operater" do
+ it "raises an SpecExpectationNotMetError when expected < actual returns false" do
lambda {
- PositiveOperatorMatcher.new(5) <= 4
- }.should raise_error(ExpectationNotMetError)
+ SpecPositiveOperatorMatcher.new(5) <= 4
+ }.should raise_error(SpecExpectationNotMetError)
end
it "provides a failure message that 'Expected x to be less than or equal to y'" do
- Expectation.should_receive(:fail_with).with("Expected 5\n", "to be less than or equal to 4\n")
- PositiveOperatorMatcher.new(5) <= 4
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected 5\n", "to be less than or equal to 4\n")
+ SpecPositiveOperatorMatcher.new(5) <= 4
end
it "does not raise an exception when expected < actual returns true" do
- PositiveOperatorMatcher.new(4) <= 5
- PositiveOperatorMatcher.new(4) <= 4
+ SpecPositiveOperatorMatcher.new(4) <= 5
+ SpecPositiveOperatorMatcher.new(4) <= 4
end
end
-describe NegativeOperatorMatcher, "== operator" do
- it "raises an ExpectationNotMetError when expected == actual returns true" do
+describe SpecNegativeOperatorMatcher, "== operator" do
+ it "raises an SpecExpectationNotMetError when expected == actual returns true" do
lambda {
- NegativeOperatorMatcher.new(1) == 1
- }.should raise_error(ExpectationNotMetError)
+ SpecNegativeOperatorMatcher.new(1) == 1
+ }.should raise_error(SpecExpectationNotMetError)
end
it "provides a failure message that 'Expected x not to equal y'" do
- Expectation.should_receive(:fail_with).with("Expected 1\n", "not to equal 1\n")
- NegativeOperatorMatcher.new(1) == 1
+ SpecExpectation.should_receive(:fail_with).with("Expected 1\n", "not to equal 1\n")
+ SpecNegativeOperatorMatcher.new(1) == 1
end
it "does not raise an exception when expected == actual returns false" do
- NegativeOperatorMatcher.new(1) == 2
+ SpecNegativeOperatorMatcher.new(1) == 2
end
end
-describe NegativeOperatorMatcher, "=~ operator" do
- it "raises an ExpectationNotMetError when expected =~ actual returns true" do
+describe SpecNegativeOperatorMatcher, "=~ operator" do
+ it "raises an SpecExpectationNotMetError when expected =~ actual returns true" do
lambda {
- NegativeOperatorMatcher.new('real') =~ /real/
- }.should raise_error(ExpectationNotMetError)
+ SpecNegativeOperatorMatcher.new('real') =~ /real/
+ }.should raise_error(SpecExpectationNotMetError)
end
it "provides a failure message that 'Expected \"x\" not to match /y/'" do
- Expectation.should_receive(:fail_with).with("Expected \"real\"\n", "not to match /real/\n")
- NegativeOperatorMatcher.new('real') =~ /real/
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected \"real\"\n", "not to match /real/\n")
+ SpecNegativeOperatorMatcher.new('real') =~ /real/
end
it "does not raise an exception when expected =~ actual returns false" do
- NegativeOperatorMatcher.new('real') =~ /fake/
+ SpecNegativeOperatorMatcher.new('real') =~ /fake/
end
end
-describe NegativeOperatorMatcher, "< operator" do
- it "raises an ExpectationNotMetError when expected < actual returns true" do
+describe SpecNegativeOperatorMatcher, "< operator" do
+ it "raises an SpecExpectationNotMetError when expected < actual returns true" do
lambda {
- NegativeOperatorMatcher.new(4) < 5
- }.should raise_error(ExpectationNotMetError)
+ SpecNegativeOperatorMatcher.new(4) < 5
+ }.should raise_error(SpecExpectationNotMetError)
end
it "provides a failure message that 'Expected x not to be less than y'" do
- Expectation.should_receive(:fail_with).with("Expected 4\n", "not to be less than 5\n")
- NegativeOperatorMatcher.new(4) < 5
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected 4\n", "not to be less than 5\n")
+ SpecNegativeOperatorMatcher.new(4) < 5
end
it "does not raise an exception when expected < actual returns false" do
- NegativeOperatorMatcher.new(5) < 4
+ SpecNegativeOperatorMatcher.new(5) < 4
end
end
-describe NegativeOperatorMatcher, "<= operator" do
- it "raises an ExpectationNotMetError when expected <= actual returns true" do
+describe SpecNegativeOperatorMatcher, "<= operator" do
+ it "raises an SpecExpectationNotMetError when expected <= actual returns true" do
lambda {
- NegativeOperatorMatcher.new(4) <= 5
- }.should raise_error(ExpectationNotMetError)
+ SpecNegativeOperatorMatcher.new(4) <= 5
+ }.should raise_error(SpecExpectationNotMetError)
lambda {
- NegativeOperatorMatcher.new(5) <= 5
- }.should raise_error(ExpectationNotMetError)
+ SpecNegativeOperatorMatcher.new(5) <= 5
+ }.should raise_error(SpecExpectationNotMetError)
end
it "provides a failure message that 'Expected x not to be less than or equal to y'" do
- Expectation.should_receive(:fail_with).with("Expected 4\n", "not to be less than or equal to 5\n")
- NegativeOperatorMatcher.new(4) <= 5
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected 4\n", "not to be less than or equal to 5\n")
+ SpecNegativeOperatorMatcher.new(4) <= 5
end
it "does not raise an exception when expected <= actual returns false" do
- NegativeOperatorMatcher.new(5) <= 4
+ SpecNegativeOperatorMatcher.new(5) <= 4
end
end
-describe NegativeOperatorMatcher, "> operator" do
- it "raises an ExpectationNotMetError when expected > actual returns true" do
+describe SpecNegativeOperatorMatcher, "> operator" do
+ it "raises an SpecExpectationNotMetError when expected > actual returns true" do
lambda {
- NegativeOperatorMatcher.new(5) > 4
- }.should raise_error(ExpectationNotMetError)
+ SpecNegativeOperatorMatcher.new(5) > 4
+ }.should raise_error(SpecExpectationNotMetError)
end
it "provides a failure message that 'Expected x not to be greater than y'" do
- Expectation.should_receive(:fail_with).with("Expected 5\n", "not to be greater than 4\n")
- NegativeOperatorMatcher.new(5) > 4
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected 5\n", "not to be greater than 4\n")
+ SpecNegativeOperatorMatcher.new(5) > 4
end
it "does not raise an exception when expected > actual returns false" do
- NegativeOperatorMatcher.new(4) > 5
+ SpecNegativeOperatorMatcher.new(4) > 5
end
end
-describe NegativeOperatorMatcher, ">= operator" do
- it "raises an ExpectationNotMetError when expected >= actual returns true" do
+describe SpecNegativeOperatorMatcher, ">= operator" do
+ it "raises an SpecExpectationNotMetError when expected >= actual returns true" do
lambda {
- NegativeOperatorMatcher.new(5) >= 4
- }.should raise_error(ExpectationNotMetError)
+ SpecNegativeOperatorMatcher.new(5) >= 4
+ }.should raise_error(SpecExpectationNotMetError)
lambda {
- NegativeOperatorMatcher.new(5) >= 5
- }.should raise_error(ExpectationNotMetError)
+ SpecNegativeOperatorMatcher.new(5) >= 5
+ }.should raise_error(SpecExpectationNotMetError)
end
it "provides a failure message that 'Expected x not to be greater than or equal to y'" do
- Expectation.should_receive(:fail_with).with("Expected 5\n", "not to be greater than or equal to 4\n")
- NegativeOperatorMatcher.new(5) >= 4
+ SpecExpectation.should_receive(:fail_with).with(
+ "Expected 5\n", "not to be greater than or equal to 4\n")
+ SpecNegativeOperatorMatcher.new(5) >= 4
end
it "does not raise an exception when expected >= actual returns false" do
- NegativeOperatorMatcher.new(4) >= 5
+ SpecNegativeOperatorMatcher.new(4) >= 5
end
end
Modified: MacRuby/branches/experimental/mspec/spec/matchers/be_an_instance_of_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/matchers/be_an_instance_of_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/matchers/be_an_instance_of_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -43,8 +43,8 @@
it "provides a useful negative failure message" do
matcher = BeAnInstanceOfMatcher.new(Numeric)
- matcher.matches?(4.2)
+ matcher.matches?(4.0)
matcher.negative_failure_message.should == [
- "Expected 4.2 (Float)", "not to be an instance of Numeric"]
+ "Expected 4.0 (Float)", "not to be an instance of Numeric"]
end
end
Modified: MacRuby/branches/experimental/mspec/spec/matchers/be_close_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/matchers/be_close_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/matchers/be_close_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -34,8 +34,8 @@
it "provides a useful failure message" do
matcher = BeCloseMatcher.new(5.0, 0.5)
- matcher.matches?(5.51)
- matcher.failure_message.should == ["Expected 5.0", "to be within +/- 0.5 of 5.51"]
+ matcher.matches?(5.5)
+ matcher.failure_message.should == ["Expected 5.0", "to be within +/- 0.5 of 5.5"]
end
it "provides a useful negative failure message" do
Modified: MacRuby/branches/experimental/mspec/spec/matchers/be_kind_of_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/matchers/be_kind_of_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/matchers/be_kind_of_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -24,8 +24,8 @@
it "provides a useful negative failure message" do
matcher = BeKindOfMatcher.new(Numeric)
- matcher.matches?(4.2)
+ matcher.matches?(4.0)
matcher.negative_failure_message.should == [
- "Expected 4.2 (Float)", "not to be kind of Numeric"]
+ "Expected 4.0 (Float)", "not to be kind of Numeric"]
end
end
Modified: MacRuby/branches/experimental/mspec/spec/matchers/equal_utf16_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/matchers/equal_utf16_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/matchers/equal_utf16_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -3,6 +3,12 @@
require 'mspec/matchers/equal_utf16'
describe EqualUtf16Matcher do
+ before :all do
+ # this is a neutral way to covert a NULL character to a
+ # string representation on 1.8 (\000) and 1.9 (\x00)
+ @null = "\0".inspect[1..-2]
+ end
+
it "when given strings, matches when actual == expected" do
EqualUtf16Matcher.new("abcd").matches?("abcd").should == true
end
@@ -36,12 +42,16 @@
it "provides a useful failure message" do
matcher = EqualUtf16Matcher.new("a\0b\0")
matcher.matches?("a\0b\0c\0")
- matcher.failure_message.should == ["Expected \"a\\000b\\000c\\000\"\n", "to equal \"a\\000b\\000\"\n or \"\\000a\\000b\"\n"]
+ matcher.failure_message.should == [
+ "Expected \"a#{@null}b#{@null}c#{@null}\"\n",
+ "to equal \"a#{@null}b#{@null}\"\n or \"#{@null}a#{@null}b\"\n"]
end
it "provides a useful negative failure message" do
matcher = EqualUtf16Matcher.new("a\0b\0")
matcher.matches?("\0a\0b")
- matcher.negative_failure_message.should == ["Expected \"\\000a\\000b\"\n", "not to equal \"a\\000b\\000\"\n nor \"\\000a\\000b\"\n"]
+ matcher.negative_failure_message.should == [
+ "Expected \"#{@null}a#{@null}b\"\n",
+ "not to equal \"a#{@null}b#{@null}\"\n nor \"#{@null}a#{@null}b\"\n"]
end
end
Modified: MacRuby/branches/experimental/mspec/spec/matchers/respond_to_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/matchers/respond_to_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/matchers/respond_to_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -20,12 +20,14 @@
it "provides a useful failure message" do
matcher = RespondToMatcher.new(:non_existent_method)
matcher.matches?('string')
- matcher.failure_message.should == ["Expected \"string\" (String)", "to respond to non_existent_method"]
+ matcher.failure_message.should == [
+ "Expected \"string\" (String)", "to respond to non_existent_method"]
end
it "provides a useful negative failure message" do
matcher = RespondToMatcher.new(:to_i)
- matcher.matches?(4.2)
- matcher.negative_failure_message.should == ["Expected 4.2 (Float)", "not to respond to to_i"]
+ matcher.matches?(4.0)
+ matcher.negative_failure_message.should == [
+ "Expected 4.0 (Float)", "not to respond to to_i"]
end
end
Modified: MacRuby/branches/experimental/mspec/spec/mocks/mock_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/mocks/mock_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/mocks/mock_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -88,7 +88,7 @@
Mock.install_method(@mock, :method_call).with(:c).and_return(2)
@mock.method_call(:a, :b)
@mock.method_call(:c)
- lambda { @mock.method_call(:d) }.should raise_error(ExpectationNotMetError)
+ lambda { @mock.method_call(:d) }.should raise_error(SpecExpectationNotMetError)
end
# This illustrates RSpec's behavior. This spec fails in mock call count verification
@@ -110,7 +110,7 @@
@mock.method_call(:a).should == true
Mock.install_method(@mock, :method_call).with(:a).and_return(false)
@mock.method_call(:a).should == true
- lambda { Mock.verify_count }.should raise_error(ExpectationNotMetError)
+ lambda { Mock.verify_count }.should raise_error(SpecExpectationNotMetError)
end
it "properly sends #respond_to? calls to the aliased respond_to? method when not matching mock expectations" do
@@ -226,25 +226,25 @@
Mock.verify_call @mock, :method_call, 1, 'two', :three
end
- it "raises an ExpectationNotMetError when the mock method does not receive the expected arguments" do
+ it "raises an SpecExpectationNotMetError when the mock method does not receive the expected arguments" do
@proxy.with(4, 2)
lambda {
Mock.verify_call @mock, :method_call, 42
- }.should raise_error(ExpectationNotMetError)
+ }.should raise_error(SpecExpectationNotMetError)
end
- it "raises an ExpectationNotMetError when the mock method is called with arguments but expects none" do
+ it "raises an SpecExpectationNotMetError when the mock method is called with arguments but expects none" do
lambda {
@proxy.with(:no_args)
Mock.verify_call @mock, :method_call, "hello"
- }.should raise_error(ExpectationNotMetError)
+ }.should raise_error(SpecExpectationNotMetError)
end
- it "raises an ExpectationNotMetError when the mock method is called with no arguments but expects some" do
+ it "raises an SpecExpectationNotMetError when the mock method is called with no arguments but expects some" do
@proxy.with("hello", "beautiful", "world")
lambda {
Mock.verify_call @mock, :method_call
- }.should raise_error(ExpectationNotMetError)
+ }.should raise_error(SpecExpectationNotMetError)
end
it "does not raise an exception when the mock method is called with arguments and is expecting :any_args" do
@@ -288,21 +288,21 @@
@proxy.and_yield(1, 2, 3)
lambda {
Mock.verify_call(@mock, :method_call)
- }.should raise_error(ExpectationNotMetError)
+ }.should raise_error(SpecExpectationNotMetError)
end
it "raises an expection when it is expected to yield more arguments than the block can take" do
@proxy.and_yield(1, 2, 3)
lambda {
Mock.verify_call(@mock, :method_call) {|a, b|}
- }.should raise_error(ExpectationNotMetError)
+ }.should raise_error(SpecExpectationNotMetError)
end
it "does not raise an expection when it is expected to yield to a block that can take any number of arguments" do
@proxy.and_yield(1, 2, 3)
lambda {
Mock.verify_call(@mock, :method_call) {|*a|}
- }.should_not raise_error(ExpectationNotMetError)
+ }.should_not raise_error(SpecExpectationNotMetError)
end
end
@@ -326,10 +326,10 @@
Mock.verify_count
end
- it "raises an ExpectationNotMetError when the mock receives less than at least the expected number of calls" do
+ it "raises an SpecExpectationNotMetError when the mock receives less than at least the expected number of calls" do
@proxy.at_least(2)
@mock.method_call
- lambda { Mock.verify_count }.should raise_error(ExpectationNotMetError)
+ lambda { Mock.verify_count }.should raise_error(SpecExpectationNotMetError)
end
it "does not raise an exception when the mock receives at most the expected number of calls" do
@@ -339,12 +339,12 @@
Mock.verify_count
end
- it "raises an ExpectationNotMetError when the mock receives more than at most the expected number of calls" do
+ it "raises an SpecExpectationNotMetError when the mock receives more than at most the expected number of calls" do
@proxy.at_most(2)
@mock.method_call
@mock.method_call
@mock.method_call
- lambda { Mock.verify_count }.should raise_error(ExpectationNotMetError)
+ lambda { Mock.verify_count }.should raise_error(SpecExpectationNotMetError)
end
it "does not raise an exception when the mock receives exactly the expected number of calls" do
@@ -354,18 +354,18 @@
Mock.verify_count
end
- it "raises an ExpectationNotMetError when the mock receives less than exactly the expected number of calls" do
+ it "raises an SpecExpectationNotMetError when the mock receives less than exactly the expected number of calls" do
@proxy.exactly(2)
@mock.method_call
- lambda { Mock.verify_count }.should raise_error(ExpectationNotMetError)
+ lambda { Mock.verify_count }.should raise_error(SpecExpectationNotMetError)
end
- it "raises an ExpectationNotMetError when the mock receives more than exactly the expected number of calls" do
+ it "raises an SpecExpectationNotMetError when the mock receives more than exactly the expected number of calls" do
@proxy.exactly(2)
@mock.method_call
@mock.method_call
@mock.method_call
- lambda { Mock.verify_count }.should raise_error(ExpectationNotMetError)
+ lambda { Mock.verify_count }.should raise_error(SpecExpectationNotMetError)
end
end
@@ -425,11 +425,12 @@
it "removes the replaced method if the mock method overrides an existing method" do
def @mock.already_here() :hey end
@mock.should respond_to(:already_here)
+ replaced_name = Mock.replaced_name(@mock, :already_here)
Mock.install_method @mock, :already_here
- @mock.should respond_to(Mock.replaced_name(@mock, :already_here))
+ @mock.should respond_to(replaced_name)
Mock.cleanup
- @mock.should_not respond_to(Mock.replaced_name(@mock, :already_here))
+ @mock.should_not respond_to(replaced_name)
@mock.should respond_to(:already_here)
@mock.already_here.should == :hey
end
Modified: MacRuby/branches/experimental/mspec/spec/runner/actions/tally_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/runner/actions/tally_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/runner/actions/tally_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -274,7 +274,7 @@
end
it "increments counts returned by Tally#failures" do
- exc = ExceptionState.new nil, nil, ExpectationNotMetError.new("Failed!")
+ exc = ExceptionState.new nil, nil, SpecExpectationNotMetError.new("Failed!")
@tally.exception exc
@tally.counter.examples.should == 0
@tally.counter.expectations.should == 0
@@ -310,7 +310,7 @@
@tally.example @state, nil
@tally.expectation @state
@tally.expectation @state
- exc = ExceptionState.new nil, nil, ExpectationNotMetError.new("Failed!")
+ exc = ExceptionState.new nil, nil, SpecExpectationNotMetError.new("Failed!")
@tally.exception exc
@tally.format.should == "1 file, 1 example, 2 expectations, 1 failure, 0 errors"
end
Modified: MacRuby/branches/experimental/mspec/spec/runner/actions/timer_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/runner/actions/timer_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/runner/actions/timer_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -19,17 +19,17 @@
end
it "responds to #elapsed by returning the difference between stop and start" do
- Time.stub!(:now).and_return(Time.parse('10/18/2007 5:43:18'))
+ Time.stub!(:now).and_return(Time.parse('Mon Mar 30 14:05:19 -0700 2009'))
@timer.start
- Time.stub!(:now).and_return(Time.parse('10/18/2007 5:43:51'))
+ Time.stub!(:now).and_return(Time.parse('Mon Mar 30 14:05:52 -0700 2009'))
@timer.finish
@timer.elapsed.should == 33
end
it "responds to #format by returning a readable string of elapsed time" do
- Time.stub!(:now).and_return(Time.parse('10/18/2007 5:43:18'))
+ Time.stub!(:now).and_return(Time.parse('Mon Mar 30 14:05:19 -0700 2009'))
@timer.start
- Time.stub!(:now).and_return(Time.parse('10/18/2007 5:43:51'))
+ Time.stub!(:now).and_return(Time.parse('Mon Mar 30 14:05:52 -0700 2009'))
@timer.finish
@timer.format.should == "Finished in 33.000000 seconds"
end
Modified: MacRuby/branches/experimental/mspec/spec/runner/context_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/runner/context_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/runner/context_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -506,7 +506,7 @@
action = mock("action")
def action.exception(exc)
- ScratchPad.record :exception if exc.exception.is_a? ExpectationNotFoundError
+ ScratchPad.record :exception if exc.exception.is_a? SpecExpectationNotFoundError
end
MSpec.register :exception, action
@@ -518,19 +518,19 @@
MSpec.store :exception, nil
end
- it "raises an ExpectationNotFoundError if an #it block does not contain an expectation" do
+ it "raises an SpecExpectationNotFoundError if an #it block does not contain an expectation" do
@state.it("it") { }
@state.process
ScratchPad.recorded.should == :exception
end
- it "does not raise an ExpectationNotFoundError if an #it block does contain an expectation" do
+ it "does not raise an SpecExpectationNotFoundError if an #it block does contain an expectation" do
@state.it("it") { MSpec.expectation }
@state.process
ScratchPad.recorded.should be_nil
end
- it "does not raise an ExpectationNotFoundError if the #it block causes a failure" do
+ it "does not raise an SpecExpectationNotFoundError if the #it block causes a failure" do
@state.it("it") { raise Exception, "Failed!" }
@state.process
ScratchPad.recorded.should be_nil
Modified: MacRuby/branches/experimental/mspec/spec/runner/exception_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/runner/exception_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/runner/exception_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -69,17 +69,17 @@
@state = ExampleState.new ContextState.new("C#m"), "works"
end
- it "returns true if the exception is an ExpectationNotMetError" do
- exc = ExceptionState.new @state, "", ExpectationNotMetError.new("Fail!")
+ it "returns true if the exception is an SpecExpectationNotMetError" do
+ exc = ExceptionState.new @state, "", SpecExpectationNotMetError.new("Fail!")
exc.failure?.should be_true
end
- it "returns true if the exception is an ExpectationNotFoundError" do
- exc = ExceptionState.new @state, "", ExpectationNotFoundError.new("Fail!")
+ it "returns true if the exception is an SpecExpectationNotFoundError" do
+ exc = ExceptionState.new @state, "", SpecExpectationNotFoundError.new("Fail!")
exc.failure?.should be_true
end
- it "returns false if the exception is not an ExpectationNotMetError or an ExpectationNotFoundError" do
+ it "returns false if the exception is not an SpecExpectationNotMetError or an SpecExpectationNotFoundError" do
exc = ExceptionState.new @state, "", Exception.new("Fail!")
exc.failure?.should be_false
end
@@ -91,18 +91,18 @@
exc.message.should == "<No message>"
end
- it "returns the message without exception class when the exception is an ExpectationNotMetError" do
- exc = ExceptionState.new @state, "", ExpectationNotMetError.new("Fail!")
+ it "returns the message without exception class when the exception is an SpecExpectationNotMetError" do
+ exc = ExceptionState.new @state, "", SpecExpectationNotMetError.new("Fail!")
exc.message.should == "Fail!"
end
- it "returns ExpectationNotFoundError#message when the exception is an ExpectationNotFoundError" do
- e = ExpectationNotFoundError.new
+ it "returns SpecExpectationNotFoundError#message when the exception is an SpecExpectationNotFoundError" do
+ e = SpecExpectationNotFoundError.new
exc = ExceptionState.new @state, "", e
exc.message.should == e.message
end
- it "returns the message with exception class when the exception is not an ExpectationNotMetError or an ExpectationNotFoundError" do
+ it "returns the message with exception class when the exception is not an SpecExpectationNotMetError or an SpecExpectationNotFoundError" do
exc = ExceptionState.new @state, "", Exception.new("Fail!")
exc.message.should == "Exception: Fail!"
end
Modified: MacRuby/branches/experimental/mspec/spec/runner/formatters/dotted_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/runner/formatters/dotted_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/runner/formatters/dotted_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -78,7 +78,7 @@
describe DottedFormatter, "#exception" do
before :each do
@formatter = DottedFormatter.new
- @failure = ExceptionState.new nil, nil, ExpectationNotMetError.new("failed")
+ @failure = ExceptionState.new nil, nil, SpecExpectationNotMetError.new("failed")
@error = ExceptionState.new nil, nil, MSpecExampleError.new("boom!")
end
@@ -107,7 +107,7 @@
describe DottedFormatter, "#exception?" do
before :each do
@formatter = DottedFormatter.new
- @failure = ExceptionState.new nil, nil, ExpectationNotMetError.new("failed")
+ @failure = ExceptionState.new nil, nil, SpecExpectationNotMetError.new("failed")
@error = ExceptionState.new nil, nil, MSpecExampleError.new("boom!")
end
@@ -137,7 +137,7 @@
describe DottedFormatter, "#failure?" do
before :each do
@formatter = DottedFormatter.new
- @failure = ExceptionState.new nil, nil, ExpectationNotMetError.new("failed")
+ @failure = ExceptionState.new nil, nil, SpecExpectationNotMetError.new("failed")
@error = ExceptionState.new nil, nil, MSpecExampleError.new("boom!")
end
@@ -162,7 +162,7 @@
before :each do
@state = ExampleState.new ContextState.new("describe"), "it"
@formatter = DottedFormatter.new
- @formatter.exception ExceptionState.new(nil, nil, ExpectationNotMetError.new("Failed!"))
+ @formatter.exception ExceptionState.new(nil, nil, SpecExpectationNotMetError.new("Failed!"))
end
it "resets the #failure? flag to false" do
@@ -195,7 +195,7 @@
end
it "prints an 'F' if there was an expectation failure" do
- exc = ExpectationNotMetError.new "failed"
+ exc = SpecExpectationNotMetError.new "failed"
@formatter.exception ExceptionState.new(@state, nil, exc)
@formatter.after(@state)
@out.should == "F"
@@ -209,7 +209,7 @@
end
it "prints an 'E' if there are mixed exceptions and exepctation failures" do
- exc = ExpectationNotMetError.new "failed"
+ exc = SpecExpectationNotMetError.new "failed"
@formatter.exception ExceptionState.new(@state, nil, exc)
exc = MSpecExampleError.new("boom!")
@formatter.exception ExceptionState.new(@state, nil, exc)
Modified: MacRuby/branches/experimental/mspec/spec/runner/formatters/file_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/runner/formatters/file_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/runner/formatters/file_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -27,7 +27,7 @@
before :each do
@state = ExampleState.new ContextState.new("describe"), "it"
@formatter = FileFormatter.new
- @formatter.exception ExceptionState.new(nil, nil, ExpectationNotMetError.new("Failed!"))
+ @formatter.exception ExceptionState.new(nil, nil, SpecExpectationNotMetError.new("Failed!"))
end
it "resets the #failure? flag to false" do
@@ -60,7 +60,7 @@
end
it "prints an 'F' if there was an expectation failure" do
- exc = ExpectationNotMetError.new "failed"
+ exc = SpecExpectationNotMetError.new "failed"
@formatter.exception ExceptionState.new(@state, nil, exc)
@formatter.unload(@state)
@out.should == "F"
@@ -74,7 +74,7 @@
end
it "prints an 'E' if there are mixed exceptions and exepctation failures" do
- exc = ExpectationNotMetError.new "failed"
+ exc = SpecExpectationNotMetError.new "failed"
@formatter.exception ExceptionState.new(@state, nil, exc)
exc = MSpecExampleError.new("boom!")
@formatter.exception ExceptionState.new(@state, nil, exc)
Modified: MacRuby/branches/experimental/mspec/spec/runner/formatters/html_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/runner/formatters/html_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/runner/formatters/html_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -104,11 +104,11 @@
end
it "prints the #it string once for each exception raised" do
- exc = ExceptionState.new @state, nil, ExpectationNotMetError.new("disappointing")
+ exc = ExceptionState.new @state, nil, SpecExpectationNotMetError.new("disappointing")
@formatter.exception exc
exc = ExceptionState.new @state, nil, MSpecExampleError.new("painful")
@formatter.exception exc
- @out.should ==
+ @out.should ==
%[<li class="fail">- it (<a href="#details-1">FAILED - 1</a>)</li>
<li class="fail">- it (<a href="#details-2">ERROR - 2</a>)</li>
]
@@ -133,7 +133,7 @@
end
it "does not print any output if an exception is raised" do
- exc = ExceptionState.new @state, nil, ExpectationNotMetError.new("disappointing")
+ exc = ExceptionState.new @state, nil, SpecExpectationNotMetError.new("disappointing")
@formatter.exception exc
out = @out.dup
@formatter.after @state
Modified: MacRuby/branches/experimental/mspec/spec/runner/formatters/method_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/runner/formatters/method_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/runner/formatters/method_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -118,7 +118,7 @@
state = ExampleState.new ContextState.new("Some#method"), "it"
@formatter.before state
- exc = ExpectationNotMetError.new "failed"
+ exc = SpecExpectationNotMetError.new "failed"
@formatter.exception ExceptionState.new(@state, nil, exc)
@formatter.exception ExceptionState.new(@state, nil, exc)
@@ -152,7 +152,7 @@
@formatter.tally.counter.failures = 2
@formatter.tally.counter.errors = 1
- exc = ExpectationNotMetError.new "failed"
+ exc = SpecExpectationNotMetError.new "failed"
@formatter.exception ExceptionState.new(@state, nil, exc)
@formatter.exception ExceptionState.new(@state, nil, exc)
Modified: MacRuby/branches/experimental/mspec/spec/runner/formatters/specdoc_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/runner/formatters/specdoc_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/runner/formatters/specdoc_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -47,7 +47,7 @@
end
it "resets the #exception? flag" do
- exc = ExceptionState.new @state, nil, ExpectationNotMetError.new("disappointing")
+ exc = ExceptionState.new @state, nil, SpecExpectationNotMetError.new("disappointing")
@formatter.exception exc
@formatter.exception?.should be_true
@formatter.before @state
@@ -67,20 +67,20 @@
$stdout = STDOUT
end
- it "prints 'ERROR' if an exception is not an ExpectationNotMetError" do
+ it "prints 'ERROR' if an exception is not an SpecExpectationNotMetError" do
exc = ExceptionState.new @state, nil, MSpecExampleError.new("painful")
@formatter.exception exc
@out.should == " (ERROR - 1)"
end
- it "prints 'FAILED' if an exception is an ExpectationNotMetError" do
- exc = ExceptionState.new @state, nil, ExpectationNotMetError.new("disappointing")
+ it "prints 'FAILED' if an exception is an SpecExpectationNotMetError" do
+ exc = ExceptionState.new @state, nil, SpecExpectationNotMetError.new("disappointing")
@formatter.exception exc
@out.should == " (FAILED - 1)"
end
it "prints the #it string if an exception has already been raised" do
- exc = ExceptionState.new @state, nil, ExpectationNotMetError.new("disappointing")
+ exc = ExceptionState.new @state, nil, SpecExpectationNotMetError.new("disappointing")
@formatter.exception exc
exc = ExceptionState.new @state, nil, MSpecExampleError.new("painful")
@formatter.exception exc
Modified: MacRuby/branches/experimental/mspec/spec/runner/formatters/summary_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/runner/formatters/summary_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/runner/formatters/summary_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -16,7 +16,7 @@
end
it "does not print anything" do
- exc = ExceptionState.new @state, nil, ExpectationNotMetError.new("disappointing")
+ exc = ExceptionState.new @state, nil, SpecExpectationNotMetError.new("disappointing")
@formatter.exception exc
exc = ExceptionState.new @state, nil, MSpecExampleError.new("painful")
@formatter.exception exc
Modified: MacRuby/branches/experimental/mspec/spec/utils/options_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/utils/options_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/utils/options_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -236,48 +236,49 @@
describe MSpecOptions, "#parse" do
before :each do
@opt = MSpecOptions.new
- @prc = lambda { |o| ScratchPad.record [:parsed, o] }
+ @prc = lambda { ScratchPad.record :parsed }
+ @arg_prc = lambda { |o| ScratchPad.record [:parsed, o] }
ScratchPad.clear
end
it "parses a short option" do
@opt.on "-a", "desc", &@prc
@opt.parse ["-a"]
- ScratchPad.recorded.should == [:parsed, nil]
+ ScratchPad.recorded.should == :parsed
end
it "parse a long option" do
@opt.on "--abdc", "desc", &@prc
@opt.parse ["--abdc"]
- ScratchPad.recorded.should == [:parsed, nil]
+ ScratchPad.recorded.should == :parsed
end
it "parses a short option group" do
- @opt.on "-a", "ARG", "desc", &@prc
+ @opt.on "-a", "ARG", "desc", &@arg_prc
@opt.parse ["-a", "ARG"]
ScratchPad.recorded.should == [:parsed, "ARG"]
end
it "parses a short option with an argument" do
- @opt.on "-a", "ARG", "desc", &@prc
+ @opt.on "-a", "ARG", "desc", &@arg_prc
@opt.parse ["-a", "ARG"]
ScratchPad.recorded.should == [:parsed, "ARG"]
end
it "parses a short option with connected argument" do
- @opt.on "-a", "ARG", "desc", &@prc
+ @opt.on "-a", "ARG", "desc", &@arg_prc
@opt.parse ["-aARG"]
ScratchPad.recorded.should == [:parsed, "ARG"]
end
it "parses a long option with an argument" do
- @opt.on "--abdc", "ARG", "desc", &@prc
+ @opt.on "--abdc", "ARG", "desc", &@arg_prc
@opt.parse ["--abdc", "ARG"]
ScratchPad.recorded.should == [:parsed, "ARG"]
end
it "parses a long option with an '=' argument" do
- @opt.on "--abdc", "ARG", "desc", &@prc
+ @opt.on "--abdc", "ARG", "desc", &@arg_prc
@opt.parse ["--abdc=ARG"]
ScratchPad.recorded.should == [:parsed, "ARG"]
end
@@ -300,7 +301,7 @@
end
it "returns the unprocessed entries" do
- @opt.on "-a", "ARG", "desc", &@prc
+ @opt.on "-a", "ARG", "desc", &@arg_prc
@opt.parse(["abdc", "-a", "ilny"]).should == ["abdc"]
end
Modified: MacRuby/branches/experimental/mspec/spec/utils/script_spec.rb
===================================================================
--- MacRuby/branches/experimental/mspec/spec/utils/script_spec.rb 2009-04-04 18:57:08 UTC (rev 1347)
+++ MacRuby/branches/experimental/mspec/spec/utils/script_spec.rb 2009-04-04 22:37:55 UTC (rev 1348)
@@ -356,9 +356,9 @@
end
it "returns the pattern in an array if it is a file" do
- File.should_receive(:expand_path).with("file").and_return("file")
- File.should_receive(:file?).with("file").and_return(true)
- @script.entries("file").should == ["file"]
+ File.should_receive(:expand_path).with("file").and_return("file/expanded")
+ File.should_receive(:file?).with("file/expanded").and_return(true)
+ @script.entries("file").should == ["file/expanded"]
end
it "returns Dir['pattern/**/*_spec.rb'] if pattern is a directory" do
@@ -434,10 +434,10 @@
it "looks up items with leading ':' in the config object" do
@script.should_receive(:entries).and_return(["file1"], ["file2"])
- @script.files(":files").should == ["file1", "file2"]
+ @script.files([":files"]).should == ["file1", "file2"]
end
it "returns an empty list if the config key is not set" do
- @script.files(":all_files").should == []
+ @script.files([":all_files"]).should == []
end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090404/40ad8b9c/attachment-0001.html>
More information about the macruby-changes
mailing list