Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding assertion replacement in a different format

  • Loading branch information...
commit ba9ff94a270c20b916f5bf1d52da342b19278f96 1 parent 65dceed
@sathish316 sathish316 authored
View
113 Rakefile
@@ -2,21 +2,12 @@
# -*- ruby -*-
require 'rake/clean'
-require 'rake/rdoctask'
SRC_DIR = 'src'
-PROB_DIR = 'koans'
-DIST_DIR = 'dist'
+KOAN_DIR = 'koans'
SRC_FILES = FileList["#{SRC_DIR}/*"]
-KOAN_FILES = SRC_FILES.pathmap("#{PROB_DIR}/%f")
-
-today = Time.now.strftime("%Y-%m-%d")
-TAR_FILE = "#{DIST_DIR}/rubykoans-#{today}.tgz"
-ZIP_FILE = "#{DIST_DIR}/rubykoans-#{today}.zip"
-
-CLEAN.include("**/*.rbc")
-CLOBBER.include(DIST_DIR)
+KOAN_FILES = SRC_FILES.pathmap("#{KOAN_DIR}/%f")
module Koans
# Remove solution info from source
@@ -30,6 +21,9 @@ module Koans
line = line.gsub(/\b_n_\([^\)]+\)/, "_n_")
line = line.gsub(%r(/\#\{__\}/), "/__/")
line = line.gsub(/\s*#\s*__\s*$/, '')
+ line = line.gsub(/assert_equal [\:"']?([\w\s\!']+)['"]?,/, "assert_equal __,")
+ line = line.gsub(/assert_match \/(.*?)\//, "assert_match /__/")
+ line = line.gsub(/assert_raises(\w+)\//, "assert_raises(___)")
line
end
@@ -58,27 +52,6 @@ module Koans
end
end
-module RubyImpls
- # Calculate the list of relevant Ruby implementations.
- def self.find_ruby_impls
- rubys = `rvm list`.gsub(/=>/,'').split(/\n/).sort
- expected.map { |impl|
- last = rubys.grep(Regexp.new(Regexp.quote(impl))).last
- last ? last.split.first : nil
- }.compact
- end
-
- # Return a (cached) list of relevant Ruby implementations.
- def self.list
- @list ||= find_ruby_impls
- end
-
- # List of expected ruby implementations.
- def self.expected
- %w(ruby-1.8.6 ruby-1.8.7 ruby-1.9.2 jruby ree)
- end
-end
-
task :default => :walk_the_path
task :walk_the_path do
@@ -86,81 +59,27 @@ task :walk_the_path do
ruby 'path_to_enlightenment.rb'
end
-Rake::RDocTask.new do |rd|
- rd.main = "README.rdoc"
- rd.rdoc_files.include("README.rdoc", "koans/*.rb")
-end
-
-directory DIST_DIR
-directory PROB_DIR
-
-file ZIP_FILE => KOAN_FILES + [DIST_DIR] do
- sh "zip #{ZIP_FILE} #{PROB_DIR}/*"
-end
-
-file TAR_FILE => KOAN_FILES + [DIST_DIR] do
- sh "tar zcvf #{TAR_FILE} #{PROB_DIR}"
+task :run do
+ puts 'koans'
+ Dir.chdir("src") do
+ puts "in #{Dir.pwd}"
+ sh "ruby path_to_enlightenment.rb"
+ end
end
-desc "Create packaged files for distribution"
-task :package => [TAR_FILE, ZIP_FILE]
-
-desc "Upload the package files to the web server"
-task :upload => [TAR_FILE, ZIP_FILE] do
- sh "scp #{TAR_FILE} linode:sites/onestepback.org/download"
- sh "scp #{ZIP_FILE} linode:sites/onestepback.org/download"
-end
+directory KOAN_DIR
desc "Generate the Koans from the source files from scratch."
task :regen => [:clobber_koans, :gen]
desc "Generate the Koans from the changed source files."
-task :gen => KOAN_FILES + [PROB_DIR + "/README.rdoc"]
+task :gen => KOAN_FILES
task :clobber_koans do
- rm_r PROB_DIR
-end
-
-file PROB_DIR + "/README.rdoc" => "README.rdoc" do |t|
- cp "README.rdoc", t.name
+ rm_r KOAN_DIR
end
SRC_FILES.each do |koan_src|
- file koan_src.pathmap("#{PROB_DIR}/%f") => [PROB_DIR, koan_src] do |t|
+ file koan_src.pathmap("#{KOAN_DIR}/%f") => [KOAN_DIR, koan_src] do |t|
Koans.make_koan_file koan_src, t.name
end
-end
-
-task :run do
- puts 'koans'
- Dir.chdir("src") do
- puts "in #{Dir.pwd}"
- sh "ruby path_to_enlightenment.rb"
- end
-end
-
-
-desc "Pre-checkin tests (=> run_all)"
-task :cruise => :run_all
-
-desc "Run the completed koans againts a list of relevant Ruby Implementations"
-task :run_all do
- results = []
- RubyImpls.list.each do |impl|
- puts "=" * 40
- puts "On Ruby #{impl}"
- sh "rvm #{impl} rake run"
- results << [impl, "RAN"]
- puts
- end
- puts "=" * 40
- puts "Summary:"
- puts
- results.each do |impl, res|
- puts "#{impl} => RAN"
- end
- puts
- RubyImpls.expected.each do |requested_impl|
- impl_pattern = Regexp.new(Regexp.quote(requested_impl))
- puts "No Results for #{requested_impl}" unless results.detect { |x| x.first =~ impl_pattern }
- end
-end
+end
View
2  src/about_class_as_constant.rb
@@ -48,6 +48,6 @@ def test_self_inside_class_is_class_itself
def test_class_is_an_object_of_type_class_and_can_be_created_dynamically
cls = Class.new
- assert_match /Class/, cls.to_s
+ assert_match /Class/, cls.to_s
end
end
View
4 src/about_metaclass.rb
@@ -106,7 +106,7 @@ def red_truck.honk
end
assert_equal "Honk!Honk!", red_truck.honk
- assert_raises NoMethodError do
+ assert_raises(NoMethodError) do
blue_truck.honk
end
end
@@ -162,7 +162,7 @@ def metaclass.honk_honk
assert_equal "Honk", @truck.honk
assert_equal "Honk Honk", @truck.meta_eval { honk_honk }
- assert_raises NoMethodError do
+ assert_raises(NoMethodError) do
@truck.honk_honk
end
end
View
1  src/about_method_missing.rb
@@ -3,6 +3,5 @@
class AboutMethodMissing < EdgeCase::Koan
def test_foo
-
end
end
View
6 src/edgecase.rb
@@ -247,13 +247,13 @@ def artistic_end_screen
,:::::::::::, ::::::::::::,
:::::::::::, ,::::::::::::
::::::::::::: ,::::::::::::
-:::::::::::: Ruby Koans ::::::::::::,
+:::::::::::: Ruby Metaprogramming Koans ::::::::::::,
::::::::::::#{ ruby_version },::::::::::::,
:::::::::::, , ::::::::::::
-,:::::::::::::, brought to you by ,,::::::::::::,
+,:::::::::::::, ,,::::::::::::,
:::::::::::::: ,::::::::::::
::::::::::::::, ,:::::::::::::
- ::::::::::::, EdgeCase Software Artisans , ::::::::::::
+ ::::::::::::, , ::::::::::::
:,::::::::: :::: :::::::::::::
,::::::::::: ,: ,,:::::::::::::,
:::::::::::: ,::::::::::::::,
Please sign in to comment.
Something went wrong with that request. Please try again.