-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
87 lines (72 loc) · 1.96 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "--format progress"
t.rcov = false
end
task :default => :features do
puts
puts
puts "Features passed OK. Now what does your flog look like? (Hint: low is good)"
puts
system("flog #{File.dirname(__FILE__)}/lib/*.rb")
end
task :start_dojo do
end
task :dojo do
def run_cukes
system("cucumber features")
unless $?.exitstatus == 0
puts
puts "FAIL! Better fix that. Hit [ENTER] to run the tests again when you're ready..."
STDIN.gets
end
end
def init(name)
system("git checkout iteration-1")
exit $?.exitstatus unless ($?.exitstatus == 0)
system("git branch -D #{name}")
system("git checkout -b #{name}")
end
def get_name
print "Enter your name: "
STDIN.gets
end
def success?
$?.exitstatus == 0
end
init(get_name)
iteration = 1
until iteration > 5
run_cukes
if success?
if iteration <= 5
system("git add .")
system(%Q{git commit -m "iteration #{iteration} tests passing."})
puts
puts
puts "WIN!"
puts "Perhaps you would care for a spot of refactoring at this point?"
go_next = false
until go_next
message = "Press [ENTER] to run the tests again (with refactoring tips)"
message << ", [SPACE ENTER] to move to the next iteration" if success?
puts message
go_next = (STDIN.gets == " \n")
system("rake")
go_next = go_next and success?
end
system(%Q{git commit -m "iteration #{iteration} refactored."})
# move to next iteration
iteration += 1
system("git merge iteration-#{iteration}")
else
puts "EPIC WIN! Now to play the refactoring game..."
until false
system("rake")
puts "Not bad. Can you do any better? (Hit a key to re-run the flog)"
STDIN.gets
end
end
end
end
end