whtt-eric-beet 0.6.10

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.
Files changed (72) hide show
  1. data/Gemfile +12 -0
  2. data/Gemfile.lock +25 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +13 -0
  5. data/Rakefile +59 -0
  6. data/TODO +25 -0
  7. data/VERSION +1 -0
  8. data/bin/beet +114 -0
  9. data/features/generating.feature +24 -0
  10. data/features/step_definitions/beet_steps.rb +7 -0
  11. data/features/step_definitions/common_steps.rb +172 -0
  12. data/features/support/common.rb +33 -0
  13. data/features/support/env.rb +25 -0
  14. data/lib/beet.rb +13 -0
  15. data/lib/beet/capistrano.rb +14 -0
  16. data/lib/beet/command_execution.rb +56 -0
  17. data/lib/beet/executor.rb +236 -0
  18. data/lib/beet/file_system.rb +163 -0
  19. data/lib/beet/files/swfupload/images/cancelbutton.gif +0 -0
  20. data/lib/beet/files/swfupload/images/header-bg.jpg +0 -0
  21. data/lib/beet/files/swfupload/images/logo.gif +0 -0
  22. data/lib/beet/files/swfupload/js/handlers.js +290 -0
  23. data/lib/beet/gem_location_map.rb +65 -0
  24. data/lib/beet/interaction.rb +47 -0
  25. data/lib/beet/logger.rb +44 -0
  26. data/lib/beet/rails.rb +175 -0
  27. data/lib/beet/recipes/passenger/vhost.rb +17 -0
  28. data/lib/beet/recipes/rack/middleware.rb +17 -0
  29. data/lib/beet/recipes/rails/auth/authlogic.rb +302 -0
  30. data/lib/beet/recipes/rails/auth/clearance.rb +22 -0
  31. data/lib/beet/recipes/rails/auth/devise.rb +22 -0
  32. data/lib/beet/recipes/rails/clean_files.rb +4 -0
  33. data/lib/beet/recipes/rails/cms/bcms_blog.rb +21 -0
  34. data/lib/beet/recipes/rails/cms/bcms_event.rb +24 -0
  35. data/lib/beet/recipes/rails/css/blueprint.rb +5 -0
  36. data/lib/beet/recipes/rails/css/compass.rb +35 -0
  37. data/lib/beet/recipes/rails/css/nifty_layout.rb +5 -0
  38. data/lib/beet/recipes/rails/css/reset.rb +10 -0
  39. data/lib/beet/recipes/rails/db/mongo.rb +57 -0
  40. data/lib/beet/recipes/rails/db/mysql.rb +47 -0
  41. data/lib/beet/recipes/rails/db/postgres.rb +52 -0
  42. data/lib/beet/recipes/rails/git.rb +23 -0
  43. data/lib/beet/recipes/rails/jquery.rb +11 -0
  44. data/lib/beet/recipes/rails/swfupload.rb +305 -0
  45. data/lib/beet/recipes/rails/testing/rspec.rb +3 -0
  46. data/lib/beet/recipes/rails/testing/shoulda.rb +1 -0
  47. data/lib/beet/recipes/rails3/admin_interface/active_scaffold.rb +10 -0
  48. data/lib/beet/recipes/rails3/admin_interface/rails_admin.rb +9 -0
  49. data/lib/beet/recipes/rails3/auth/devise.rb +17 -0
  50. data/lib/beet/recipes/rails3/clean_files.rb +3 -0
  51. data/lib/beet/recipes/rails3/css/boilerplate.rb +41 -0
  52. data/lib/beet/recipes/rails3/css/reset.rb +10 -0
  53. data/lib/beet/recipes/rails3/css/sass.rb +3 -0
  54. data/lib/beet/recipes/rails3/db/mysql.rb +35 -0
  55. data/lib/beet/recipes/rails3/file_uploads/paperclip.rb +29 -0
  56. data/lib/beet/recipes/rails3/git.rb +16 -0
  57. data/lib/beet/recipes/rails3/jammit.rb +26 -0
  58. data/lib/beet/recipes/rails3/js/jquery.rb +12 -0
  59. data/lib/beet/recipes/rails3/markup/haml.rb +3 -0
  60. data/lib/beet/recipes/rails3/testing/cucumber.rb +19 -0
  61. data/lib/beet/recipes/rails3/testing/rspec.rb +40 -0
  62. data/lib/beet/recipes/standalone/hades.rb +61 -0
  63. data/lib/beet/recipes/system/rvmrc.rb +15 -0
  64. data/lib/beet/scm.rb +36 -0
  65. data/lib/beet/scm/git.rb +15 -0
  66. data/lib/beet/scm/svn.rb +5 -0
  67. data/lib/beet/template_location_map.rb +15 -0
  68. data/test/executor_test.rb +24 -0
  69. data/test/file_system_test.rb +59 -0
  70. data/test/test_helper.rb +12 -0
  71. data/whtt-eric-beet.gemspec +120 -0
  72. metadata +203 -0
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ platforms :ruby do
4
+ if RUBY_VERSION < '1.9'
5
+ gem "ruby-debug", ">= 0.10.3"
6
+ else
7
+ gem "ruby-debug19", "~> 0.11.6"
8
+ end
9
+ end
10
+
11
+ gem "activesupport", "~> 3.0.0"
12
+ gem "thor", "~> 0.14.0"
@@ -0,0 +1,25 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ archive-tar-minitar (0.5.2)
5
+ columnize (0.3.1)
6
+ linecache19 (0.5.11)
7
+ ruby_core_source (>= 0.1.4)
8
+ ruby-debug-base19 (0.11.24)
9
+ columnize (>= 0.3.1)
10
+ linecache19 (>= 0.5.11)
11
+ ruby_core_source (>= 0.1.4)
12
+ ruby-debug19 (0.11.6)
13
+ columnize (>= 0.3.1)
14
+ linecache19 (>= 0.5.11)
15
+ ruby-debug-base19 (>= 0.11.19)
16
+ ruby_core_source (0.1.4)
17
+ archive-tar-minitar (>= 0.5.2)
18
+ thor (0.14.0)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ ruby-debug19 (~> 0.11.6)
25
+ thor (~> 0.14.0)
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.
@@ -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
+ == Copyright
8
+
9
+ Copyright (c) 2010 Jack Dempsey. See LICENSE for details.
10
+
11
+ == Other Stuff
12
+
13
+ Some additional recipes inspired by Miles Sterrett's {Rails 3 Template}[https://github.com/mileszs/rails3_template]
@@ -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 "thor", "~> 0.14.0"
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,25 @@
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
+ * create a "if gem_exists?('browsercms')" type method
13
+ * perhaps repurpose the search_for_rails_2 method to search for any installed gem
14
+
15
+ * add ability to set --prefix rails3 so you're not typing rails3/auth/devise, rails3/js/jquery, etc, just
16
+ beet -g foo --prefix rails3 -r auth/devise, js/jquery
17
+ * in fact, maybe make a .beetrc file where you can set a prefix permanently.
18
+
19
+ * use aruba to test beet - http://github.com/aslakhellesoy/aruba
20
+
21
+ * write recipes for
22
+ * multiple file uploads
23
+ * facebook connect with devise - http://stackoverflow.com/questions/3580557/rails-3-using-devise-how-to-allow-someone-to-log-in-using-their-facebook-account
24
+
25
+ * add in a "recipe not found: #{recipe}" so when things don't run it doesn't silently fail
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.6.10
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'thor'
5
+ begin
6
+ require 'ruby-debug'
7
+ rescue LoadError
8
+ end
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'beet'
11
+ require 'pp'
12
+
13
+ WIN32 = (RUBY_PLATFORM =~ /win32|mingw|bccwin|cygwin/) rescue nil
14
+ SUDO = (WIN32 || ENV['SUDOLESS']) ? '': 'sudo '
15
+
16
+ class BeetRunner < Thor
17
+ map "-g" => :generate
18
+ map "-j" => :just_recipe
19
+ map "-h" => :help
20
+ map "-v" => :version
21
+ map "-l" => :list
22
+ map "-d" => :display
23
+ map "--list" => :list
24
+ map "--display" => :display
25
+
26
+ desc 'generate [app_name]', "the main app generate method"
27
+ method_options %w(recipes -r) => :string, %w(project_type -p) => :project_type, %w(gems) => :string, %w(template -t) => :string, %w(save -s) => :string, %w(use -u) => :string
28
+ def generate(app_name)
29
+ executor = Beet::Executor.new(app_name, options)
30
+ executor.start
31
+ end
32
+
33
+ desc 'just_recipe', "when you just need a recipe"
34
+ method_options %w(recipes -r) => :string, %w(gems) => :string, %w(save -s) => :string, %w(use -u) => :string
35
+ def just_recipe(app_name='.')
36
+ executor = Beet::Executor.new(app_name, options.merge('generate' => false))
37
+ executor.start
38
+ end
39
+
40
+ desc 'list', "list what recipes and templates beet knows about"
41
+ method_options %w(templates -t) => :string
42
+ def list(pattern=nil)
43
+ paths = []
44
+ paths << File.dirname(__FILE__) + '/../lib/beet/recipes/**/*.rb'
45
+ paths << ENV['BEET_RECIPES_DIR'] + '/**/*.rb' if ENV['BEET_RECIPES_DIR']
46
+ recipes = paths.map do |path|
47
+ Dir.glob(path)
48
+ end.flatten.compact
49
+
50
+ recipes = recipes.grep(Regexp.new(pattern)) if pattern
51
+
52
+ puts "\nRecipes: (e.g. beet -g app -r rails/git)"
53
+ pp recipes
54
+
55
+ if options[:templates]
56
+ puts "\nTemplates: (e.g. beet -g app -t bort)"
57
+ pp TEMPLATE_LOCATIONS.sort.map {|array| array[0] + " => " + array[1]}
58
+ end
59
+
60
+ puts "\nSaved Configurations:"
61
+ print `cat #{ENV['HOME']}/.beet.yml`
62
+ end
63
+
64
+ desc 'display', "Display the code for the recipes/templates"
65
+ method_options %w(recipes -r) => :string, %w(template -t) => :string
66
+ def display(app_name='.')
67
+ executor = Beet::Executor.new(app_name,options.merge('generate' => false, 'display' => true))
68
+ executor.start
69
+ end
70
+
71
+ desc 'version', "the current version of beet"
72
+ def version
73
+ version_file = File.dirname(__FILE__) + '/../VERSION'
74
+ if File.exists?(version_file) and version = File.read(version_file)
75
+ puts "Beet version: #{version}"
76
+ end
77
+ end
78
+
79
+ desc 'help', 'help output'
80
+ def help
81
+ puts %{
82
+ Usage: beet /path/to/your/app [options]
83
+
84
+ Options:
85
+ -g, --generate Run the generate command to build a project
86
+ -j, --just_recipe Run the just_recipe command to only run specified recipes, templates, etc.
87
+ -d, --display Instead of running, show the template or recipe body
88
+ -r, --recipes Recipes to use
89
+ -s, --save Save current set of options
90
+ -u, --use Use a saved set of options
91
+ --gems Gems to include
92
+
93
+ Beet Info:
94
+ -v, --version Show the Beet version number and quit.
95
+ -l, --list [text] Show the various recipes known to Beet and quit. Pass in [text] to limit output to recipes that include [text]
96
+ -h, --help Show this help message and quit.
97
+
98
+ General Options:
99
+
100
+ Description:
101
+ Beet is used to quickly generate applications.
102
+
103
+ Example:
104
+ beet generate example_app --recipes="rails3/auth/devise, rails3/clean_files, rails3/git"
105
+
106
+ Same thing but shorter:
107
+
108
+ beet -g example_app -r=rails3/auth/devise,rails3/clean_files,rails3/git
109
+ }
110
+ end
111
+ end
112
+
113
+ BeetRunner.start
114
+
@@ -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