shuhari 0.1.0
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/.gitignore +18 -0
- data/Gemfile +14 -0
- data/Guardfile +6 -0
- data/LICENSE +22 -0
- data/README.md +50 -0
- data/Rakefile +8 -0
- data/bin/shuhari +10 -0
- data/cucumber.yml +11 -0
- data/features/cucumber_kata.feature +89 -0
- data/features/getting_help.feature +41 -0
- data/features/minitest_kata.feature +89 -0
- data/features/minitest_spec_kata.feature +89 -0
- data/features/rspec_kata.feature +93 -0
- data/features/step_definitions/steps.rb +5 -0
- data/features/support/env.rb +3 -0
- data/features/testunit_kata.feature +88 -0
- data/lib/shuhari.rb +9 -0
- data/lib/shuhari/app.rb +87 -0
- data/lib/shuhari/platform.rb +32 -0
- data/lib/shuhari/platform_gems.rb +41 -0
- data/lib/shuhari/project_generation.rb +58 -0
- data/lib/shuhari/version.rb +3 -0
- data/shuhari.gemspec +19 -0
- data/templates/base/.rvmrc.tt +1 -0
- data/templates/base/lib/kata.rb.tt +2 -0
- data/templates/base/shuhari.yml.tt +2 -0
- data/templates/cucumber/Gemfile.tt +8 -0
- data/templates/cucumber/Guardfile +5 -0
- data/templates/cucumber/features/kata.feature.tt +1 -0
- data/templates/cucumber/features/step_definitions/steps.rb +0 -0
- data/templates/cucumber/features/support/env.rb.tt +4 -0
- data/templates/minitest/Gemfile.tt +7 -0
- data/templates/minitest/Guardfile +5 -0
- data/templates/minitest/test/test_helper.rb.tt +5 -0
- data/templates/minitest/test/test_kata.rb.tt +4 -0
- data/templates/minitest_spec/Gemfile.tt +7 -0
- data/templates/minitest_spec/Guardfile +5 -0
- data/templates/minitest_spec/spec/kata_spec.rb.tt +4 -0
- data/templates/minitest_spec/spec/spec_helper.rb.tt +5 -0
- data/templates/rspec/Gemfile.tt +7 -0
- data/templates/rspec/Guardfile +5 -0
- data/templates/rspec/spec/kata_spec.rb.tt +4 -0
- data/templates/rspec/spec/spec_helper.rb.tt +9 -0
- data/templates/testunit/Gemfile.tt +7 -0
- data/templates/testunit/Guardfile +5 -0
- data/templates/testunit/test/kata_test.rb.tt +4 -0
- data/templates/testunit/test/test_helper.rb.tt +4 -0
- metadata +119 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in shuhari.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :test do
|
7
|
+
gem 'cucumber'
|
8
|
+
gem 'rspec'
|
9
|
+
gem 'aruba'
|
10
|
+
gem 'guard-cucumber'
|
11
|
+
gem 'coolline', :require => false
|
12
|
+
gem 'growl', :require => false
|
13
|
+
gem 'rb-fsevent', :require => false
|
14
|
+
end
|
data/Guardfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Jason Arhart
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Shuhari
|
2
|
+
|
3
|
+
Shuhari generates new projects for doing TDD Kata.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Switch to your global gemset if you're using rvm:
|
8
|
+
|
9
|
+
$ rvm use @global
|
10
|
+
|
11
|
+
Install the gem:
|
12
|
+
|
13
|
+
$ gem install shuhari
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Get help on shuhari commands:
|
18
|
+
|
19
|
+
$ shuhari help
|
20
|
+
|
21
|
+
Create your kata project:
|
22
|
+
|
23
|
+
$ shuhari new MyAwesomeKata
|
24
|
+
|
25
|
+
Bundle your gems:
|
26
|
+
|
27
|
+
$ cd my_awesome_kata
|
28
|
+
$ bundle
|
29
|
+
|
30
|
+
Start guard to run your tests automatically:
|
31
|
+
|
32
|
+
$ guard
|
33
|
+
|
34
|
+
Do your kata! Guard will monitor your files and run your tests automatically
|
35
|
+
whenever you make a change.
|
36
|
+
|
37
|
+
When you finish your kata:
|
38
|
+
|
39
|
+
$ shuhari empty
|
40
|
+
|
41
|
+
Your project is empty again (your tests and code are removed) and you can
|
42
|
+
restart your kata!
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/shuhari
ADDED
data/cucumber.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
<%
|
2
|
+
std_opts = '--format progress'
|
3
|
+
|
4
|
+
platform_opts = case RUBY_PLATFORM
|
5
|
+
when /darwin/ then '--tags ~@linux --tags ~@windows'
|
6
|
+
when /linux/ then '--tags ~@osx --tags ~@windows'
|
7
|
+
when /win32/, /mingw32/ then '--tags ~@osx --tags ~@linux'
|
8
|
+
else '--tags ~@osx --tags ~@linux --tags ~@windows'
|
9
|
+
end
|
10
|
+
%>
|
11
|
+
default: <%= std_opts %> <%= platform_opts %>
|
@@ -0,0 +1,89 @@
|
|
1
|
+
Feature: Cucumber Kata Generation
|
2
|
+
|
3
|
+
Scenario: All Platforms
|
4
|
+
When I run `shuhari new FizzBuzz --cucumber`
|
5
|
+
Then a directory named "fizz_buzz" should exist
|
6
|
+
And the following files should exist:
|
7
|
+
|fizz_buzz/Gemfile |
|
8
|
+
|fizz_buzz/Guardfile |
|
9
|
+
|fizz_buzz/lib/fizz_buzz.rb |
|
10
|
+
|fizz_buzz/features/fizz_buzz.feature |
|
11
|
+
|fizz_buzz/features/support/env.rb |
|
12
|
+
|fizz_buzz/features/step_definitions/steps.rb |
|
13
|
+
|fizz_buzz/shuhari.yml |
|
14
|
+
And the file "fizz_buzz/features/fizz_buzz.feature" should contain:
|
15
|
+
"""
|
16
|
+
Feature: Fizz Buzz
|
17
|
+
"""
|
18
|
+
And the file "fizz_buzz/lib/fizz_buzz.rb" should contain:
|
19
|
+
"""
|
20
|
+
class FizzBuzz
|
21
|
+
end
|
22
|
+
"""
|
23
|
+
And the file "fizz_buzz/features/support/env.rb" should contain:
|
24
|
+
"""
|
25
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', File.dirname(__FILE__))
|
26
|
+
|
27
|
+
require 'fizz_buzz'
|
28
|
+
require 'rspec/expectations'
|
29
|
+
"""
|
30
|
+
And the file "fizz_buzz/Guardfile" should contain:
|
31
|
+
"""
|
32
|
+
guard 'cucumber' do
|
33
|
+
watch(%r{^lib/.+\.rb$}) { 'features' }
|
34
|
+
watch(%r{^features/.+\.feature$})
|
35
|
+
watch(%r{^features/(support|step_definitions)/.+$}) { 'features' }
|
36
|
+
end
|
37
|
+
"""
|
38
|
+
And the file "fizz_buzz/shuhari.yml" should contain:
|
39
|
+
"""
|
40
|
+
project_name: FizzBuzz
|
41
|
+
test_framework: cucumber
|
42
|
+
"""
|
43
|
+
|
44
|
+
@osx
|
45
|
+
Scenario: OS X
|
46
|
+
When I run `shuhari new FizzBuzz --cucumber`
|
47
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
48
|
+
"""
|
49
|
+
group :development do
|
50
|
+
gem 'cucumber'
|
51
|
+
gem 'rspec'
|
52
|
+
gem 'guard-cucumber'
|
53
|
+
gem 'coolline', :require => false
|
54
|
+
gem 'growl'
|
55
|
+
# gem 'growl_notify'
|
56
|
+
# gem 'ruby_gntp'
|
57
|
+
gem 'rb-fsevent'
|
58
|
+
end
|
59
|
+
"""
|
60
|
+
|
61
|
+
@linux
|
62
|
+
Scenario: Linux
|
63
|
+
When I run `shuhari new FizzBuzz --cucumber`
|
64
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
65
|
+
"""
|
66
|
+
group :development do
|
67
|
+
gem 'cucumber'
|
68
|
+
gem 'rspec'
|
69
|
+
gem 'guard-cucumber'
|
70
|
+
gem 'coolline', :require => false
|
71
|
+
gem 'libnotify'
|
72
|
+
gem 'rb-inotify'
|
73
|
+
end
|
74
|
+
"""
|
75
|
+
|
76
|
+
@windows
|
77
|
+
Scenario: Windows
|
78
|
+
When I run `shuhari new FizzBuzz --cucumber`
|
79
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
80
|
+
"""
|
81
|
+
group :development do
|
82
|
+
gem 'cucumber'
|
83
|
+
gem 'rspec'
|
84
|
+
gem 'guard-cucumber'
|
85
|
+
gem 'rb-notifu'
|
86
|
+
gem 'win32console'
|
87
|
+
gem 'wdm'
|
88
|
+
end
|
89
|
+
"""
|
@@ -0,0 +1,41 @@
|
|
1
|
+
Feature: Getting Help
|
2
|
+
|
3
|
+
Scenario: General help
|
4
|
+
When I run `shuhari help`
|
5
|
+
Then the output should contain:
|
6
|
+
"""
|
7
|
+
Tasks:
|
8
|
+
shuhari empty # Restart the Kata with empty mind and project
|
9
|
+
shuhari help [TASK] # Describe available tasks or one specific task
|
10
|
+
shuhari new [NAME] # Create a new Kata project
|
11
|
+
"""
|
12
|
+
|
13
|
+
Scenario: Help about the "new" task
|
14
|
+
When I run `shuhari help new`
|
15
|
+
Then the output should contain:
|
16
|
+
"""
|
17
|
+
Usage:
|
18
|
+
shuhari new [NAME]
|
19
|
+
|
20
|
+
Options:
|
21
|
+
-r, [--rspec] # Test using RSpec
|
22
|
+
# Default: true
|
23
|
+
-m, [--minitest] # Test using Minitest::Unit
|
24
|
+
-s, [--minitest-spec] # Test using Minitest::Spec
|
25
|
+
-t, [--testunit] # Test using Test::Unit
|
26
|
+
-c, [--cucumber] # Test using Cucumber
|
27
|
+
-g, [--gemset] # Create .rvmrc to use a gemset
|
28
|
+
# Default: true
|
29
|
+
|
30
|
+
Create a new Kata project
|
31
|
+
"""
|
32
|
+
|
33
|
+
Scenario: Help about the "empty" task
|
34
|
+
When I run `shuhari help empty`
|
35
|
+
Then the output should contain:
|
36
|
+
"""
|
37
|
+
Usage:
|
38
|
+
shuhari empty
|
39
|
+
|
40
|
+
Restart the Kata with empty mind and project
|
41
|
+
"""
|
@@ -0,0 +1,89 @@
|
|
1
|
+
Feature: Minitest Kata Generation
|
2
|
+
|
3
|
+
Scenario: All Platforms
|
4
|
+
When I run `shuhari new FizzBuzz --minitest`
|
5
|
+
Then a directory named "fizz_buzz" should exist
|
6
|
+
And the following files should exist:
|
7
|
+
|fizz_buzz/Gemfile |
|
8
|
+
|fizz_buzz/Guardfile |
|
9
|
+
|fizz_buzz/lib/fizz_buzz.rb |
|
10
|
+
|fizz_buzz/test/test_helper.rb |
|
11
|
+
|fizz_buzz/test/test_fizz_buzz.rb |
|
12
|
+
|fizz_buzz/shuhari.yml |
|
13
|
+
And the file "fizz_buzz/test/test_fizz_buzz.rb" should contain:
|
14
|
+
"""
|
15
|
+
require File.expand_path('test_helper', File.dirname(__FILE__))
|
16
|
+
|
17
|
+
class TestFizzBuzz < MiniTest::Unit::TestCase
|
18
|
+
end
|
19
|
+
"""
|
20
|
+
And the file "fizz_buzz/lib/fizz_buzz.rb" should contain:
|
21
|
+
"""
|
22
|
+
class FizzBuzz
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
And the file "fizz_buzz/test/test_helper.rb" should contain:
|
26
|
+
"""
|
27
|
+
$LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__))
|
28
|
+
|
29
|
+
require 'fizz_buzz'
|
30
|
+
require 'minitest/autorun'
|
31
|
+
require 'minitest/pride'
|
32
|
+
"""
|
33
|
+
And the file "fizz_buzz/Guardfile" should contain:
|
34
|
+
"""
|
35
|
+
guard 'minitest' do
|
36
|
+
watch(%r|^test/test_(.*)\.rb|)
|
37
|
+
watch(%r|^lib/(.*)\.rb|) { |m| "test/test_#{m[1]}.rb" }
|
38
|
+
watch(%r|^test/test_helper\.rb|) { "test" }
|
39
|
+
end
|
40
|
+
"""
|
41
|
+
And the file "fizz_buzz/shuhari.yml" should contain:
|
42
|
+
"""
|
43
|
+
project_name: FizzBuzz
|
44
|
+
test_framework: minitest
|
45
|
+
"""
|
46
|
+
|
47
|
+
@osx
|
48
|
+
Scenario: OS X
|
49
|
+
When I run `shuhari new FizzBuzz --minitest`
|
50
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
51
|
+
"""
|
52
|
+
group :development do
|
53
|
+
gem 'minitest'
|
54
|
+
gem 'guard-minitest'
|
55
|
+
gem 'coolline', :require => false
|
56
|
+
gem 'growl'
|
57
|
+
# gem 'growl_notify'
|
58
|
+
# gem 'ruby_gntp'
|
59
|
+
gem 'rb-fsevent'
|
60
|
+
end
|
61
|
+
"""
|
62
|
+
|
63
|
+
@linux
|
64
|
+
Scenario: Linux
|
65
|
+
When I run `shuhari new FizzBuzz --minitest`
|
66
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
67
|
+
"""
|
68
|
+
group :development do
|
69
|
+
gem 'minitest'
|
70
|
+
gem 'guard-minitest'
|
71
|
+
gem 'coolline', :require => false
|
72
|
+
gem 'libnotify'
|
73
|
+
gem 'rb-inotify'
|
74
|
+
end
|
75
|
+
"""
|
76
|
+
|
77
|
+
@windows
|
78
|
+
Scenario: Windows
|
79
|
+
When I run `shuhari new FizzBuzz --minitest`
|
80
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
81
|
+
"""
|
82
|
+
group :development do
|
83
|
+
gem 'minitest'
|
84
|
+
gem 'guard-minitest'
|
85
|
+
gem 'rb-notifu'
|
86
|
+
gem 'win32console'
|
87
|
+
gem 'wdm'
|
88
|
+
end
|
89
|
+
"""
|
@@ -0,0 +1,89 @@
|
|
1
|
+
Feature: Minitest::Spec Kata Generation
|
2
|
+
|
3
|
+
Scenario: All Platforms
|
4
|
+
When I run `shuhari new FizzBuzz --minitest_spec`
|
5
|
+
Then a directory named "fizz_buzz" should exist
|
6
|
+
And the following files should exist:
|
7
|
+
|fizz_buzz/Gemfile |
|
8
|
+
|fizz_buzz/Guardfile |
|
9
|
+
|fizz_buzz/lib/fizz_buzz.rb |
|
10
|
+
|fizz_buzz/spec/spec_helper.rb |
|
11
|
+
|fizz_buzz/spec/fizz_buzz_spec.rb |
|
12
|
+
|fizz_buzz/shuhari.yml |
|
13
|
+
And the file "fizz_buzz/spec/fizz_buzz_spec.rb" should contain:
|
14
|
+
"""
|
15
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
16
|
+
|
17
|
+
describe FizzBuzz do
|
18
|
+
end
|
19
|
+
"""
|
20
|
+
And the file "fizz_buzz/lib/fizz_buzz.rb" should contain:
|
21
|
+
"""
|
22
|
+
class FizzBuzz
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
And the file "fizz_buzz/spec/spec_helper.rb" should contain:
|
26
|
+
"""
|
27
|
+
$LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__))
|
28
|
+
|
29
|
+
require 'fizz_buzz'
|
30
|
+
require 'minitest/autorun'
|
31
|
+
require 'minitest/pride'
|
32
|
+
"""
|
33
|
+
And the file "fizz_buzz/Guardfile" should contain:
|
34
|
+
"""
|
35
|
+
guard 'minitest' do
|
36
|
+
watch(%r|^spec/(.*)_spec\.rb|)
|
37
|
+
watch(%r|^lib/(.*)\.rb|) { |m| "spec/#{m[1]}_spec.rb" }
|
38
|
+
watch(%r|^spec/spec_helper\.rb|) { "spec" }
|
39
|
+
end
|
40
|
+
"""
|
41
|
+
And the file "fizz_buzz/shuhari.yml" should contain:
|
42
|
+
"""
|
43
|
+
project_name: FizzBuzz
|
44
|
+
test_framework: minitest_spec
|
45
|
+
"""
|
46
|
+
|
47
|
+
@osx
|
48
|
+
Scenario: OS X
|
49
|
+
When I run `shuhari new FizzBuzz --minitest_spec`
|
50
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
51
|
+
"""
|
52
|
+
group :development do
|
53
|
+
gem 'minitest'
|
54
|
+
gem 'guard-minitest'
|
55
|
+
gem 'coolline', :require => false
|
56
|
+
gem 'growl'
|
57
|
+
# gem 'growl_notify'
|
58
|
+
# gem 'ruby_gntp'
|
59
|
+
gem 'rb-fsevent'
|
60
|
+
end
|
61
|
+
"""
|
62
|
+
|
63
|
+
@linux
|
64
|
+
Scenario: Linux
|
65
|
+
When I run `shuhari new FizzBuzz --minitest_spec`
|
66
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
67
|
+
"""
|
68
|
+
group :development do
|
69
|
+
gem 'minitest'
|
70
|
+
gem 'guard-minitest'
|
71
|
+
gem 'coolline', :require => false
|
72
|
+
gem 'libnotify'
|
73
|
+
gem 'rb-inotify'
|
74
|
+
end
|
75
|
+
"""
|
76
|
+
|
77
|
+
@windows
|
78
|
+
Scenario: Windows
|
79
|
+
When I run `shuhari new FizzBuzz --minitest_spec`
|
80
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
81
|
+
"""
|
82
|
+
group :development do
|
83
|
+
gem 'minitest'
|
84
|
+
gem 'guard-minitest'
|
85
|
+
gem 'rb-notifu'
|
86
|
+
gem 'win32console'
|
87
|
+
gem 'wdm'
|
88
|
+
end
|
89
|
+
"""
|
@@ -0,0 +1,93 @@
|
|
1
|
+
Feature: RSpec Kata Generation
|
2
|
+
|
3
|
+
Scenario: All Platforms
|
4
|
+
When I run `shuhari new FizzBuzz --rspec`
|
5
|
+
Then a directory named "fizz_buzz" should exist
|
6
|
+
And the following files should exist:
|
7
|
+
|fizz_buzz/Gemfile |
|
8
|
+
|fizz_buzz/Guardfile |
|
9
|
+
|fizz_buzz/lib/fizz_buzz.rb |
|
10
|
+
|fizz_buzz/spec/spec_helper.rb |
|
11
|
+
|fizz_buzz/spec/fizz_buzz_spec.rb |
|
12
|
+
|fizz_buzz/shuhari.yml |
|
13
|
+
And the file "fizz_buzz/spec/fizz_buzz_spec.rb" should contain:
|
14
|
+
"""
|
15
|
+
require 'spec_helper'
|
16
|
+
|
17
|
+
describe FizzBuzz do
|
18
|
+
end
|
19
|
+
"""
|
20
|
+
And the file "fizz_buzz/lib/fizz_buzz.rb" should contain:
|
21
|
+
"""
|
22
|
+
class FizzBuzz
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
And the file "fizz_buzz/spec/spec_helper.rb" should contain:
|
26
|
+
"""
|
27
|
+
require 'fizz_buzz'
|
28
|
+
require 'rspec'
|
29
|
+
|
30
|
+
# Requires supporting files with custom matchers and macros, etc,
|
31
|
+
# in ./support/ and its subdirectories.
|
32
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
33
|
+
|
34
|
+
RSpec.configure do |config|
|
35
|
+
end
|
36
|
+
"""
|
37
|
+
And the file "fizz_buzz/Guardfile" should contain:
|
38
|
+
"""
|
39
|
+
guard 'rspec', :version => 2 do
|
40
|
+
watch(%r{^spec/.+_spec\.rb$})
|
41
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
42
|
+
watch('spec/spec_helper.rb') { "spec/" }
|
43
|
+
end
|
44
|
+
"""
|
45
|
+
And the file "fizz_buzz/shuhari.yml" should contain:
|
46
|
+
"""
|
47
|
+
project_name: FizzBuzz
|
48
|
+
test_framework: rspec
|
49
|
+
"""
|
50
|
+
|
51
|
+
@osx
|
52
|
+
Scenario: OS X
|
53
|
+
When I run `shuhari new FizzBuzz --rspec`
|
54
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
55
|
+
"""
|
56
|
+
group :development do
|
57
|
+
gem 'rspec'
|
58
|
+
gem 'guard-rspec'
|
59
|
+
gem 'coolline', :require => false
|
60
|
+
gem 'growl'
|
61
|
+
# gem 'growl_notify'
|
62
|
+
# gem 'ruby_gntp'
|
63
|
+
gem 'rb-fsevent'
|
64
|
+
end
|
65
|
+
"""
|
66
|
+
|
67
|
+
@linux
|
68
|
+
Scenario: Linux
|
69
|
+
When I run `shuhari new FizzBuzz --rspec`
|
70
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
71
|
+
"""
|
72
|
+
group :development do
|
73
|
+
gem 'rspec'
|
74
|
+
gem 'guard-rspec'
|
75
|
+
gem 'coolline', :require => false
|
76
|
+
gem 'libnotify'
|
77
|
+
gem 'rb-inotify'
|
78
|
+
end
|
79
|
+
"""
|
80
|
+
|
81
|
+
@windows
|
82
|
+
Scenario: Windows
|
83
|
+
When I run `shuhari new FizzBuzz --rspec`
|
84
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
85
|
+
"""
|
86
|
+
group :development do
|
87
|
+
gem 'rspec'
|
88
|
+
gem 'guard-rspec'
|
89
|
+
gem 'rb-notifu'
|
90
|
+
gem 'win32console'
|
91
|
+
gem 'wdm'
|
92
|
+
end
|
93
|
+
"""
|
@@ -0,0 +1,88 @@
|
|
1
|
+
Feature: Test::Unit Kata Generation
|
2
|
+
|
3
|
+
Scenario: All Platforms
|
4
|
+
When I run `shuhari new FizzBuzz --testunit`
|
5
|
+
Then a directory named "fizz_buzz" should exist
|
6
|
+
And the following files should exist:
|
7
|
+
|fizz_buzz/Gemfile |
|
8
|
+
|fizz_buzz/Guardfile |
|
9
|
+
|fizz_buzz/lib/fizz_buzz.rb |
|
10
|
+
|fizz_buzz/test/test_helper.rb |
|
11
|
+
|fizz_buzz/test/fizz_buzz_test.rb |
|
12
|
+
|fizz_buzz/shuhari.yml |
|
13
|
+
And the file "fizz_buzz/test/fizz_buzz_test.rb" should contain:
|
14
|
+
"""
|
15
|
+
require 'test_helper'
|
16
|
+
|
17
|
+
class FizzBuzzTest < Test::Unit::TestCase
|
18
|
+
end
|
19
|
+
"""
|
20
|
+
And the file "fizz_buzz/lib/fizz_buzz.rb" should contain:
|
21
|
+
"""
|
22
|
+
class FizzBuzz
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
And the file "fizz_buzz/test/test_helper.rb" should contain:
|
26
|
+
"""
|
27
|
+
$LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__))
|
28
|
+
|
29
|
+
require 'fizz_buzz'
|
30
|
+
require 'test/unit'
|
31
|
+
"""
|
32
|
+
And the file "fizz_buzz/Guardfile" should contain:
|
33
|
+
"""
|
34
|
+
guard :test do
|
35
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
36
|
+
watch(%r{^test/.+_test\.rb$})
|
37
|
+
watch('test/test_helper.rb') { "test" }
|
38
|
+
end
|
39
|
+
"""
|
40
|
+
And the file "fizz_buzz/shuhari.yml" should contain:
|
41
|
+
"""
|
42
|
+
project_name: FizzBuzz
|
43
|
+
test_framework: testunit
|
44
|
+
"""
|
45
|
+
|
46
|
+
@osx
|
47
|
+
Scenario: OS X
|
48
|
+
When I run `shuhari new FizzBuzz --testunit`
|
49
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
50
|
+
"""
|
51
|
+
group :development do
|
52
|
+
gem 'test-unit'
|
53
|
+
gem 'guard-test'
|
54
|
+
gem 'coolline', :require => false
|
55
|
+
gem 'growl'
|
56
|
+
# gem 'growl_notify'
|
57
|
+
# gem 'ruby_gntp'
|
58
|
+
gem 'rb-fsevent'
|
59
|
+
end
|
60
|
+
"""
|
61
|
+
|
62
|
+
@linux
|
63
|
+
Scenario: Linux
|
64
|
+
When I run `shuhari new FizzBuzz --testunit`
|
65
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
66
|
+
"""
|
67
|
+
group :development do
|
68
|
+
gem 'test-unit'
|
69
|
+
gem 'guard-test'
|
70
|
+
gem 'coolline', :require => false
|
71
|
+
gem 'libnotify'
|
72
|
+
gem 'rb-inotify'
|
73
|
+
end
|
74
|
+
"""
|
75
|
+
|
76
|
+
@windows
|
77
|
+
Scenario: Windows
|
78
|
+
When I run `shuhari new FizzBuzz --testunit`
|
79
|
+
Then the file "fizz_buzz/Gemfile" should contain:
|
80
|
+
"""
|
81
|
+
group :development do
|
82
|
+
gem 'test-unit'
|
83
|
+
gem 'guard-test'
|
84
|
+
gem 'rb-notifu'
|
85
|
+
gem 'win32console'
|
86
|
+
gem 'wdm'
|
87
|
+
end
|
88
|
+
"""
|
data/lib/shuhari.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
module Shuhari
|
2
|
+
|
3
|
+
PROJECT_ROOT = File.expand_path('..', File.dirname(__FILE__))
|
4
|
+
|
5
|
+
autoload :App, 'shuhari/app'
|
6
|
+
autoload :Platform, 'shuhari/platform'
|
7
|
+
autoload :PlatformGems, 'shuhari/platform_gems'
|
8
|
+
autoload :ProjectGeneration, 'shuhari/project_generation'
|
9
|
+
end
|
data/lib/shuhari/app.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'shuhari'
|
3
|
+
|
4
|
+
module Shuhari
|
5
|
+
class App < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
include ProjectGeneration
|
8
|
+
|
9
|
+
desc 'new [NAME]', 'Create a new Kata project'
|
10
|
+
|
11
|
+
method_option :rspec, :type => :boolean, :aliases => '-r',
|
12
|
+
:desc => 'Test using RSpec', :default => true
|
13
|
+
|
14
|
+
method_option :minitest, :type => :boolean, :aliases => '-m',
|
15
|
+
:desc => 'Test using Minitest::Unit'
|
16
|
+
|
17
|
+
method_option :minitest_spec, :type => :boolean, :aliases => '-s',
|
18
|
+
:desc => 'Test using Minitest::Spec'
|
19
|
+
|
20
|
+
method_option :testunit, :type => :boolean, :aliases => '-t',
|
21
|
+
:desc => 'Test using Test::Unit'
|
22
|
+
|
23
|
+
method_option :cucumber, :type => :boolean, :aliases => '-c',
|
24
|
+
:desc => 'Test using Cucumber'
|
25
|
+
|
26
|
+
if Platform.unix?
|
27
|
+
method_option :gemset, :type => :boolean, :aliases => '-g',
|
28
|
+
:desc => 'Create .rvmrc to use a gemset', :default => Platform.rvm?
|
29
|
+
end
|
30
|
+
|
31
|
+
def new(name=nil)
|
32
|
+
@name = name || ask('Project Name:')
|
33
|
+
setup_source_paths
|
34
|
+
inside snake_name, :verbose => true do
|
35
|
+
self.destination_root = '.'
|
36
|
+
create_project
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
desc 'empty', 'Restart the Kata with empty mind and project'
|
41
|
+
def empty
|
42
|
+
@name = load_setting(:project_name)
|
43
|
+
@framework = load_setting(:test_framework)
|
44
|
+
clean_project
|
45
|
+
setup_source_paths
|
46
|
+
setup_code
|
47
|
+
end
|
48
|
+
|
49
|
+
protected
|
50
|
+
|
51
|
+
def load_setting(name)
|
52
|
+
require 'yaml'
|
53
|
+
@settings ||= YAML.load_file('shuhari.yml')
|
54
|
+
@settings[name.to_s] or raise Thor::Error, "#{name} missing from shuhari.yml"
|
55
|
+
end
|
56
|
+
|
57
|
+
def setup_source_paths
|
58
|
+
['base', framework].each do |sub|
|
59
|
+
source_paths << File.join(PROJECT_ROOT, 'templates', sub)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
attr_accessor :name
|
64
|
+
|
65
|
+
def camel_name
|
66
|
+
@camel_name ||= Util.camel_case(name)
|
67
|
+
end
|
68
|
+
|
69
|
+
def snake_name
|
70
|
+
@snake_name ||= Util.snake_case(name)
|
71
|
+
end
|
72
|
+
|
73
|
+
def human_name
|
74
|
+
@human_name ||= snake_name.split('_').map { |i| i.capitalize }.join(' ')
|
75
|
+
end
|
76
|
+
|
77
|
+
def framework
|
78
|
+
@framework ||= %w(
|
79
|
+
minitest minitest_spec testunit cucumber rspec
|
80
|
+
).find { |f| options[f.to_sym] }
|
81
|
+
end
|
82
|
+
|
83
|
+
def gemset
|
84
|
+
options[:gemset] && "#{snake_name}_kata"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'shuhari'
|
2
|
+
|
3
|
+
module Shuhari
|
4
|
+
module Platform
|
5
|
+
|
6
|
+
module_function
|
7
|
+
|
8
|
+
def rvm?
|
9
|
+
!`which rvm`.empty?
|
10
|
+
end
|
11
|
+
|
12
|
+
def unix?
|
13
|
+
osx? or linux?
|
14
|
+
end
|
15
|
+
|
16
|
+
def osx?
|
17
|
+
os == :osx
|
18
|
+
end
|
19
|
+
|
20
|
+
def linux?
|
21
|
+
os == :linux
|
22
|
+
end
|
23
|
+
|
24
|
+
def os
|
25
|
+
@os ||= case RUBY_PLATFORM
|
26
|
+
when /darwin/ then :osx
|
27
|
+
when /linux/ then :linux
|
28
|
+
when /win32/, /mingw32/ then :windows
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'shuhari'
|
2
|
+
|
3
|
+
module Shuhari
|
4
|
+
module PlatformGems
|
5
|
+
|
6
|
+
protected
|
7
|
+
|
8
|
+
def osx_gems
|
9
|
+
unix_gems +
|
10
|
+
[ "gem 'growl'",
|
11
|
+
"# gem 'growl_notify'",
|
12
|
+
"# gem 'ruby_gntp'",
|
13
|
+
"gem 'rb-fsevent'" ]
|
14
|
+
end
|
15
|
+
|
16
|
+
def linux_gems
|
17
|
+
unix_gems +
|
18
|
+
[ "gem 'libnotify'",
|
19
|
+
"gem 'rb-inotify'" ]
|
20
|
+
end
|
21
|
+
|
22
|
+
def unix_gems
|
23
|
+
[ "gem 'coolline', :require => false" ]
|
24
|
+
end
|
25
|
+
|
26
|
+
def windows_gems
|
27
|
+
[ "gem 'rb-notifu'",
|
28
|
+
"gem 'win32console'",
|
29
|
+
"gem 'wdm'" ]
|
30
|
+
end
|
31
|
+
|
32
|
+
def platform_gems
|
33
|
+
case Platform.os
|
34
|
+
when :osx then osx_gems
|
35
|
+
when :linux then linux_gems
|
36
|
+
when :windows then windows_gems
|
37
|
+
else []
|
38
|
+
end.join "\n "
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Shuhari
|
4
|
+
module ProjectGeneration
|
5
|
+
include Thor::Actions
|
6
|
+
include PlatformGems
|
7
|
+
|
8
|
+
protected
|
9
|
+
|
10
|
+
def create_project
|
11
|
+
template 'Gemfile.tt'
|
12
|
+
copy_file 'Guardfile'
|
13
|
+
setup_code
|
14
|
+
template 'shuhari.yml.tt'
|
15
|
+
template '.rvmrc.tt' if gemset
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup_code
|
19
|
+
inside('lib') { template 'kata.rb.tt', "#{snake_name}.rb" }
|
20
|
+
inside(test_directory) { send :"setup_#{framework}" }
|
21
|
+
end
|
22
|
+
|
23
|
+
def setup_rspec
|
24
|
+
template 'spec_helper.rb.tt'
|
25
|
+
template 'kata_spec.rb.tt', "#{snake_name}_spec.rb"
|
26
|
+
end
|
27
|
+
|
28
|
+
def setup_minitest
|
29
|
+
template 'test_helper.rb.tt'
|
30
|
+
template 'test_kata.rb.tt', "test_#{snake_name}.rb"
|
31
|
+
end
|
32
|
+
|
33
|
+
alias_method :setup_minitest_spec, :setup_rspec
|
34
|
+
|
35
|
+
def setup_testunit
|
36
|
+
template 'test_helper.rb.tt'
|
37
|
+
template 'kata_test.rb.tt', "#{snake_name}_test.rb"
|
38
|
+
end
|
39
|
+
|
40
|
+
def setup_cucumber
|
41
|
+
inside('support') { template 'env.rb.tt' }
|
42
|
+
directory 'step_definitions'
|
43
|
+
template 'kata.feature.tt', "#{snake_name}.feature"
|
44
|
+
end
|
45
|
+
|
46
|
+
def clean_project
|
47
|
+
['lib', test_directory].each { |dir| remove_dir dir }
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_directory
|
51
|
+
case framework
|
52
|
+
when 'rspec', 'minitest_spec' then 'spec'
|
53
|
+
when 'cucumber' then 'features'
|
54
|
+
else 'test'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/shuhari.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/shuhari/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Jason Arhart"]
|
6
|
+
gem.email = ["jarhart@gmail.com"]
|
7
|
+
gem.description = %q{Shuhari generates new projects for doing TDD Kata.}
|
8
|
+
gem.summary = %q{TDD Kata project generator}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "shuhari"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Shuhari::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency "thor", "~> 0.14"
|
19
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
rvm use @<%= gemset %> --create
|
@@ -0,0 +1 @@
|
|
1
|
+
Feature: <%= human_name %>
|
File without changes
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require '<%= snake_name %>'
|
2
|
+
require 'rspec'
|
3
|
+
|
4
|
+
# Requires supporting files with custom matchers and macros, etc,
|
5
|
+
# in ./support/ and its subdirectories.
|
6
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shuhari
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jason Arhart
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.14'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.14'
|
30
|
+
description: Shuhari generates new projects for doing TDD Kata.
|
31
|
+
email:
|
32
|
+
- jarhart@gmail.com
|
33
|
+
executables:
|
34
|
+
- shuhari
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- .gitignore
|
39
|
+
- Gemfile
|
40
|
+
- Gemfile.lock
|
41
|
+
- Guardfile
|
42
|
+
- LICENSE
|
43
|
+
- README.md
|
44
|
+
- Rakefile
|
45
|
+
- bin/shuhari
|
46
|
+
- cucumber.yml
|
47
|
+
- features/cucumber_kata.feature
|
48
|
+
- features/getting_help.feature
|
49
|
+
- features/minitest_kata.feature
|
50
|
+
- features/minitest_spec_kata.feature
|
51
|
+
- features/rspec_kata.feature
|
52
|
+
- features/step_definitions/steps.rb
|
53
|
+
- features/support/env.rb
|
54
|
+
- features/testunit_kata.feature
|
55
|
+
- lib/shuhari.rb
|
56
|
+
- lib/shuhari/app.rb
|
57
|
+
- lib/shuhari/platform.rb
|
58
|
+
- lib/shuhari/platform_gems.rb
|
59
|
+
- lib/shuhari/project_generation.rb
|
60
|
+
- lib/shuhari/version.rb
|
61
|
+
- shuhari.gemspec
|
62
|
+
- templates/base/.rvmrc.tt
|
63
|
+
- templates/base/lib/kata.rb.tt
|
64
|
+
- templates/base/shuhari.yml.tt
|
65
|
+
- templates/cucumber/Gemfile.tt
|
66
|
+
- templates/cucumber/Guardfile
|
67
|
+
- templates/cucumber/features/kata.feature.tt
|
68
|
+
- templates/cucumber/features/step_definitions/steps.rb
|
69
|
+
- templates/cucumber/features/support/env.rb.tt
|
70
|
+
- templates/minitest/Gemfile.tt
|
71
|
+
- templates/minitest/Guardfile
|
72
|
+
- templates/minitest/test/test_helper.rb.tt
|
73
|
+
- templates/minitest/test/test_kata.rb.tt
|
74
|
+
- templates/minitest_spec/Gemfile.tt
|
75
|
+
- templates/minitest_spec/Guardfile
|
76
|
+
- templates/minitest_spec/spec/kata_spec.rb.tt
|
77
|
+
- templates/minitest_spec/spec/spec_helper.rb.tt
|
78
|
+
- templates/rspec/Gemfile.tt
|
79
|
+
- templates/rspec/Guardfile
|
80
|
+
- templates/rspec/spec/kata_spec.rb.tt
|
81
|
+
- templates/rspec/spec/spec_helper.rb.tt
|
82
|
+
- templates/testunit/Gemfile.tt
|
83
|
+
- templates/testunit/Guardfile
|
84
|
+
- templates/testunit/test/kata_test.rb.tt
|
85
|
+
- templates/testunit/test/test_helper.rb.tt
|
86
|
+
homepage: ''
|
87
|
+
licenses: []
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.8.24
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: TDD Kata project generator
|
110
|
+
test_files:
|
111
|
+
- features/cucumber_kata.feature
|
112
|
+
- features/getting_help.feature
|
113
|
+
- features/minitest_kata.feature
|
114
|
+
- features/minitest_spec_kata.feature
|
115
|
+
- features/rspec_kata.feature
|
116
|
+
- features/step_definitions/steps.rb
|
117
|
+
- features/support/env.rb
|
118
|
+
- features/testunit_kata.feature
|
119
|
+
has_rdoc:
|