mirror of
https://github.com/edgecase/ruby_koans.git
synced 2026-04-21 01:03:20 -04:00
Updated the koans directory.
This commit is contained in:
@@ -7,6 +7,6 @@ require 'rake/testtask'
|
|||||||
task :default => :test
|
task :default => :test
|
||||||
|
|
||||||
task :test do
|
task :test do
|
||||||
ruby '-I.', 'path_to_enlightenment.rb'
|
ruby 'path_to_enlightenment.rb'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,18 @@ class AboutMessagePassing < EdgeCase::Koan
|
|||||||
#
|
#
|
||||||
# If the method :method_missing causes the NoMethodError, then
|
# If the method :method_missing causes the NoMethodError, then
|
||||||
# what would happen if we redefine method_missing?
|
# what would happen if we redefine method_missing?
|
||||||
|
#
|
||||||
|
# NOTE:
|
||||||
|
#
|
||||||
|
# In Ruby 1.8 the method_missing method is public and can be
|
||||||
|
# called as shown above. However, in Ruby 1.9 the method_missing
|
||||||
|
# method is private. We explicitly made it public in the testing
|
||||||
|
# framework so this example works in both versions of Ruby. Just
|
||||||
|
# keep in mind you can't call method_missing like that in Ruby
|
||||||
|
# 1.9. normally.
|
||||||
|
#
|
||||||
|
# Thanks. We now return you to your regularly schedule Ruby
|
||||||
|
# Koans.
|
||||||
end
|
end
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|||||||
@@ -36,13 +36,27 @@ class Object
|
|||||||
self.send(method)
|
self.send(method)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
in_ruby_version("1.9") do
|
||||||
|
public :method_missing
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module EdgeCase
|
module EdgeCase
|
||||||
class Sensei
|
class Sensei
|
||||||
attr_reader :failure, :failed_test
|
attr_reader :failure, :failed_test
|
||||||
|
|
||||||
AssertionError = Test::Unit::AssertionFailedError
|
in_ruby_version("1.8") do
|
||||||
|
AssertionError = Test::Unit::AssertionFailedError
|
||||||
|
end
|
||||||
|
|
||||||
|
in_ruby_version("1.9") do
|
||||||
|
if defined?(MiniTest)
|
||||||
|
AssertionError = MiniTest::Assertion
|
||||||
|
else
|
||||||
|
AssertionError = Test::Unit::AssertionFailedError
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@pass_count = 0
|
@pass_count = 0
|
||||||
@@ -165,12 +179,12 @@ module EdgeCase
|
|||||||
test.setup
|
test.setup
|
||||||
begin
|
begin
|
||||||
test.send(method)
|
test.send(method)
|
||||||
rescue StandardError => ex
|
rescue StandardError, EdgeCase::Sensei::AssertionError => ex
|
||||||
test.failed(ex)
|
test.failed(ex)
|
||||||
ensure
|
ensure
|
||||||
begin
|
begin
|
||||||
test.teardown
|
test.teardown
|
||||||
rescue StandardError => ex
|
rescue StandardError, EdgeCase::Sensei::AssertionError => ex
|
||||||
test.failed(ex) if test.passed?
|
test.failed(ex) if test.passed?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
# The path to Ruby Enlightenment starts with the following:
|
# The path to Ruby Enlightenment starts with the following:
|
||||||
|
|
||||||
|
$LOAD_PATH << File.dirname(__FILE__)
|
||||||
|
|
||||||
require 'about_asserts'
|
require 'about_asserts'
|
||||||
require 'about_nil'
|
require 'about_nil'
|
||||||
require 'about_arrays'
|
require 'about_arrays'
|
||||||
|
|||||||
Reference in New Issue
Block a user