beet 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/LICENSE +20 -0
- data/README.rdoc +13 -0
- data/Rakefile +59 -0
- data/TODO +17 -0
- data/VERSION +1 -0
- data/beet.gemspec +89 -0
- data/bin/beet +112 -0
- data/features/generating.feature +24 -0
- data/features/step_definitions/beet_steps.rb +7 -0
- data/features/step_definitions/common_steps.rb +172 -0
- data/features/support/common.rb +33 -0
- data/features/support/env.rb +25 -0
- data/lib/beet.rb +10 -0
- data/lib/beet/capistrano.rb +14 -0
- data/lib/beet/execution.rb +50 -0
- data/lib/beet/executor.rb +195 -0
- data/lib/beet/file_system.rb +143 -0
- data/lib/beet/gem_location_map.rb +64 -0
- data/lib/beet/interaction.rb +37 -0
- data/lib/beet/logger.rb +44 -0
- data/lib/beet/rails.rb +146 -0
- data/lib/beet/recipes/passenger/vhost.rb +17 -0
- data/lib/beet/recipes/rack/middleware.rb +17 -0
- data/lib/beet/recipes/rails/authlogic.rb +297 -0
- data/lib/beet/recipes/rails/clean_files.rb +4 -0
- data/lib/beet/recipes/rails/clearance.rb +22 -0
- data/lib/beet/recipes/rails/cms/bcms_blog.rb +21 -0
- data/lib/beet/recipes/rails/cms/bcms_event.rb +24 -0
- data/lib/beet/recipes/rails/css/blueprint.rb +5 -0
- data/lib/beet/recipes/rails/css/reset.rb +10 -0
- data/lib/beet/recipes/rails/db/mysql.rb +42 -0
- data/lib/beet/recipes/rails/db/postgres.rb +52 -0
- data/lib/beet/recipes/rails/git.rb +23 -0
- data/lib/beet/recipes/rails/jquery.rb +11 -0
- data/lib/beet/recipes/rails/rspec.rb +3 -0
- data/lib/beet/recipes/rails/shoulda.rb +1 -0
- data/lib/beet/scm.rb +36 -0
- data/lib/beet/scm/git.rb +15 -0
- data/lib/beet/scm/svn.rb +5 -0
- data/lib/beet/template_location_map.rb +13 -0
- data/test/executor_test.rb +24 -0
- data/test/file_system_test.rb +59 -0
- data/test/test_helper.rb +12 -0
- metadata +110 -0
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Jack Dempsey
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
= beet
|
2
|
+
|
3
|
+
Beet is a simple project generator, with its roots and underlying infrastructure heavily influenced from Rails Templates.
|
4
|
+
|
5
|
+
Please visit the homepage to learn more: http://jackdempsey.github.com/beet
|
6
|
+
|
7
|
+
= How to
|
8
|
+
to work with ruby 1.9 recommend to use wycats-thor
|
9
|
+
example: beet -g new_app --recipes rails/jquery,rails/authlogic,rails/git
|
10
|
+
|
11
|
+
== Copyright
|
12
|
+
|
13
|
+
Copyright (c) 2009 Jack Dempsey. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "beet"
|
8
|
+
gem.summary = %Q{A gem to help with easily generating projects}
|
9
|
+
gem.email = "jack.dempsey@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/jackdempsey/beet"
|
11
|
+
gem.authors = ["Jack Dempsey"]
|
12
|
+
gem.add_dependency "wycats-thor", "= 0.11.5"
|
13
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
end
|
15
|
+
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/*_test.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/*_test.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
if File.exist?('VERSION.yml')
|
48
|
+
config = YAML.load(File.read('VERSION.yml'))
|
49
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
50
|
+
else
|
51
|
+
version = ""
|
52
|
+
end
|
53
|
+
|
54
|
+
rdoc.rdoc_dir = 'rdoc'
|
55
|
+
rdoc.title = "beet_shoulda #{version}"
|
56
|
+
rdoc.rdoc_files.include('README*')
|
57
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
58
|
+
end
|
59
|
+
|
data/TODO
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
* refactor methods in bin/beet to use each other (lots of duplication between generate and just_recipe
|
2
|
+
( maybe just make generate a boolean option rather than a method )
|
3
|
+
* refactor so you can use template names in the recipe calls along with local paths and remote paths
|
4
|
+
|
5
|
+
* fixup places where its obviously just rails stuff, like add_gems
|
6
|
+
* generate command in bin/beet should have executor stuff pulled out of case, ie, it should always run
|
7
|
+
* create a better way to mixin things from rails/whatever as needed inside Beet::Executor
|
8
|
+
|
9
|
+
* figure out if its worth it to use similar step definitions as done in Jeweler for gems that generate stuff
|
10
|
+
and want to verify things worked correctly
|
11
|
+
|
12
|
+
* write some recipes for browsercms
|
13
|
+
|
14
|
+
* work on ubuntu install ideas
|
15
|
+
|
16
|
+
* create a "if gem_exists?('browsercms')" type method
|
17
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.1
|
data/beet.gemspec
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{beet}
|
8
|
+
s.version = "0.3.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jack Dempsey"]
|
12
|
+
s.date = %q{2009-10-24}
|
13
|
+
s.default_executable = %q{beet}
|
14
|
+
s.email = %q{jack.dempsey@gmail.com}
|
15
|
+
s.executables = ["beet"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"TODO",
|
26
|
+
"VERSION",
|
27
|
+
"beet.gemspec",
|
28
|
+
"bin/beet",
|
29
|
+
"features/generating.feature",
|
30
|
+
"features/step_definitions/beet_steps.rb",
|
31
|
+
"features/step_definitions/common_steps.rb",
|
32
|
+
"features/support/common.rb",
|
33
|
+
"features/support/env.rb",
|
34
|
+
"lib/beet.rb",
|
35
|
+
"lib/beet/capistrano.rb",
|
36
|
+
"lib/beet/execution.rb",
|
37
|
+
"lib/beet/executor.rb",
|
38
|
+
"lib/beet/file_system.rb",
|
39
|
+
"lib/beet/gem_location_map.rb",
|
40
|
+
"lib/beet/interaction.rb",
|
41
|
+
"lib/beet/logger.rb",
|
42
|
+
"lib/beet/rails.rb",
|
43
|
+
"lib/beet/recipes/passenger/vhost.rb",
|
44
|
+
"lib/beet/recipes/rack/middleware.rb",
|
45
|
+
"lib/beet/recipes/rails/authlogic.rb",
|
46
|
+
"lib/beet/recipes/rails/clean_files.rb",
|
47
|
+
"lib/beet/recipes/rails/clearance.rb",
|
48
|
+
"lib/beet/recipes/rails/cms/bcms_blog.rb",
|
49
|
+
"lib/beet/recipes/rails/cms/bcms_event.rb",
|
50
|
+
"lib/beet/recipes/rails/css/blueprint.rb",
|
51
|
+
"lib/beet/recipes/rails/css/reset.rb",
|
52
|
+
"lib/beet/recipes/rails/db/mysql.rb",
|
53
|
+
"lib/beet/recipes/rails/db/postgres.rb",
|
54
|
+
"lib/beet/recipes/rails/git.rb",
|
55
|
+
"lib/beet/recipes/rails/jquery.rb",
|
56
|
+
"lib/beet/recipes/rails/rspec.rb",
|
57
|
+
"lib/beet/recipes/rails/shoulda.rb",
|
58
|
+
"lib/beet/scm.rb",
|
59
|
+
"lib/beet/scm/git.rb",
|
60
|
+
"lib/beet/scm/svn.rb",
|
61
|
+
"lib/beet/template_location_map.rb",
|
62
|
+
"test/executor_test.rb",
|
63
|
+
"test/file_system_test.rb",
|
64
|
+
"test/test_helper.rb"
|
65
|
+
]
|
66
|
+
s.homepage = %q{http://github.com/jackdempsey/beet}
|
67
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
68
|
+
s.require_paths = ["lib"]
|
69
|
+
s.rubygems_version = %q{1.3.5}
|
70
|
+
s.summary = %q{A gem to help with easily generating projects}
|
71
|
+
s.test_files = [
|
72
|
+
"test/executor_test.rb",
|
73
|
+
"test/file_system_test.rb",
|
74
|
+
"test/test_helper.rb"
|
75
|
+
]
|
76
|
+
|
77
|
+
if s.respond_to? :specification_version then
|
78
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
79
|
+
s.specification_version = 3
|
80
|
+
|
81
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
82
|
+
s.add_runtime_dependency(%q<wycats-thor>, ["= 0.11.5"])
|
83
|
+
else
|
84
|
+
s.add_dependency(%q<wycats-thor>, ["= 0.11.5"])
|
85
|
+
end
|
86
|
+
else
|
87
|
+
s.add_dependency(%q<wycats-thor>, ["= 0.11.5"])
|
88
|
+
end
|
89
|
+
end
|
data/bin/beet
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'thor'
|
5
|
+
begin
|
6
|
+
if RUBY_VERSION <= '1.8.6'
|
7
|
+
require 'ruby-debug'
|
8
|
+
end
|
9
|
+
rescue LoadError
|
10
|
+
end
|
11
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
12
|
+
require 'beet'
|
13
|
+
require 'pp'
|
14
|
+
|
15
|
+
WIN32 = (RUBY_PLATFORM =~ /win32|mingw|bccwin|cygwin/) rescue nil
|
16
|
+
SUDO = (WIN32 || ENV['SUDOLESS']) ? '': 'sudo '
|
17
|
+
|
18
|
+
class BeetRunner < Thor
|
19
|
+
map "-g" => :generate
|
20
|
+
map "-j" => :just_recipe
|
21
|
+
map "-h" => :help
|
22
|
+
map "-v" => :version
|
23
|
+
map "-l" => :list
|
24
|
+
map "-d" => :display
|
25
|
+
map "--list" => :list
|
26
|
+
map "--display" => :display
|
27
|
+
|
28
|
+
desc 'generate [app_name]', "the main app generate method"
|
29
|
+
method_options %w(recipes -r) => :string, %w(gems -g) => :string, %w(template -t) => :string, %w(save -s) => :string, %w(use -u) => :string
|
30
|
+
def generate(app_name, project_type=:rails)
|
31
|
+
executor = Beet::Executor.new(app_name, options.merge('project_type' => project_type))
|
32
|
+
executor.start
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'just_recipe', "when you just need a recipe"
|
36
|
+
method_options %w(recipes -r) => :string, %w(gems -g) => :string, %w(save -s) => :string, %w(use -u) => :string
|
37
|
+
def just_recipe(app_name='.')
|
38
|
+
executor = Beet::Executor.new(app_name, options.merge('generate' => false))
|
39
|
+
executor.start
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'list', "list what recipes and templates beet knows about"
|
43
|
+
def list
|
44
|
+
paths = []
|
45
|
+
paths << File.dirname(__FILE__) + '/../lib/beet/recipes/**/*.rb'
|
46
|
+
paths << ENV['BEET_RECIPES_DIR'] if ENV['BEET_RECIPES_DIR']
|
47
|
+
recipes = paths.map do |path|
|
48
|
+
Dir.glob(path)
|
49
|
+
end.flatten.compact
|
50
|
+
puts "\nRecipes: (e.g. beet -g app -r rails/git)"
|
51
|
+
pp recipes
|
52
|
+
puts "\nTemplates: (e.g. beet -g app -t bort)"
|
53
|
+
pp TEMPLATE_LOCATIONS.sort.map {|array| array[0] + " => " + array[1]}
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'display', "Display the code for the recipes/templates"
|
57
|
+
method_options %w(recipes -r) => :string, %w(template -t) => :string
|
58
|
+
def display(app_name='.')
|
59
|
+
executor = Beet::Executor.new(app_name,options.merge('generate' => false, 'display' => true))
|
60
|
+
executor.start
|
61
|
+
end
|
62
|
+
|
63
|
+
desc 'version', "the current version of beet"
|
64
|
+
def version
|
65
|
+
version_file = File.dirname(__FILE__) + '/../VERSION'
|
66
|
+
if File.exists?(version_file) and version = File.read(version_file)
|
67
|
+
puts "Beet version: #{version}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
desc 'help', 'help output'
|
72
|
+
def help
|
73
|
+
puts %{
|
74
|
+
Usage: #{$0} /path/to/your/app [options]
|
75
|
+
|
76
|
+
Options:
|
77
|
+
-g, --generate Run the generate command to build a project
|
78
|
+
-j, --just_recipe Run the just_recipe command to only run specified recipes, templates, etc.
|
79
|
+
-d, --display Instead of running, show the template or recipe body
|
80
|
+
|
81
|
+
Beet Info:
|
82
|
+
-v, --version Show the Beet version number and quit.
|
83
|
+
-l, --list Show the various recipes known to Beet and quit.
|
84
|
+
-h, --help Show this help message and quit.
|
85
|
+
|
86
|
+
General Options:
|
87
|
+
|
88
|
+
Description:
|
89
|
+
Beet is used to quickly generate applications.
|
90
|
+
|
91
|
+
Example:
|
92
|
+
beet generate example_app --recipes="rails/authlogic, rails/clean_files, rails/git"
|
93
|
+
|
94
|
+
Same thing but shorter:
|
95
|
+
|
96
|
+
beet -g example_app -r=rails/authlogic,rails/clean_files,rails/git
|
97
|
+
}
|
98
|
+
end
|
99
|
+
end
|
100
|
+
def method_missing(*args)
|
101
|
+
unless @activesupport_required
|
102
|
+
require 'activesupport'
|
103
|
+
@activesupport_required = true
|
104
|
+
m = args.shift
|
105
|
+
send(m, *args)
|
106
|
+
else
|
107
|
+
super
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
BeetRunner.start
|
112
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Feature: Generating Projects
|
2
|
+
In order to reduce the time needed to build new rails apps
|
3
|
+
As a developer
|
4
|
+
I want to generate apps with beet
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given this will run inside a clean "generated_output" directory
|
8
|
+
|
9
|
+
Scenario: Generating a rails app
|
10
|
+
When I run local executable "beet" with arguments "-g rails_app"
|
11
|
+
Then folder "rails_app" is created
|
12
|
+
And "rails_app" should be a rails app
|
13
|
+
|
14
|
+
Scenario: Generating a rails app with rails/git recipe
|
15
|
+
When I run local executable "beet" with arguments "-g rails_app -r rails/git"
|
16
|
+
Then folder "rails_app" is created
|
17
|
+
And "rails_app" should be a rails app
|
18
|
+
And folder "rails_app/.git" is created
|
19
|
+
|
20
|
+
Scenario: Generating a rails app then running rails/git recipe separately
|
21
|
+
When I run local executable "beet" with arguments "-g rails_app"
|
22
|
+
And inside "rails_app" I run local executable "beet" with arguments "-j -r rails/git"
|
23
|
+
And folder "rails_app/.git" is created"
|
24
|
+
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Then /^"(.*)" should be a rails app$/ do |directory|
|
2
|
+
File.exists?(File.join(@active_project_folder, 'app'))
|
3
|
+
File.exists?(File.join(@active_project_folder, 'config'))
|
4
|
+
File.exists?(File.join(@active_project_folder, 'db'))
|
5
|
+
File.exists?(File.join(@active_project_folder, 'public'))
|
6
|
+
File.exists?(File.join(@active_project_folder, 'vendor'))
|
7
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
Given /this will run inside a clean "(.*)" directory/ do |directory|
|
2
|
+
@active_project_folder = File.expand_path File.join(File.dirname(__FILE__), '..', '..', directory)
|
3
|
+
FileUtils.rm_rf @active_project_folder
|
4
|
+
FileUtils.mkdir_p @active_project_folder
|
5
|
+
end
|
6
|
+
|
7
|
+
Given /^env variable \$([\w_]+) set to "(.*)"/ do |env_var, value|
|
8
|
+
ENV[env_var] = value
|
9
|
+
end
|
10
|
+
|
11
|
+
Given /"(.*)" folder is deleted/ do |folder|
|
12
|
+
in_project_folder { FileUtils.rm_rf folder }
|
13
|
+
end
|
14
|
+
|
15
|
+
When /^inside "(.*)" I run local executable "(.*)" with arguments "(.*)"$/ do |directory, executable, arguments|
|
16
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
17
|
+
executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
|
18
|
+
in_project_subfolder(directory) do
|
19
|
+
system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
When /^I invoke "(.*)" generator with arguments "(.*)"$/ do |generator, arguments|
|
24
|
+
@stdout = StringIO.new
|
25
|
+
in_project_folder do
|
26
|
+
if Object.const_defined?("APP_ROOT")
|
27
|
+
APP_ROOT.replace(FileUtils.pwd)
|
28
|
+
else
|
29
|
+
APP_ROOT = FileUtils.pwd
|
30
|
+
end
|
31
|
+
run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
|
32
|
+
end
|
33
|
+
File.open(File.join(@tmp_root, "generator.out"), "w") do |f|
|
34
|
+
@stdout.rewind
|
35
|
+
f << @stdout.read
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
When /^I run executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
40
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
41
|
+
in_project_folder do
|
42
|
+
system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
When /^I run project executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
47
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
48
|
+
in_project_folder do
|
49
|
+
system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
When /^I run local executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
54
|
+
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
55
|
+
executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
|
56
|
+
in_project_folder do
|
57
|
+
`ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}`
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
When /^I invoke task "rake (.*)"/ do |task|
|
62
|
+
@stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
|
63
|
+
in_project_folder do
|
64
|
+
system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
Then /^folder "(.*)" (is|is not) created/ do |folder, is|
|
69
|
+
in_project_folder do
|
70
|
+
File.exists?(folder).should(is == 'is' ? be_true : be_false)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
Then /^file "(.*)" (is|is not) created/ do |file, is|
|
75
|
+
in_project_folder do
|
76
|
+
File.exists?(file).should(is == 'is' ? be_true : be_false)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
Then /^file with name matching "(.*)" is created/ do |pattern|
|
81
|
+
in_project_folder do
|
82
|
+
Dir[pattern].should_not be_empty
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
Then /^file "(.*)" contents (does|does not) match \/(.*)\// do |file, does, regex|
|
87
|
+
in_project_folder do
|
88
|
+
actual_output = File.read(file)
|
89
|
+
(does == 'does') ?
|
90
|
+
actual_output.should(match(/#{regex}/)) :
|
91
|
+
actual_output.should_not(match(/#{regex}/))
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
Then /gem file "(.*)" and generated file "(.*)" should be the same/ do |gem_file, project_file|
|
96
|
+
File.exists?(gem_file).should be_true
|
97
|
+
File.exists?(project_file).should be_true
|
98
|
+
gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
|
99
|
+
project_file_contents = File.read(File.join(@active_project_folder, project_file))
|
100
|
+
project_file_contents.should == gem_file_contents
|
101
|
+
end
|
102
|
+
|
103
|
+
Then /^(does|does not) invoke generator "(.*)"$/ do |does_invoke, generator|
|
104
|
+
actual_output = File.read(@stdout)
|
105
|
+
does_invoke == "does" ?
|
106
|
+
actual_output.should(match(/dependency\s+#{generator}/)) :
|
107
|
+
actual_output.should_not(match(/dependency\s+#{generator}/))
|
108
|
+
end
|
109
|
+
|
110
|
+
Then /I should see help option "(.*)"/ do |opt|
|
111
|
+
actual_output = File.read(@stdout)
|
112
|
+
actual_output.should match(/#{opt}/)
|
113
|
+
end
|
114
|
+
|
115
|
+
Then /^I should see$/ do |text|
|
116
|
+
actual_output = File.read(@stdout)
|
117
|
+
actual_output.should contain(text)
|
118
|
+
end
|
119
|
+
|
120
|
+
Then /^I should not see$/ do |text|
|
121
|
+
actual_output = File.read(@stdout)
|
122
|
+
actual_output.should_not contain(text)
|
123
|
+
end
|
124
|
+
|
125
|
+
Then /^I should see exactly$/ do |text|
|
126
|
+
actual_output = File.read(@stdout)
|
127
|
+
actual_output.should == text
|
128
|
+
end
|
129
|
+
|
130
|
+
Then /^I should see all (\d+) tests pass/ do |expected_test_count|
|
131
|
+
expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
|
132
|
+
actual_output = File.read(@stdout)
|
133
|
+
actual_output.should match(expected)
|
134
|
+
end
|
135
|
+
|
136
|
+
Then /^I should see all (\d+) examples pass/ do |expected_test_count|
|
137
|
+
expected = %r{^#{expected_test_count} examples?, 0 failures}
|
138
|
+
actual_output = File.read(@stdout)
|
139
|
+
actual_output.should match(expected)
|
140
|
+
end
|
141
|
+
|
142
|
+
Then /^yaml file "(.*)" contains (\{.*\})/ do |file, yaml|
|
143
|
+
in_project_folder do
|
144
|
+
yaml = eval yaml
|
145
|
+
YAML.load(File.read(file)).should == yaml
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
Then /^Rakefile can display tasks successfully/ do
|
150
|
+
@stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
|
151
|
+
in_project_folder do
|
152
|
+
system "rake -T > #{@stdout} 2> #{@stdout}"
|
153
|
+
end
|
154
|
+
actual_output = File.read(@stdout)
|
155
|
+
actual_output.should match(/^rake\s+\w+\s+#\s.*/)
|
156
|
+
end
|
157
|
+
|
158
|
+
Then /^task "rake (.*)" is executed successfully/ do |task|
|
159
|
+
@stdout.should_not be_nil
|
160
|
+
actual_output = File.read(@stdout)
|
161
|
+
actual_output.should_not match(/^Don't know how to build task '#{task}'/)
|
162
|
+
actual_output.should_not match(/Error/i)
|
163
|
+
end
|
164
|
+
|
165
|
+
Then /^gem spec key "(.*)" contains \/(.*)\// do |key, regex|
|
166
|
+
in_project_folder do
|
167
|
+
gem_file = Dir["pkg/*.gem"].first
|
168
|
+
gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
|
169
|
+
spec_value = gem_spec.send(key.to_sym)
|
170
|
+
spec_value.to_s.should match(/#{regex}/)
|
171
|
+
end
|
172
|
+
end
|