kata 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +3 -3
- data/bin/kata +5 -0
- data/lib/kata/base.rb +2 -2
- data/lib/kata/setup/ruby.rb +1 -1
- data/lib/kata/version.rb +1 -1
- data/spec/kata_base_spec.rb +72 -112
- data/spec/setup/base_spec.rb +1 -1
- data/spec/spec_helper.rb +6 -0
- data/spec/support/helpers/stdout_helper.rb +11 -8
- metadata +6 -6
data/README.md
CHANGED
@@ -5,7 +5,7 @@ repetition. Authoring katas is done in blogs but you can't really test yourself.
|
|
5
5
|
DSL to author the kata and administer it as a test providing feedback for evaluation. It also
|
6
6
|
provides basic github repo setup so that you can chart solution progress over time.
|
7
7
|
|
8
|
-
The inspiration for this gem came from my friend [Nick Hengeveld](https://github.com/
|
8
|
+
The inspiration for this gem came from my friend [Nick Hengeveld](https://github.com/nickh)
|
9
9
|
|
10
10
|
### Installation
|
11
11
|
|
@@ -60,11 +60,11 @@ The [Wiki](https://github.com/wbailey/kata/wiki) has all of the documentation ne
|
|
60
60
|
|
61
61
|
### Contributors
|
62
62
|
|
63
|
-
|
63
|
+
[Richard Millan](https://github.com/richardiux) updated the tests and forced me to bring more of this up to date
|
64
64
|
|
65
65
|
### License
|
66
66
|
|
67
|
-
Copyright (c) 2011-
|
67
|
+
Copyright (c) 2011-2013 Wes Bailey
|
68
68
|
|
69
69
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
70
70
|
associated documentation files (the "Software"), to deal in the Software without restriction,
|
data/bin/kata
CHANGED
data/lib/kata/base.rb
CHANGED
@@ -18,7 +18,7 @@ module Kata
|
|
18
18
|
yield if block_given?
|
19
19
|
end
|
20
20
|
|
21
|
-
def requirement(txt)
|
21
|
+
def requirement(txt = 'kata requirement')
|
22
22
|
puts indent + txt
|
23
23
|
|
24
24
|
start = Time.now
|
@@ -29,7 +29,7 @@ module Kata
|
|
29
29
|
|
30
30
|
puts
|
31
31
|
|
32
|
-
system %Q{git add . &&
|
32
|
+
system %Q{git add . && git commit -m '#{txt}' > /dev/null} rescue Exception
|
33
33
|
|
34
34
|
elapsed = Time.now - start
|
35
35
|
@@times << {:title => txt, :time => elapsed}
|
data/lib/kata/setup/ruby.rb
CHANGED
data/lib/kata/version.rb
CHANGED
data/spec/kata_base_spec.rb
CHANGED
@@ -3,140 +3,100 @@ require 'kata/base'
|
|
3
3
|
|
4
4
|
module Kata
|
5
5
|
module Base
|
6
|
-
describe
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
6
|
+
describe 'DSL' do
|
7
|
+
let :use_class do
|
8
|
+
Class.new do
|
9
|
+
include Kata::Base
|
28
10
|
end
|
11
|
+
end
|
29
12
|
|
30
|
-
|
31
|
-
output = capture_stdout do
|
32
|
-
lambda {
|
33
|
-
kata @summary
|
34
|
-
}.should_not raise_exception
|
35
|
-
end
|
13
|
+
subject { use_class.new }
|
36
14
|
|
37
|
-
|
38
|
-
end
|
15
|
+
let(:system_call) {"git add . && git commit -m 'test req' > /dev/null"}
|
39
16
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
kata @summary do
|
44
|
-
end
|
45
|
-
}.should_not raise_exception
|
46
|
-
end
|
17
|
+
describe "#kata" do
|
18
|
+
it 'displays summary' do
|
19
|
+
subject.should_receive(:puts).with('test Kata')
|
47
20
|
|
48
|
-
|
21
|
+
subject.kata 'test'
|
49
22
|
end
|
50
23
|
end
|
51
24
|
|
52
|
-
describe
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
25
|
+
describe '#context' do
|
26
|
+
it 'displays' do
|
27
|
+
subject.should_receive(:puts).with('test Kata')
|
28
|
+
subject.should_receive(:puts).with(' test context')
|
66
29
|
|
67
|
-
|
68
|
-
|
69
|
-
lambda {
|
70
|
-
kata @summary do
|
71
|
-
requirement @requirement do
|
72
|
-
end
|
73
|
-
end
|
74
|
-
}.should_not raise_exception
|
30
|
+
subject.kata 'test' do
|
31
|
+
subject.context 'test context'
|
75
32
|
end
|
76
33
|
end
|
77
34
|
|
78
|
-
it
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
35
|
+
it 'accepts requirement' do
|
36
|
+
subject.should_receive(:puts).with(' test context')
|
37
|
+
subject.should_receive(:puts).with(' test req')
|
38
|
+
subject.should_receive(:print)
|
39
|
+
$stdin.should_receive(:gets).and_return('y')
|
40
|
+
subject.should_receive(:puts).exactly(2).times
|
41
|
+
subject.should_receive(:system).with(system_call).and_return(0)
|
42
|
+
subject.should_receive(:puts)
|
43
|
+
|
44
|
+
subject.kata 'test' do
|
45
|
+
subject.context 'test context' do
|
46
|
+
subject.requirement 'test req'
|
47
|
+
end
|
85
48
|
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
49
|
end
|
102
50
|
end
|
103
51
|
|
104
|
-
describe
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
52
|
+
describe '#requirement' do
|
53
|
+
it 'displays' do
|
54
|
+
subject.should_receive(:puts).with(' test req')
|
55
|
+
subject.should_receive(:print)
|
56
|
+
$stdin.should_receive(:gets).and_return('y')
|
57
|
+
subject.should_receive(:puts).exactly(2).times
|
58
|
+
subject.should_receive(:system).with(system_call).and_return(0)
|
59
|
+
subject.should_receive(:puts)
|
60
|
+
|
61
|
+
subject.kata 'test' do
|
62
|
+
subject.requirement 'test req'
|
63
|
+
end
|
112
64
|
end
|
113
65
|
|
114
|
-
it
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
66
|
+
it 'accepts example' do
|
67
|
+
subject.should_receive(:puts).with(' test req')
|
68
|
+
subject.should_receive(:print)
|
69
|
+
$stdin.should_receive(:gets).and_return('y')
|
70
|
+
subject.should_receive(:puts).exactly(2).times
|
71
|
+
subject.should_receive(:system).with(system_call).and_return(0)
|
72
|
+
subject.should_receive(:puts).exactly(3).times
|
73
|
+
subject.should_receive(:puts)
|
74
|
+
|
75
|
+
subject.kata 'test' do
|
76
|
+
subject.requirement 'test req' do
|
77
|
+
subject.example 'test example 1'
|
78
|
+
subject.example 'test example 2'
|
79
|
+
subject.example 'test example 3'
|
80
|
+
end
|
123
81
|
end
|
124
82
|
end
|
125
83
|
|
126
|
-
it
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
84
|
+
it 'accepts detail' do
|
85
|
+
subject.should_receive(:puts).with(' test req')
|
86
|
+
subject.should_receive(:print)
|
87
|
+
$stdin.should_receive(:gets).and_return('y')
|
88
|
+
subject.should_receive(:puts).exactly(2).times
|
89
|
+
subject.should_receive(:system).with(system_call).and_return(0)
|
90
|
+
subject.should_receive(:puts).exactly(3).times
|
91
|
+
subject.should_receive(:puts)
|
92
|
+
|
93
|
+
subject.kata 'test' do
|
94
|
+
subject.requirement 'test req' do
|
95
|
+
subject.detail 'test detail 1'
|
96
|
+
subject.detail 'test detail 2'
|
97
|
+
subject.detail 'test detail 3'
|
98
|
+
end
|
137
99
|
end
|
138
|
-
|
139
|
-
output.should have_examples @display_summary, @requirement, @examples
|
140
100
|
end
|
141
101
|
end
|
142
102
|
end
|
data/spec/setup/base_spec.rb
CHANGED
@@ -23,7 +23,7 @@ module Kata
|
|
23
23
|
it "creates files" do
|
24
24
|
expect {
|
25
25
|
subject.build_tree
|
26
|
-
}.
|
26
|
+
}.to_not raise_exception
|
27
27
|
|
28
28
|
Dir[File.join(subject.repo_name, '**', '*.rb')].size.should == 4
|
29
29
|
Dir[File.join(subject.repo_name, 'README')].size.should == 1
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
-
require 'stringio'
|
2
|
-
|
3
1
|
def capture_stdout
|
4
|
-
|
5
|
-
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
orig_stdout, orig_stdin = $stdout, $stdin
|
5
|
+
captured_stdout, captured_stdin = StringIO.new, StringIO.new("y\n")
|
6
|
+
$stdout, $stdin = captured_stdout, captured_stdin
|
7
|
+
|
6
8
|
yield
|
7
|
-
|
9
|
+
|
10
|
+
return captured_stdout.string.chomp
|
8
11
|
ensure
|
9
|
-
$stdout =
|
10
|
-
$stdin =
|
11
|
-
end
|
12
|
+
$stdout = orig_stdout
|
13
|
+
$stdin = orig_stdin
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-03-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
17
|
-
requirement: &
|
17
|
+
requirement: &2156425380 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 1.0.0
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2156425380
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: command_line_reporter
|
28
|
-
requirement: &
|
28
|
+
requirement: &2156424600 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 3.2.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2156424600
|
37
37
|
description: This DSL provides an easy way for you to write a code kata for pairing
|
38
38
|
exercises or individual testing
|
39
39
|
email: baywes@gmail.com
|