newgem 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -0
- data/Manifest.txt +9 -1
- data/Rakefile +2 -1
- data/TODO.markdown +9 -3
- data/app_generators/newgem/newgem_generator.rb +5 -1
- data/app_generators/newgem/templates/README.rdoc +1 -1
- data/app_generators/newgem/templates/Rakefile +2 -1
- data/app_generators/newgem_simple/templates/Rakefile +1 -1
- data/bin/newgem +1 -1
- data/features/development.feature +5 -5
- data/features/executable_generator.feature +46 -29
- data/features/extconf.feature +27 -26
- data/features/install_cucumber.feature +29 -19
- data/features/install_website.feature +6 -6
- data/features/newgem_cli.feature +86 -42
- data/features/rubygem_tasks.feature +26 -18
- data/features/step_definitions/cli_steps.rb +22 -17
- data/features/step_definitions/common_steps.rb +45 -67
- data/features/step_definitions/rubygems_steps.rb +1 -1
- data/features/support/cli.rb +8 -0
- data/features/support/common.rb +29 -0
- data/features/support/env.rb +2 -7
- data/features/support/matchers.rb +11 -0
- data/lib/newgem.rb +1 -1
- data/lib/newgem/rubyforge-ext.rb +1 -1
- data/newgem_generators/install_website/install_website_generator.rb +1 -1
- data/newgem_generators/install_website/templates/features/website.feature +4 -4
- data/newgem_theme_generators/long_box_theme/long_box_theme_generator.rb +1 -1
- data/rubygems_generators/executable/executable_generator.rb +1 -1
- data/rubygems_generators/executable/templates/spec/cli_spec.rb.erb +2 -2
- data/rubygems_generators/executable/templates/test/test_cli.rb.erb +2 -2
- data/rubygems_generators/extconf/extconf_generator.rb +1 -1
- data/rubygems_generators/install_cucumber/install_cucumber_generator.rb +2 -0
- data/rubygems_generators/install_cucumber/templates/features/development.feature +5 -5
- data/rubygems_generators/install_cucumber/templates/features/step_definitions/common_steps.rb +45 -67
- data/rubygems_generators/install_cucumber/templates/features/support/common.rb +29 -0
- data/rubygems_generators/install_rspec/install_rspec_generator.rb +1 -1
- data/rubygems_generators/install_rspec/templates/spec.rb +1 -1
- data/rubygems_generators/install_rspec/templates/spec/spec_helper.rb +1 -1
- data/rubygems_generators/install_rspec/templates/tasks/rspec.rake +1 -1
- data/rubygems_generators/install_shoulda/USAGE +5 -0
- data/rubygems_generators/install_shoulda/install_shoulda_generator.rb +35 -0
- data/rubygems_generators/install_shoulda/templates/tasks/shoulda.rake +15 -0
- data/rubygems_generators/install_shoulda/templates/test/test.rb +13 -0
- data/rubygems_generators/install_shoulda/templates/test/test_helper.rb +9 -0
- data/rubygems_generators/install_test_unit/install_test_unit_generator.rb +1 -1
- data/script/destroy +1 -1
- data/script/generate +1 -1
- data/test/test_generator_helper.rb +1 -1
- data/website/index.html +2 -2
- data/website/rubyforge.html +2 -2
- metadata +21 -6
- data/features/expected_outputs/newgem.out +0 -27
@@ -0,0 +1,11 @@
|
|
1
|
+
module Matchers
|
2
|
+
def contain(expected)
|
3
|
+
simple_matcher("contain #{expected.inspect}") do |given, matcher|
|
4
|
+
matcher.failure_message = "expected #{given.inspect} to contain #{expected.inspect}"
|
5
|
+
matcher.negative_failure_message = "expected #{given.inspect} not to contain #{expected.inspect}"
|
6
|
+
given.index expected
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
World(Matchers)
|
data/lib/newgem.rb
CHANGED
data/lib/newgem/rubyforge-ext.rb
CHANGED
@@ -17,7 +17,7 @@ class InstallWebsiteGenerator < RubiGen::Base
|
|
17
17
|
super
|
18
18
|
@destination_root = File.expand_path(destination_root)
|
19
19
|
@gem_name = base_name
|
20
|
-
@module_name = @gem_name.
|
20
|
+
@module_name = @gem_name.gsub('-','_').camelize
|
21
21
|
@rubyforge_username = ENV['RUBYFORGE_USERNAME'].nil? || ENV['RUBYFORGE_USERNAME'].empty? ? 'unknown' : ENV['RUBYFORGE_USERNAME']
|
22
22
|
extract_options
|
23
23
|
end
|
@@ -7,8 +7,8 @@ Feature: Can deploy a website to a remote server via rsycn
|
|
7
7
|
Given copy this project for test
|
8
8
|
Given a safe folder for dummy deployment
|
9
9
|
Given project website configuration for safe folder on local machine
|
10
|
-
When task
|
11
|
-
Then file
|
12
|
-
Then remote file
|
13
|
-
Then remote folder
|
10
|
+
When I invoke task "rake website"
|
11
|
+
Then file "website/index.html" is created
|
12
|
+
Then remote file "index.html" is created after local rsync
|
13
|
+
Then remote folder "rdoc" is created after local rsync
|
14
14
|
|
@@ -11,7 +11,7 @@ class ExecutableGenerator < RubiGen::Base
|
|
11
11
|
super
|
12
12
|
usage if args.empty?
|
13
13
|
@bin_name = args.shift
|
14
|
-
@module_name = @bin_name.
|
14
|
+
@module_name = @bin_name.gsub('-','_').camelize
|
15
15
|
@project_name = File.basename(File.expand_path(destination_root))
|
16
16
|
extract_options
|
17
17
|
end
|
@@ -9,7 +9,7 @@ describe <%= module_name %>::CLI, "execute" do
|
|
9
9
|
@stdout = @stdout_io.read
|
10
10
|
end
|
11
11
|
|
12
|
-
it "should
|
13
|
-
@stdout.
|
12
|
+
it "should print default output" do
|
13
|
+
@stdout.should =~ /To update this executable/
|
14
14
|
end
|
15
15
|
end
|
@@ -8,7 +8,7 @@ class Test<%= module_name %>Cli < Test::Unit::TestCase
|
|
8
8
|
@stdout = @stdout_io.read
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def test_print_default_output
|
12
|
+
assert_match(/To update this executable/, @stdout)
|
13
13
|
end
|
14
14
|
end
|
@@ -21,6 +21,8 @@ class InstallCucumberGenerator < RubiGen::Base
|
|
21
21
|
m.file 'features/development.feature', 'features/development.feature'
|
22
22
|
m.file 'features/step_definitions/common_steps.rb', 'features/step_definitions/common_steps.rb'
|
23
23
|
m.template 'features/support/env.rb.erb', 'features/support/env.rb'
|
24
|
+
m.file 'features/support/common.rb', 'features/support/common.rb'
|
25
|
+
m.file 'features/support/matchers.rb', 'features/support/matchers.rb'
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
@@ -6,8 +6,8 @@ Feature: Development processes of newgem itself (rake tasks)
|
|
6
6
|
|
7
7
|
Scenario: Generate RubyGem
|
8
8
|
Given this project is active project folder
|
9
|
-
And
|
10
|
-
When task
|
11
|
-
Then folder
|
12
|
-
And file with name matching
|
13
|
-
And gem spec key
|
9
|
+
And "pkg" folder is deleted
|
10
|
+
When I invoke task "rake gem"
|
11
|
+
Then folder "pkg" is created
|
12
|
+
And file with name matching "pkg/*.gem" is created else you should run "rake manifest" to fix this
|
13
|
+
And gem spec key "rdoc_options" contains /--mainREADME.rdoc/
|
data/rubygems_generators/install_cucumber/templates/features/step_definitions/common_steps.rb
CHANGED
@@ -1,51 +1,27 @@
|
|
1
|
-
|
2
|
-
project_folder = @active_project_folder || @tmp_root
|
3
|
-
FileUtils.chdir(project_folder, &block)
|
4
|
-
end
|
5
|
-
|
6
|
-
def in_home_folder(&block)
|
7
|
-
FileUtils.chdir(@home_path, &block)
|
8
|
-
end
|
9
|
-
|
10
|
-
Given %r{^a safe folder} do
|
1
|
+
Given /^a safe folder/ do
|
11
2
|
FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp"
|
12
3
|
FileUtils.mkdir_p @tmp_root
|
13
4
|
FileUtils.mkdir_p @home_path = File.expand_path(File.join(@tmp_root, "home"))
|
14
5
|
@lib_path = File.expand_path(File.dirname(__FILE__) + '/../../lib')
|
15
|
-
Given
|
6
|
+
Given %Q{env variable $HOME set to "#{@home_path}"}
|
16
7
|
end
|
17
8
|
|
18
|
-
Given
|
9
|
+
Given /^this project is active project folder/ do
|
19
10
|
Given "a safe folder"
|
20
11
|
@active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
|
21
12
|
end
|
22
13
|
|
23
|
-
Given
|
14
|
+
Given /^env variable \$([\w_]+) set to "(.*)"/ do |env_var, value|
|
24
15
|
ENV[env_var] = value
|
25
16
|
end
|
26
17
|
|
27
|
-
|
28
|
-
|
29
|
-
File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
|
30
|
-
f << "$:.unshift('#{@lib_path}')\n"
|
31
|
-
f << rakefile
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def setup_active_project_folder project_name
|
36
|
-
@active_project_folder = File.join(@tmp_root, project_name)
|
37
|
-
@project_name = project_name
|
38
|
-
end
|
39
|
-
|
40
|
-
Given %r{'(.*)' folder is deleted} do |folder|
|
41
|
-
in_project_folder do
|
42
|
-
FileUtils.rm_rf folder
|
43
|
-
end
|
18
|
+
Given /"(.*)" folder is deleted/ do |folder|
|
19
|
+
in_project_folder { FileUtils.rm_rf folder }
|
44
20
|
end
|
45
21
|
|
46
|
-
When
|
22
|
+
When /^I invoke "(.*)" generator with arguments "(.*)"$/ do |generator, arguments|
|
47
23
|
@stdout = StringIO.new
|
48
|
-
|
24
|
+
in_project_folder do
|
49
25
|
if Object.const_defined?("APP_ROOT")
|
50
26
|
APP_ROOT.replace(FileUtils.pwd)
|
51
27
|
else
|
@@ -59,21 +35,21 @@ When %r{^'(.*)' generator is invoked with arguments '(.*)'$} do |generator, argu
|
|
59
35
|
end
|
60
36
|
end
|
61
37
|
|
62
|
-
When
|
38
|
+
When /^I run executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
63
39
|
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
64
40
|
in_project_folder do
|
65
41
|
system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
66
42
|
end
|
67
43
|
end
|
68
44
|
|
69
|
-
When
|
45
|
+
When /^I run project executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
70
46
|
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
71
47
|
in_project_folder do
|
72
48
|
system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
73
49
|
end
|
74
50
|
end
|
75
51
|
|
76
|
-
When
|
52
|
+
When /^I run local executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
77
53
|
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
78
54
|
executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
|
79
55
|
in_project_folder do
|
@@ -81,32 +57,41 @@ When %r{run local executable '(.*)' with arguments '(.*)'} do |executable, argum
|
|
81
57
|
end
|
82
58
|
end
|
83
59
|
|
84
|
-
When
|
60
|
+
When /^I invoke task "rake (.*)"/ do |task|
|
85
61
|
@stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
|
86
|
-
|
62
|
+
in_project_folder do
|
87
63
|
system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
|
88
64
|
end
|
89
65
|
end
|
90
66
|
|
91
|
-
Then
|
67
|
+
Then /^folder "(.*)" (is|is not) created/ do |folder, is|
|
92
68
|
in_project_folder do
|
93
69
|
File.exists?(folder).should(is == 'is' ? be_true : be_false)
|
94
70
|
end
|
95
71
|
end
|
96
72
|
|
97
|
-
Then
|
73
|
+
Then /^file "(.*)" (is|is not) created/ do |file, is|
|
98
74
|
in_project_folder do
|
99
75
|
File.exists?(file).should(is == 'is' ? be_true : be_false)
|
100
76
|
end
|
101
77
|
end
|
102
78
|
|
103
|
-
Then
|
79
|
+
Then /^file with name matching "(.*)" is created/ do |pattern|
|
104
80
|
in_project_folder do
|
105
81
|
Dir[pattern].should_not be_empty
|
106
82
|
end
|
107
83
|
end
|
108
84
|
|
109
|
-
Then
|
85
|
+
Then /^file "(.*)" contents (does|does not) match \/(.*)\// do |file, does, regex|
|
86
|
+
in_project_folder do
|
87
|
+
actual_output = File.read(file)
|
88
|
+
(does == 'does') ?
|
89
|
+
actual_output.should(match(/#{regex}/)) :
|
90
|
+
actual_output.should_not(match(/#{regex}/))
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
Then /gem file "(.*)" and generated file "(.*)" should be the same/ do |gem_file, project_file|
|
110
95
|
File.exists?(gem_file).should be_true
|
111
96
|
File.exists?(project_file).should be_true
|
112
97
|
gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
|
@@ -114,77 +99,70 @@ Then %r{gem file '(.*)' and generated file '(.*)' should be the same} do |gem_fi
|
|
114
99
|
project_file_contents.should == gem_file_contents
|
115
100
|
end
|
116
101
|
|
117
|
-
Then
|
118
|
-
expected_output = File.read(File.join(File.dirname(__FILE__) + "/../expected_outputs", file))
|
119
|
-
actual_output = File.read(@stdout)
|
120
|
-
actual_output.should == expected_output
|
121
|
-
end
|
122
|
-
|
123
|
-
Then %r{^(does|does not) invoke generator '(.*)'$} do |does_invoke, generator|
|
102
|
+
Then /^(does|does not) invoke generator "(.*)"$/ do |does_invoke, generator|
|
124
103
|
actual_output = File.read(@stdout)
|
125
104
|
does_invoke == "does" ?
|
126
105
|
actual_output.should(match(/dependency\s+#{generator}/)) :
|
127
106
|
actual_output.should_not(match(/dependency\s+#{generator}/))
|
128
107
|
end
|
129
108
|
|
130
|
-
Then
|
109
|
+
Then /help options "(.*)" and "(.*)" are displayed/ do |opt1, opt2|
|
131
110
|
actual_output = File.read(@stdout)
|
132
111
|
actual_output.should match(/#{opt1}/)
|
133
112
|
actual_output.should match(/#{opt2}/)
|
134
113
|
end
|
135
114
|
|
136
|
-
Then
|
115
|
+
Then /^I should see$/ do |text|
|
137
116
|
actual_output = File.read(@stdout)
|
138
|
-
(
|
139
|
-
actual_output.should(match(/#{regex}/)) :
|
140
|
-
actual_output.should_not(match(/#{regex}/))
|
117
|
+
actual_output.should contain(text)
|
141
118
|
end
|
142
119
|
|
143
|
-
Then
|
144
|
-
|
145
|
-
|
146
|
-
(does == 'does') ?
|
147
|
-
actual_output.should(match(/#{regex}/)) :
|
148
|
-
actual_output.should_not(match(/#{regex}/))
|
149
|
-
end
|
120
|
+
Then /^I should not see$/ do |text|
|
121
|
+
actual_output = File.read(@stdout)
|
122
|
+
actual_output.should_not contain(text)
|
150
123
|
end
|
151
124
|
|
152
|
-
Then
|
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|
|
153
131
|
expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
|
154
132
|
actual_output = File.read(@stdout)
|
155
133
|
actual_output.should match(expected)
|
156
134
|
end
|
157
135
|
|
158
|
-
Then
|
136
|
+
Then /^I should see all (\d+) examples pass/ do |expected_test_count|
|
159
137
|
expected = %r{^#{expected_test_count} examples?, 0 failures}
|
160
138
|
actual_output = File.read(@stdout)
|
161
139
|
actual_output.should match(expected)
|
162
140
|
end
|
163
141
|
|
164
|
-
Then
|
142
|
+
Then /^yaml file "(.*)" contains (\{.*\})/ do |file, yaml|
|
165
143
|
in_project_folder do
|
166
144
|
yaml = eval yaml
|
167
145
|
YAML.load(File.read(file)).should == yaml
|
168
146
|
end
|
169
147
|
end
|
170
148
|
|
171
|
-
Then
|
149
|
+
Then /^Rakefile can display tasks successfully/ do
|
172
150
|
@stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
|
173
|
-
|
151
|
+
in_project_folder do
|
174
152
|
system "rake -T > #{@stdout} 2> #{@stdout}"
|
175
153
|
end
|
176
154
|
actual_output = File.read(@stdout)
|
177
155
|
actual_output.should match(/^rake\s+\w+\s+#\s.*/)
|
178
156
|
end
|
179
157
|
|
180
|
-
Then
|
158
|
+
Then /^task "rake (.*)" is executed successfully/ do |task|
|
181
159
|
@stdout.should_not be_nil
|
182
160
|
actual_output = File.read(@stdout)
|
183
161
|
actual_output.should_not match(/^Don't know how to build task '#{task}'/)
|
184
162
|
actual_output.should_not match(/Error/i)
|
185
163
|
end
|
186
164
|
|
187
|
-
Then
|
165
|
+
Then /^gem spec key "(.*)" contains \/(.*)\// do |key, regex|
|
188
166
|
in_project_folder do
|
189
167
|
gem_file = Dir["pkg/*.gem"].first
|
190
168
|
gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module CommonHelpers
|
2
|
+
def in_tmp_folder(&block)
|
3
|
+
FileUtils.chdir(@tmp_root, &block)
|
4
|
+
end
|
5
|
+
|
6
|
+
def in_project_folder(&block)
|
7
|
+
project_folder = @active_project_folder || @tmp_root
|
8
|
+
FileUtils.chdir(project_folder, &block)
|
9
|
+
end
|
10
|
+
|
11
|
+
def in_home_folder(&block)
|
12
|
+
FileUtils.chdir(@home_path, &block)
|
13
|
+
end
|
14
|
+
|
15
|
+
def force_local_lib_override(project_name = @project_name)
|
16
|
+
rakefile = File.read(File.join(project_name, 'Rakefile'))
|
17
|
+
File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
|
18
|
+
f << "$:.unshift('#{@lib_path}')\n"
|
19
|
+
f << rakefile
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def setup_active_project_folder project_name
|
24
|
+
@active_project_folder = File.join(@tmp_root, project_name)
|
25
|
+
@project_name = project_name
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
World(CommonHelpers)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
class InstallShouldaGenerator < RubiGen::Base
|
3
|
+
attr_reader :gem_name, :module_name
|
4
|
+
|
5
|
+
def initialize(runtime_args, runtime_options = {})
|
6
|
+
super
|
7
|
+
@destination_root = File.expand_path(destination_root)
|
8
|
+
@gem_name = base_name
|
9
|
+
@module_name = @gem_name.gsub('-','_').camelize
|
10
|
+
end
|
11
|
+
|
12
|
+
def manifest
|
13
|
+
record do |m|
|
14
|
+
# Ensure appropriate folder(s) exists
|
15
|
+
m.directory 'test'
|
16
|
+
m.directory 'tasks'
|
17
|
+
|
18
|
+
m.template 'test/test.rb', "test/test_#{gem_name}.rb"
|
19
|
+
m.template "test/test_helper.rb", "test/test_helper.rb"
|
20
|
+
|
21
|
+
m.file_copy_each %w( shoulda.rake ), 'tasks'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
def banner
|
27
|
+
<<-EOS
|
28
|
+
Install Shoulda testing support.
|
29
|
+
|
30
|
+
Includes a rake task (tasks/shoulda.rake) to be loaded by the root Rakefile,
|
31
|
+
which provides a "test" task.
|
32
|
+
|
33
|
+
EOS
|
34
|
+
end
|
35
|
+
end
|