kata 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/kata +22 -0
- data/lib/kata.rb +2 -66
- data/lib/kata/base.rb +78 -0
- data/lib/kata/setup.rb +104 -0
- data/spec/kata_base_spec.rb +144 -0
- data/spec/kata_setup_spec.rb +30 -0
- data/spec/support/matchers/kata.rb +9 -1
- metadata +19 -36
- data/Rakefile +0 -2
- data/bin/autospec +0 -16
- data/bin/autotest +0 -16
- data/bin/htmldiff +0 -16
- data/bin/ldiff +0 -16
- data/bin/minitar +0 -16
- data/bin/multigem +0 -16
- data/bin/multiruby +0 -16
- data/bin/multiruby_setup +0 -16
- data/bin/rdebug +0 -16
- data/bin/rspec +0 -16
- data/bin/unit_diff +0 -16
- data/bin/zentest +0 -16
- data/spec/kata_spec.rb +0 -139
data/bin/kata
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'kata'
|
2
|
+
|
3
|
+
usage = 'kata [-s|--setup] file'
|
4
|
+
|
5
|
+
if %w{-s --setup}.include? ARGV[0]
|
6
|
+
raise ArgumentError unless ARGV[1] && File.exists?(ARGV[1])
|
7
|
+
|
8
|
+
name = nil
|
9
|
+
|
10
|
+
File.open(ARGV[1]).each do |line|
|
11
|
+
if line.match /^kata *\"([^\"]*)\" *do$/
|
12
|
+
name = $1
|
13
|
+
break
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
setup = Kata::Setup.new name
|
18
|
+
setup.build_tree
|
19
|
+
setup.create_repo
|
20
|
+
else
|
21
|
+
load ARGV[0]
|
22
|
+
end
|
data/lib/kata.rb
CHANGED
@@ -1,66 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
def kata txt, lib = nil
|
5
|
-
puts txt
|
6
|
-
yield if block_given?
|
7
|
-
complete
|
8
|
-
end
|
9
|
-
|
10
|
-
def requirement txt
|
11
|
-
puts indent + txt
|
12
|
-
|
13
|
-
start = Time.now
|
14
|
-
|
15
|
-
yield if block_given?
|
16
|
-
|
17
|
-
rsp = ask "\ncontinue (Y|n): ", 'y'
|
18
|
-
|
19
|
-
puts
|
20
|
-
|
21
|
-
elapsed = Time.now - start
|
22
|
-
@@times << {:title => txt, :time => elapsed}
|
23
|
-
|
24
|
-
complete false if rsp.downcase == 'n'
|
25
|
-
end
|
26
|
-
|
27
|
-
def example txt
|
28
|
-
puts indent + '- ' + txt
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def ask prompt, default
|
34
|
-
print prompt
|
35
|
-
$stdin.gets.chomp || default
|
36
|
-
end
|
37
|
-
|
38
|
-
def complete status = true
|
39
|
-
if @@times.size > 0
|
40
|
-
title = status ? 'Congratulations!' : 'You completed the following:'
|
41
|
-
|
42
|
-
formatter = lambda do |sec|
|
43
|
-
use = sec.round
|
44
|
-
[use/3600, use/60 % 60, use % 60].map {|v| v.to_s.rjust(2,'0')}.join(':')
|
45
|
-
end
|
46
|
-
|
47
|
-
puts "\n\n#{title}"
|
48
|
-
puts @@times.inject('') {|s,p| s << "- #{p[:title][0,70].ljust(70, ' ')} #{formatter.call(p[:time]).rjust(10,' ')}\n"}
|
49
|
-
puts '-' * 70 + ' ' * 5 + '-' * 8
|
50
|
-
puts 'Total Time taking Kata'.ljust(70, ' ') + ' ' * 5 + formatter.call(@@times.inject(0) {|s,h| s += h[:time]})
|
51
|
-
end
|
52
|
-
|
53
|
-
exit 1 unless status
|
54
|
-
end
|
55
|
-
|
56
|
-
def ancestry
|
57
|
-
caller.grep(/#{Regexp.escape(__FILE__)}/).map {|v| v.match(/^[^`]*`([^']*)'/)[1]}
|
58
|
-
end
|
59
|
-
|
60
|
-
def indent
|
61
|
-
nesting = ancestry.size - 2
|
62
|
-
' ' * (3 * nesting)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
include Kata
|
1
|
+
require 'kata/setup'
|
2
|
+
require 'kata/base'
|
data/lib/kata/base.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
module Kata
|
2
|
+
module Base
|
3
|
+
@@times = []
|
4
|
+
|
5
|
+
def kata txt, lib = nil
|
6
|
+
@kata_name = txt
|
7
|
+
puts "#{@kata_name} Kata"
|
8
|
+
yield if block_given?
|
9
|
+
complete
|
10
|
+
end
|
11
|
+
|
12
|
+
def context txt
|
13
|
+
puts indent + txt
|
14
|
+
yield if block_given?
|
15
|
+
end
|
16
|
+
|
17
|
+
def requirement txt
|
18
|
+
puts indent + txt
|
19
|
+
|
20
|
+
start = Time.now
|
21
|
+
|
22
|
+
yield if block_given?
|
23
|
+
|
24
|
+
rsp = ask "\ncompleted (Y|n): ", 'y'
|
25
|
+
|
26
|
+
puts
|
27
|
+
|
28
|
+
elapsed = Time.now - start
|
29
|
+
@@times << {:title => txt, :time => elapsed}
|
30
|
+
|
31
|
+
complete false if rsp.downcase == 'n'
|
32
|
+
end
|
33
|
+
|
34
|
+
def example txt
|
35
|
+
puts indent + '- ' + txt
|
36
|
+
end
|
37
|
+
|
38
|
+
def detail txt
|
39
|
+
puts indent + '- ' + txt
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def ask prompt, default
|
45
|
+
print prompt
|
46
|
+
$stdin.gets.chomp || default
|
47
|
+
end
|
48
|
+
|
49
|
+
def complete status = true
|
50
|
+
if @@times.size > 0
|
51
|
+
title = status ? 'Congratulations!' : 'You completed the following:'
|
52
|
+
|
53
|
+
formatter = lambda do |sec|
|
54
|
+
use = sec.round
|
55
|
+
[use/3600, use/60 % 60, use % 60].map {|v| v.to_s.rjust(2,'0')}.join(':')
|
56
|
+
end
|
57
|
+
|
58
|
+
puts "\n\n#{title}"
|
59
|
+
puts @@times.inject('') {|s,p| s << "- #{p[:title][0,70].ljust(70, ' ')} #{formatter.call(p[:time]).rjust(10,' ')}\n"}
|
60
|
+
puts '-' * 70 + ' ' * 5 + '-' * 8
|
61
|
+
puts "Total Time taking #{@kata_name} kata: ".ljust(70, ' ') + ' ' * 5 + formatter.call(@@times.inject(0) {|s,h| s += h[:time]})
|
62
|
+
end
|
63
|
+
|
64
|
+
exit 1 unless status
|
65
|
+
end
|
66
|
+
|
67
|
+
def ancestry
|
68
|
+
caller.grep(/#{Regexp.escape(__FILE__)}/).map {|v| v.match(/^[^`]*`([^']*)'/)[1]}
|
69
|
+
end
|
70
|
+
|
71
|
+
def indent
|
72
|
+
nesting = ancestry.size - 2
|
73
|
+
' ' * (3 * nesting)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
include Kata::Base
|
data/lib/kata/setup.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module Kata
|
5
|
+
class Setup
|
6
|
+
attr_accessor :kata_name
|
7
|
+
attr_reader :repo_name
|
8
|
+
|
9
|
+
def initialize kata_name = 'kata'
|
10
|
+
self.kata_name = kata_name
|
11
|
+
self.repo_name = kata_name
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_repo
|
15
|
+
# Setup from github configuration
|
16
|
+
raise Exception, 'Git not installed' unless system 'which git > /dev/null'
|
17
|
+
|
18
|
+
github = OpenStruct.new :url => 'http://github.com/api/v2/json/'
|
19
|
+
|
20
|
+
github_user, shell_user = %x{git config --get github.user}.chomp, ENV['USER']
|
21
|
+
|
22
|
+
github.user = github_user.empty? ? shell_user : github_user
|
23
|
+
|
24
|
+
raise Exception, 'Unable to determine github user' if github.user.empty?
|
25
|
+
|
26
|
+
github.token = %x{git config --get github.token}.chomp
|
27
|
+
|
28
|
+
raise Exception, 'Unable to determine github api token' if github.token.empty?
|
29
|
+
|
30
|
+
user_string = "-u '#{github.user}/token:#{github.token}'"
|
31
|
+
repo_params = "-d 'name=#{repo_name}' -d 'description=code+kata+repo'"
|
32
|
+
|
33
|
+
# Create the repo on github
|
34
|
+
raise SystemCallError, 'unable to use curl to create repo on github' unless system <<-EOF
|
35
|
+
curl #{user_string} #{repo_params} #{github.url}repos/create
|
36
|
+
EOF
|
37
|
+
|
38
|
+
# publish to github
|
39
|
+
raise SystemCallError, 'unable to publish repo to github' unless system <<-EOF
|
40
|
+
cd #{repo_name};
|
41
|
+
git init;
|
42
|
+
git add README lib/ spec/;
|
43
|
+
git commit -m 'starting kata';
|
44
|
+
git remote add origin git@github.com:#{github.user}/#{repo_name}.git;
|
45
|
+
git push origin master
|
46
|
+
EOF
|
47
|
+
end
|
48
|
+
|
49
|
+
def repo_name= kata_name
|
50
|
+
@repo_name = "#{kata_name.gsub(/( |-)\1?/, '_')}-#{Time.now.strftime('%Y-%m-%d-%H%M%S')}".downcase
|
51
|
+
end
|
52
|
+
|
53
|
+
def build_tree
|
54
|
+
%W{#{repo_name}/lib #{repo_name}/spec/support/helpers #{repo_name}/spec/support/matchers}.each {|path| FileUtils.mkdir_p path}
|
55
|
+
|
56
|
+
use_kata_name = kata_name.gsub(/( |-)\1?/, '_').downcase
|
57
|
+
class_name = kata_name.split(/ |-|_/).map(&:capitalize).join
|
58
|
+
|
59
|
+
# create the README file so github is happy
|
60
|
+
File.open(File.join(repo_name, 'README'), 'w') {|f| f.write <<EOF}
|
61
|
+
Leveling up my ruby awesomeness!
|
62
|
+
EOF
|
63
|
+
|
64
|
+
# create the base class file
|
65
|
+
File.open(File.join(repo_name, 'lib', "#{use_kata_name}.rb"), 'w') {|f| f.write <<EOF}
|
66
|
+
class #{class_name}
|
67
|
+
end
|
68
|
+
EOF
|
69
|
+
|
70
|
+
# create the spec_helper.rb file
|
71
|
+
File.open(File.join(repo_name, 'spec', 'spec_helper.rb'), 'w') {|f| f.write <<EOF}
|
72
|
+
$: << '.' << File.join(File.dirname(__FILE__), '..', 'lib')
|
73
|
+
|
74
|
+
require 'rspec'
|
75
|
+
|
76
|
+
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
|
77
|
+
EOF
|
78
|
+
|
79
|
+
# create a working spec file for the kata
|
80
|
+
File.open(File.join(repo_name, 'spec', "#{use_kata_name}_spec.rb"), 'w') {|f| f.write <<EOF}
|
81
|
+
require 'spec_helper'
|
82
|
+
require '#{use_kata_name}'
|
83
|
+
|
84
|
+
class #{class_name}
|
85
|
+
describe "new" do
|
86
|
+
it "should instantiate" do
|
87
|
+
lambda {
|
88
|
+
#{class_name}.new
|
89
|
+
}.should_not raise_exception
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
EOF
|
94
|
+
# stub out a custom matchers file
|
95
|
+
File.open(File.join(repo_name, 'spec', 'support', 'matchers', "#{use_kata_name}.rb"), 'w') {|f| f.write <<EOF}
|
96
|
+
RSpec::Matchers.define :your_method do |expected|
|
97
|
+
match do |your_match|
|
98
|
+
#your_match.method_on_object_to_execute == expected
|
99
|
+
end
|
100
|
+
end
|
101
|
+
EOF
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'kata/base'
|
3
|
+
|
4
|
+
module Kata
|
5
|
+
module Base
|
6
|
+
describe "DSL" do
|
7
|
+
before :each do
|
8
|
+
@summary = 'sample summary'
|
9
|
+
@display_summary = "#{@summary} Kata"
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#kata" do
|
13
|
+
it "is defined" do
|
14
|
+
capture_stdout do
|
15
|
+
lambda {
|
16
|
+
kata @summary
|
17
|
+
}.should_not raise_exception
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "accepts block" do
|
22
|
+
capture_stdout do
|
23
|
+
lambda {
|
24
|
+
kata @summary do
|
25
|
+
end
|
26
|
+
}.should_not raise_exception
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "displays the summary" do
|
31
|
+
output = capture_stdout do
|
32
|
+
lambda {
|
33
|
+
kata @summary
|
34
|
+
}.should_not raise_exception
|
35
|
+
end
|
36
|
+
|
37
|
+
output.should have_summary @display_summary
|
38
|
+
end
|
39
|
+
|
40
|
+
it "displays the summary with block" do
|
41
|
+
output = capture_stdout do
|
42
|
+
lambda {
|
43
|
+
kata @summary do
|
44
|
+
end
|
45
|
+
}.should_not raise_exception
|
46
|
+
end
|
47
|
+
|
48
|
+
output.should have_summary @display_summary
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#requirement" do
|
53
|
+
before :each do
|
54
|
+
@requirement = "Create a simple string calculator with a method add that takes a string argument"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "is defined" do
|
58
|
+
capture_stdout do
|
59
|
+
lambda {
|
60
|
+
kata @summary do
|
61
|
+
requirement @requirement
|
62
|
+
end
|
63
|
+
}.should_not raise_exception
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it "accepts block" do
|
68
|
+
capture_stdout do
|
69
|
+
lambda {
|
70
|
+
kata @summary do
|
71
|
+
requirement @requirement do
|
72
|
+
end
|
73
|
+
end
|
74
|
+
}.should_not raise_exception
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it "displays the summary" do
|
79
|
+
output = capture_stdout do
|
80
|
+
lambda {
|
81
|
+
kata @summary do
|
82
|
+
requirement @requirement
|
83
|
+
end
|
84
|
+
}.should_not raise_exception
|
85
|
+
end
|
86
|
+
|
87
|
+
output.should have_requirement @display_summary, @requirement
|
88
|
+
end
|
89
|
+
|
90
|
+
it "displays the summary with block" do
|
91
|
+
output = capture_stdout do
|
92
|
+
lambda {
|
93
|
+
kata @summary do
|
94
|
+
requirement @requirement do
|
95
|
+
end
|
96
|
+
end
|
97
|
+
}.should_not raise_exception
|
98
|
+
end
|
99
|
+
|
100
|
+
output.should have_requirement @display_summary, @requirement
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "#example" do
|
105
|
+
before :each do
|
106
|
+
@requirement = "Create a simple string calculator with a method add that takes a string argument"
|
107
|
+
@examples = [
|
108
|
+
%q{The string can contain 0, 1, 2 numbers for example "", "1", "1,2"},
|
109
|
+
"The method will return the sum of the digits",
|
110
|
+
"Then empty string will return 0",
|
111
|
+
]
|
112
|
+
end
|
113
|
+
|
114
|
+
it "are displayed" do
|
115
|
+
capture_stdout do
|
116
|
+
lambda {
|
117
|
+
kata @summary do
|
118
|
+
requirement @requirement do
|
119
|
+
Kata::example @examples[0]
|
120
|
+
end
|
121
|
+
end
|
122
|
+
}.should_not raise_exception
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
it "are displayed with prompt" do
|
127
|
+
output = capture_stdout do
|
128
|
+
lambda {
|
129
|
+
kata @summary do
|
130
|
+
requirement @requirement do
|
131
|
+
Kata::example @examples[0]
|
132
|
+
Kata::example @examples[1]
|
133
|
+
Kata::example @examples[2]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
}.should_not raise_exception
|
137
|
+
end
|
138
|
+
|
139
|
+
output.should have_examples @display_summary, @requirement, @examples
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'kata/setup'
|
3
|
+
|
4
|
+
module Kata
|
5
|
+
describe Setup do
|
6
|
+
subject {Kata::Setup.new}
|
7
|
+
|
8
|
+
describe "new" do
|
9
|
+
it "define a repo name" do
|
10
|
+
subject.repo_name.should match /kata-#{Time.now.strftime('%Y-%m-%d')}-\d{6}/
|
11
|
+
end
|
12
|
+
|
13
|
+
it "defines the kata name" do
|
14
|
+
s = Kata::Setup.new 'my-kata'
|
15
|
+
s.kata_name.should == 'my-kata'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "build_tree" do
|
20
|
+
it "creates files" do
|
21
|
+
lambda {
|
22
|
+
subject.build_tree
|
23
|
+
}.should_not raise_exception
|
24
|
+
|
25
|
+
Dir[File.join(subject.repo_name, '**', '*.rb')].size.should == 4
|
26
|
+
Dir[File.join(subject.repo_name, 'README')].size.should == 1
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -13,6 +13,14 @@ end
|
|
13
13
|
RSpec::Matchers.define :have_examples do |summary, requirement, examples|
|
14
14
|
example_str = examples.unshift('').join("\n - ")
|
15
15
|
match do |string|
|
16
|
-
string.split(/
|
16
|
+
string.split(/completed \(Y|n\)/)[0].strip == "#{summary}\n #{requirement}#{example_str}"
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
%w{url user token}.each do |method|
|
21
|
+
RSpec::Matchers.define "have_#{method}".to_sym do |expected|
|
22
|
+
match do |github|
|
23
|
+
github.send(method) == expected
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 0
|
9
|
-
version: 0.2.0
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Wes
|
@@ -15,7 +11,7 @@ autorequire:
|
|
15
11
|
bindir: bin
|
16
12
|
cert_chain: []
|
17
13
|
|
18
|
-
date:
|
14
|
+
date: 2011-03-11 00:00:00 -08:00
|
19
15
|
default_executable:
|
20
16
|
dependencies:
|
21
17
|
- !ruby/object:Gem::Dependency
|
@@ -26,41 +22,28 @@ dependencies:
|
|
26
22
|
requirements:
|
27
23
|
- - ">="
|
28
24
|
- !ruby/object:Gem::Version
|
29
|
-
segments:
|
30
|
-
- 1
|
31
|
-
- 0
|
32
|
-
- 0
|
33
25
|
version: 1.0.0
|
34
26
|
type: :development
|
35
27
|
version_requirements: *id001
|
36
|
-
description: This DSL provides an easy way for you to write a code kata
|
28
|
+
description: This DSL provides an easy way for you to write a code kata for pairing exercises or individual testing
|
37
29
|
email: baywes@gmail.com
|
38
|
-
executables:
|
39
|
-
|
30
|
+
executables:
|
31
|
+
- kata
|
40
32
|
extensions: []
|
41
33
|
|
42
34
|
extra_rdoc_files: []
|
43
35
|
|
44
36
|
files:
|
45
|
-
-
|
46
|
-
-
|
47
|
-
- bin/autotest
|
48
|
-
- bin/htmldiff
|
49
|
-
- bin/ldiff
|
50
|
-
- bin/minitar
|
51
|
-
- bin/multigem
|
52
|
-
- bin/multiruby
|
53
|
-
- bin/multiruby_setup
|
54
|
-
- bin/rdebug
|
55
|
-
- bin/rspec
|
56
|
-
- bin/unit_diff
|
57
|
-
- bin/zentest
|
37
|
+
- lib/kata/base.rb
|
38
|
+
- lib/kata/setup.rb
|
58
39
|
- lib/kata.rb
|
59
|
-
-
|
40
|
+
- README.md
|
41
|
+
- spec/kata_base_spec.rb
|
42
|
+
- spec/kata_setup_spec.rb
|
60
43
|
- spec/spec_helper.rb
|
61
44
|
- spec/support/helpers/stdout_helper.rb
|
62
45
|
- spec/support/matchers/kata.rb
|
63
|
-
-
|
46
|
+
- bin/kata
|
64
47
|
has_rdoc: true
|
65
48
|
homepage: http://github.com/wbailey/kata
|
66
49
|
licenses: []
|
@@ -75,23 +58,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
58
|
requirements:
|
76
59
|
- - ">="
|
77
60
|
- !ruby/object:Gem::Version
|
78
|
-
segments:
|
79
|
-
- 0
|
80
61
|
version: "0"
|
81
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
63
|
none: false
|
83
64
|
requirements:
|
84
65
|
- - ">="
|
85
66
|
- !ruby/object:Gem::Version
|
86
|
-
segments:
|
87
|
-
- 0
|
88
67
|
version: "0"
|
89
68
|
requirements: []
|
90
69
|
|
91
70
|
rubyforge_project:
|
92
|
-
rubygems_version: 1.
|
71
|
+
rubygems_version: 1.5.0
|
93
72
|
signing_key:
|
94
73
|
specification_version: 3
|
95
74
|
summary: A code kata DSL
|
96
|
-
test_files:
|
97
|
-
|
75
|
+
test_files:
|
76
|
+
- spec/kata_base_spec.rb
|
77
|
+
- spec/kata_setup_spec.rb
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
- spec/support/helpers/stdout_helper.rb
|
80
|
+
- spec/support/matchers/kata.rb
|
data/Rakefile
DELETED
data/bin/autospec
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'autospec' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('rspec-core', 'autospec')
|
data/bin/autotest
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'autotest' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('ZenTest', 'autotest')
|
data/bin/htmldiff
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'htmldiff' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('diff-lcs', 'htmldiff')
|
data/bin/ldiff
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'ldiff' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('diff-lcs', 'ldiff')
|
data/bin/minitar
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'minitar' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('archive-tar-minitar', 'minitar')
|
data/bin/multigem
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'multigem' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('ZenTest', 'multigem')
|
data/bin/multiruby
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'multiruby' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('ZenTest', 'multiruby')
|
data/bin/multiruby_setup
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'multiruby_setup' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('ZenTest', 'multiruby_setup')
|
data/bin/rdebug
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'rdebug' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('ruby-debug19', 'rdebug')
|
data/bin/rspec
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'rspec' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('rspec-core', 'rspec')
|
data/bin/unit_diff
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'unit_diff' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('ZenTest', 'unit_diff')
|
data/bin/zentest
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'zentest' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('ZenTest', 'zentest')
|
data/spec/kata_spec.rb
DELETED
@@ -1,139 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'kata'
|
3
|
-
|
4
|
-
describe "Kata DSL" do
|
5
|
-
before :each do
|
6
|
-
@summary = 'sample summary'
|
7
|
-
end
|
8
|
-
|
9
|
-
context "kata" do
|
10
|
-
it "is defined" do
|
11
|
-
capture_stdout do
|
12
|
-
lambda {
|
13
|
-
kata @summary
|
14
|
-
}.should_not raise_exception
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
it "accepts block" do
|
19
|
-
capture_stdout do
|
20
|
-
lambda {
|
21
|
-
kata @summary do
|
22
|
-
end
|
23
|
-
}.should_not raise_exception
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "displays the summary" do
|
28
|
-
output = capture_stdout do
|
29
|
-
lambda {
|
30
|
-
kata @summary
|
31
|
-
}.should_not raise_exception
|
32
|
-
end
|
33
|
-
|
34
|
-
output.should have_summary @summary
|
35
|
-
end
|
36
|
-
|
37
|
-
it "displays the summary with block" do
|
38
|
-
output = capture_stdout do
|
39
|
-
lambda {
|
40
|
-
kata @summary do
|
41
|
-
end
|
42
|
-
}.should_not raise_exception
|
43
|
-
end
|
44
|
-
|
45
|
-
output.should have_summary @summary
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "requirement" do
|
50
|
-
before :each do
|
51
|
-
@requirement = "Create a simple string calculator with a method add that takes a string argument"
|
52
|
-
end
|
53
|
-
|
54
|
-
it "is defined" do
|
55
|
-
capture_stdout do
|
56
|
-
lambda {
|
57
|
-
kata @summary do
|
58
|
-
requirement @requirement
|
59
|
-
end
|
60
|
-
}.should_not raise_exception
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
it "accepts block" do
|
65
|
-
capture_stdout do
|
66
|
-
lambda {
|
67
|
-
kata @summary do
|
68
|
-
requirement @requirement do
|
69
|
-
end
|
70
|
-
end
|
71
|
-
}.should_not raise_exception
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
it "displays the summary" do
|
76
|
-
output = capture_stdout do
|
77
|
-
lambda {
|
78
|
-
kata @summary do
|
79
|
-
requirement @requirement
|
80
|
-
end
|
81
|
-
}.should_not raise_exception
|
82
|
-
end
|
83
|
-
|
84
|
-
output.should have_requirement @summary, @requirement
|
85
|
-
end
|
86
|
-
|
87
|
-
it "displays the summary with block" do
|
88
|
-
output = capture_stdout do
|
89
|
-
lambda {
|
90
|
-
kata @summary do
|
91
|
-
requirement @requirement do
|
92
|
-
end
|
93
|
-
end
|
94
|
-
}.should_not raise_exception
|
95
|
-
end
|
96
|
-
|
97
|
-
output.should have_requirement @summary, @requirement
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context "example" do
|
102
|
-
before :each do
|
103
|
-
@requirement = "Create a simple string calculator with a method add that takes a string argument"
|
104
|
-
@examples = [
|
105
|
-
%q{The string can contain 0, 1, 2 numbers for example "", "1", "1,2"},
|
106
|
-
"The method will return the sum of the digits",
|
107
|
-
"Then empty string will return 0",
|
108
|
-
]
|
109
|
-
end
|
110
|
-
|
111
|
-
it "are displayed" do
|
112
|
-
capture_stdout do
|
113
|
-
lambda {
|
114
|
-
kata @summary do
|
115
|
-
requirement @requirement do
|
116
|
-
Kata::example @examples[0]
|
117
|
-
end
|
118
|
-
end
|
119
|
-
}.should_not raise_exception
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
it "are displayed with prompt" do
|
124
|
-
output = capture_stdout do
|
125
|
-
lambda {
|
126
|
-
kata @summary do
|
127
|
-
requirement @requirement do
|
128
|
-
Kata::example @examples[0]
|
129
|
-
Kata::example @examples[1]
|
130
|
-
Kata::example @examples[2]
|
131
|
-
end
|
132
|
-
end
|
133
|
-
}.should_not raise_exception
|
134
|
-
end
|
135
|
-
|
136
|
-
output.should have_examples @summary, @requirement, @examples
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|