kata 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
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/nhengeveld)
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
- Wes Bailey ([Exposing Gotchas](http://exposinggotchas.blogspot.com/ "Exposing Gotchas"))
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-2012 Wes Bailey
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
@@ -53,6 +53,11 @@ OptionParser.new do |opts|
53
53
  end
54
54
  end.parse!
55
55
 
56
+ if ARGV.empty?
57
+ puts usage
58
+ abort
59
+ end
60
+
56
61
  options.action = ARGV.shift.downcase.to_sym
57
62
  options.file = ARGV.shift
58
63
 
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 . && git commit -m '#{txt}' > /dev/null} rescue Exception
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}
@@ -43,7 +43,7 @@ describe #{class_name} do
43
43
  it "instantiates" do
44
44
  expect {
45
45
  #{class_name}.new
46
- }.should_not raise_exception
46
+ }.to_not raise_exception
47
47
  end
48
48
  end
49
49
  end
data/lib/kata/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kata
2
- VERSION = '1.3.1'
2
+ VERSION = '1.3.2'
3
3
  end
@@ -3,140 +3,100 @@ require 'kata/base'
3
3
 
4
4
  module Kata
5
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
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
- it "displays the summary" do
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
- output.should have_summary @display_summary
38
- end
15
+ let(:system_call) {"git add . && git commit -m 'test req' > /dev/null"}
39
16
 
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
17
+ describe "#kata" do
18
+ it 'displays summary' do
19
+ subject.should_receive(:puts).with('test Kata')
47
20
 
48
- output.should have_summary @display_summary
21
+ subject.kata 'test'
49
22
  end
50
23
  end
51
24
 
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
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
- 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
30
+ subject.kata 'test' do
31
+ subject.context 'test context'
75
32
  end
76
33
  end
77
34
 
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
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 "#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
- ]
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 "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
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 "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
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
@@ -23,7 +23,7 @@ module Kata
23
23
  it "creates files" do
24
24
  expect {
25
25
  subject.build_tree
26
- }.should_not raise_exception
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
@@ -4,3 +4,9 @@ require 'rspec'
4
4
 
5
5
  Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
6
6
 
7
+ RSpec.configure do |config|
8
+ config.before(:each) do
9
+ Kata::Base.stub(:system)
10
+ end
11
+ end
12
+
@@ -1,11 +1,14 @@
1
- require 'stringio'
2
-
3
1
  def capture_stdout
4
- $stdout = StringIO.new
5
- $stdin = StringIO.new("y\n")
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
- $stdout.string.strip
9
+
10
+ return captured_stdout.string.chomp
8
11
  ensure
9
- $stdout = STDOUT
10
- $stdin = 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.1
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: 2012-05-16 00:00:00.000000000 Z
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: &2151828020 !ruby/object:Gem::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: *2151828020
25
+ version_requirements: *2156425380
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: command_line_reporter
28
- requirement: &2151826140 !ruby/object:Gem::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: *2151826140
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