newgem 1.0.7 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/Manifest.txt +3 -1
- data/app_generators/newgem/newgem_generator.rb +13 -1
- data/bin/newgem +1 -1
- data/features/development.feature +1 -1
- data/features/executable_generator.feature +1 -1
- data/features/extconf.feature +38 -0
- data/features/newgem_cli.feature +20 -0
- data/features/steps/cli.rb +12 -3
- data/features/steps/common.rb +16 -1
- data/lib/newgem.rb +1 -1
- data/rubygems_generators/executable/executable_generator.rb +2 -1
- data/rubygems_generators/executable/templates/bin/app.rb.erb +1 -1
- data/rubygems_generators/executable/templates/lib/app/cli.rb.erb +4 -4
- data/rubygems_generators/executable/templates/spec/cli_spec.rb.erb +10 -3
- data/rubygems_generators/executable/templates/test/test_cli.rb.erb +9 -2
- data/rubygems_generators/extconf/extconf_generator.rb +13 -21
- data/rubygems_generators/extconf/templates/{autotest.rb → autotest.rb.erb} +4 -0
- data/rubygems_generators/extconf/templates/spec/spec.rb.erb +10 -0
- data/rubygems_generators/install_cucumber/templates/features/development.feature +1 -1
- data/rubygems_generators/install_cucumber/templates/features/steps/common.rb +16 -1
- data/rubygems_generators/install_test_unit/templates/test/test_helper.rb +1 -0
- data/test/test_extconf_generator.rb +15 -14
- data/website/index.html +1 -1
- data/website/rubyforge.html +1 -1
- metadata +5 -3
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
== 1.1.0 2008-11-11
|
2
|
+
|
3
|
+
* Support for ~/.newgem.yml file for default CLI arguments
|
4
|
+
* Example content: `default: -T rspec -i cucumber`
|
5
|
+
* executable and extconf generators will create specs or tests depending on what you are using in your RubyGems
|
6
|
+
* executable generator: test/spec files give more useful starting point with a StringIO passed into CLI.execute(stdout, args)
|
7
|
+
* 'rake manifest' instead of 'rake manifest:refresh' [was actually released in 1.0.7]
|
8
|
+
|
1
9
|
== 1.0.7 2008-11-08
|
2
10
|
|
3
11
|
* Removed 'rake local_deploy' and changed website to reference 'rake install_gem' for same purpose [fixed #9]
|
data/Manifest.txt
CHANGED
@@ -35,6 +35,7 @@ cucumber_generators/feature/templates/steps.erb
|
|
35
35
|
features/development.feature
|
36
36
|
features/executable_generator.feature
|
37
37
|
features/expected_outputs/newgem.out
|
38
|
+
features/extconf.feature
|
38
39
|
features/install_cucumber.feature
|
39
40
|
features/install_website.feature
|
40
41
|
features/newgem_cli.feature
|
@@ -79,9 +80,10 @@ rubygems_generators/executable/templates/test/test_cli.rb.erb
|
|
79
80
|
rubygems_generators/extconf/USAGE
|
80
81
|
rubygems_generators/extconf/extconf_generator.rb
|
81
82
|
rubygems_generators/extconf/templates/README.txt
|
82
|
-
rubygems_generators/extconf/templates/autotest.rb
|
83
|
+
rubygems_generators/extconf/templates/autotest.rb.erb
|
83
84
|
rubygems_generators/extconf/templates/ext/c_file.c.erb
|
84
85
|
rubygems_generators/extconf/templates/ext/extconf.rb.erb
|
86
|
+
rubygems_generators/extconf/templates/spec/spec.rb.erb
|
85
87
|
rubygems_generators/extconf/templates/tasks/extconf.rake
|
86
88
|
rubygems_generators/extconf/templates/tasks/extconf_name.rake
|
87
89
|
rubygems_generators/extconf/templates/test/test.rb.erb
|
@@ -27,7 +27,7 @@ class NewgemGenerator < RubiGen::Base
|
|
27
27
|
attr_reader :is_jruby
|
28
28
|
|
29
29
|
def initialize(runtime_args, runtime_options = {})
|
30
|
-
super
|
30
|
+
super(config_args_and_runtime_args(runtime_args), runtime_options)
|
31
31
|
usage if args.empty?
|
32
32
|
@destination_root = File.expand_path(args.shift)
|
33
33
|
@gem_name = base_name
|
@@ -163,6 +163,18 @@ EOS
|
|
163
163
|
@project_name = options[:project] if options.include?(:project)
|
164
164
|
@install_generators = options[:install] || []
|
165
165
|
end
|
166
|
+
|
167
|
+
# first attempt to merge config args (single string) and runtime args
|
168
|
+
def config_args_and_runtime_args(runtime_args)
|
169
|
+
newgem_config = File.expand_path(File.join(ENV['HOME'], '.newgem.yml'))
|
170
|
+
if File.exists?(newgem_config)
|
171
|
+
config = YAML.load(File.read(newgem_config))
|
172
|
+
if config_args = (config["default"] || config[config.keys.first])
|
173
|
+
return config_args.split(" ") + runtime_args
|
174
|
+
end
|
175
|
+
end
|
176
|
+
runtime_args
|
177
|
+
end
|
166
178
|
|
167
179
|
# Installation skeleton. Intermediate directories are automatically
|
168
180
|
# created so don't sweat their absence here.
|
data/bin/newgem
CHANGED
@@ -9,5 +9,5 @@ Feature: Development processes of newgem itself (rake tasks)
|
|
9
9
|
And 'pkg' folder is deleted
|
10
10
|
When task 'rake gem' is invoked
|
11
11
|
Then folder 'pkg' is created
|
12
|
-
And file with name matching 'pkg/*.gem' is created else you should run "rake manifest
|
12
|
+
And file with name matching 'pkg/*.gem' is created else you should run "rake manifest" to fix this
|
13
13
|
And gem spec key 'rdoc_options' contains /--mainREADME.rdoc/
|
@@ -39,7 +39,7 @@ Feature: Generate an executable/CLI scaffold
|
|
39
39
|
When run unit tests for test file 'test/test_my_app_cli.rb'
|
40
40
|
Then all 1 tests pass
|
41
41
|
|
42
|
-
Scenario: Run
|
42
|
+
Scenario: Run examples after executable generator should all pass for rspec
|
43
43
|
Given an existing newgem scaffold using options '-T rspec' [called 'my_project']
|
44
44
|
And 'executable' generator is invoked with arguments 'my_app'
|
45
45
|
When run unit tests for test file 'spec/my_app_cli_spec.rb'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
Feature: Write and test C-extensions
|
2
|
+
In order to leverage existing C libraries
|
3
|
+
As a RubyGems developer
|
4
|
+
I want to generate a scaffold with test/spec support for writing Ruby C-extensions
|
5
|
+
|
6
|
+
Scenario: Run extconf generator with name of extension
|
7
|
+
Given an existing newgem scaffold [called 'my_project']
|
8
|
+
When 'extconf' generator is invoked with arguments 'my_ext'
|
9
|
+
Then folder 'ext/my_ext' is created
|
10
|
+
And file 'ext/my_ext/extconf.rb' is created
|
11
|
+
And file 'ext/my_ext/my_ext.c' is created
|
12
|
+
And file 'test/test_my_ext_extn.rb' is created
|
13
|
+
And file '.autotest' is created
|
14
|
+
And contents of file '.autotest' does match /test\/test_.*_extn\.rb/
|
15
|
+
|
16
|
+
Scenario: Run extconf generator with name of extension on rspec project
|
17
|
+
Given an existing newgem scaffold using options '-T rspec' [called 'my_project']
|
18
|
+
When 'extconf' generator is invoked with arguments 'my_ext'
|
19
|
+
Then folder 'ext/my_ext' is created
|
20
|
+
And file 'ext/my_ext/extconf.rb' is created
|
21
|
+
And file 'ext/my_ext/my_ext.c' is created
|
22
|
+
And file 'spec/my_ext_extn_spec.rb' is created
|
23
|
+
And file '.autotest' is created
|
24
|
+
And contents of file '.autotest' does match /spec\/.*_extn_spec\.rb/
|
25
|
+
|
26
|
+
Scenario: Run unit tests after executable generator should all pass for test/unit
|
27
|
+
Given an existing newgem scaffold [called 'my_project']
|
28
|
+
And 'extconf' generator is invoked with arguments 'my_ext'
|
29
|
+
When task 'rake compile' is invoked
|
30
|
+
And run unit tests for test file 'test/test_my_ext_extn.rb'
|
31
|
+
Then all 1 tests pass
|
32
|
+
|
33
|
+
Scenario: Run examples after executable generator should all pass for rspec
|
34
|
+
Given an existing newgem scaffold using options '-T rspec' [called 'my_project']
|
35
|
+
And 'extconf' generator is invoked with arguments 'my_ext'
|
36
|
+
When task 'rake compile' is invoked
|
37
|
+
And run unit tests for test file 'spec/my_ext_extn_spec.rb'
|
38
|
+
Then all 1 examples pass
|
data/features/newgem_cli.feature
CHANGED
@@ -58,6 +58,26 @@ Feature: Can run 'newgem' to create RubyGem scaffolds
|
|
58
58
|
And does not invoke generator 'install_rspec'
|
59
59
|
And Rakefile can display tasks successfully
|
60
60
|
|
61
|
+
Scenario: Run newgem to pull in defaults from ~/.newgem.yml file and no argument options
|
62
|
+
Given a safe folder
|
63
|
+
And ~/.newgem.yml contains {"default" => "-T rspec -i cucumber"}
|
64
|
+
When newgem is executed for project 'my_project' with options ''
|
65
|
+
Then does invoke generator 'install_rspec'
|
66
|
+
And does invoke generator 'install_cucumber'
|
67
|
+
And does not invoke generator 'install_website'
|
68
|
+
And does not invoke generator 'install_test_unit'
|
69
|
+
And Rakefile can display tasks successfully
|
70
|
+
|
71
|
+
Scenario: Run newgem to pull in defaults from ~/.newgem.yml file and merge with runtime args
|
72
|
+
Given a safe folder
|
73
|
+
And ~/.newgem.yml contains {"default" => "-T rspec -i cucumber"}
|
74
|
+
When newgem is executed for project 'my_project' with options '-i website'
|
75
|
+
Then does invoke generator 'install_rspec'
|
76
|
+
And does invoke generator 'install_cucumber'
|
77
|
+
And does invoke generator 'install_website'
|
78
|
+
And does not invoke generator 'install_test_unit'
|
79
|
+
And Rakefile can display tasks successfully
|
80
|
+
|
61
81
|
Scenario: Run newgem and show current version number
|
62
82
|
Given a safe folder
|
63
83
|
When newgem is executed only with options '--version'
|
data/features/steps/cli.rb
CHANGED
@@ -4,7 +4,7 @@ Given %r{^an existing newgem scaffold \[called '(.*)'\]} do |project_name|
|
|
4
4
|
setup_active_project_folder project_name
|
5
5
|
FileUtils.chdir @tmp_root do
|
6
6
|
@stdout = "newgem.out"
|
7
|
-
system "ruby #{newgem} #{project_name} > #{@stdout}"
|
7
|
+
system "ruby #{newgem} #{project_name} > #{@stdout} 2> #{@stdout}"
|
8
8
|
force_local_lib_override
|
9
9
|
end
|
10
10
|
end
|
@@ -15,12 +15,12 @@ Given %r{^an existing newgem scaffold using options '(.*)' \[called '(.*)'\]} do
|
|
15
15
|
setup_active_project_folder project_name
|
16
16
|
FileUtils.chdir @tmp_root do
|
17
17
|
@stdout = "newgem.out"
|
18
|
-
system "ruby #{newgem} #{arguments} #{project_name} > #{@stdout}"
|
18
|
+
system "ruby #{newgem} #{arguments} #{project_name} > #{@stdout} 2> #{@stdout}"
|
19
19
|
force_local_lib_override
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
Given
|
23
|
+
Given %r{^project website configuration for safe folder on local machine$} do
|
24
24
|
@remote_folder = File.expand_path(File.join(@tmp_root, 'website'))
|
25
25
|
FileUtils.rm_rf @remote_folder
|
26
26
|
FileUtils.mkdir_p @remote_folder
|
@@ -32,6 +32,15 @@ Given /^project website configuration for safe folder on local machine$/ do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
Given %r{^~\/([^\s]+) contains (\{.*\})$} do |file, config|
|
36
|
+
in_home_folder do
|
37
|
+
File.open(file, 'w') do |f|
|
38
|
+
yaml = eval(config)
|
39
|
+
f << yaml.to_yaml
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
35
44
|
def newgem_cmd
|
36
45
|
File.expand_path(File.dirname(__FILE__) + "/../../bin/newgem")
|
37
46
|
end
|
data/features/steps/common.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
def in_project_folder(&block)
|
2
|
-
project_folder = @active_project_folder
|
2
|
+
project_folder = @active_project_folder || @tmp_root
|
3
3
|
FileUtils.chdir(project_folder, &block)
|
4
4
|
end
|
5
5
|
|
6
|
+
def in_home_folder(&block)
|
7
|
+
FileUtils.chdir(@home_path, &block)
|
8
|
+
end
|
9
|
+
|
6
10
|
Given %r{^a safe folder} do
|
7
11
|
FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp"
|
8
12
|
FileUtils.mkdir_p @tmp_root
|
13
|
+
FileUtils.mkdir_p @home_path = File.expand_path(File.join(@tmp_root, "home"))
|
9
14
|
@lib_path = File.expand_path(File.dirname(__FILE__) + '/../../lib')
|
15
|
+
Given "env variable $HOME set to '#{@home_path}'"
|
10
16
|
end
|
11
17
|
|
12
18
|
Given %r{^this project is active project folder} do
|
@@ -114,6 +120,15 @@ Then %r{^output (does|does not) match \/(.*)\/} do |does, regex|
|
|
114
120
|
actual_output.should_not(match(/#{regex}/))
|
115
121
|
end
|
116
122
|
|
123
|
+
Then %r{^contents of file '(.*)' (does|does not) match \/(.*)\/} do |file, does, regex|
|
124
|
+
in_project_folder do
|
125
|
+
actual_output = File.read(file)
|
126
|
+
(does == 'does') ?
|
127
|
+
actual_output.should(match(/#{regex}/)) :
|
128
|
+
actual_output.should_not(match(/#{regex}/))
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
117
132
|
Then %r{^all (\d+) tests pass} do |expected_test_count|
|
118
133
|
expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
|
119
134
|
actual_output = File.read(@stdout)
|
data/lib/newgem.rb
CHANGED
@@ -26,14 +26,15 @@ class ExecutableGenerator < RubiGen::Base
|
|
26
26
|
# Ensure bin folder exists
|
27
27
|
m.directory "bin"
|
28
28
|
m.directory "lib/#{bin_name}"
|
29
|
-
m.directory "test"
|
30
29
|
|
31
30
|
# App stub
|
32
31
|
m.template "bin/app.rb.erb", "bin/#{bin_name}"
|
33
32
|
m.template "lib/app/cli.rb.erb", "lib/#{bin_name}/cli.rb"
|
34
33
|
if using_rspec?
|
34
|
+
m.directory "spec"
|
35
35
|
m.template "spec/cli_spec.rb.erb", "spec/#{bin_name}_cli_spec.rb"
|
36
36
|
else
|
37
|
+
m.directory "test"
|
37
38
|
m.template "test/test_cli.rb.erb", "test/test_#{bin_name}_cli.rb"
|
38
39
|
end
|
39
40
|
end
|
@@ -2,7 +2,7 @@ require 'optparse'
|
|
2
2
|
|
3
3
|
module <%= module_name %>
|
4
4
|
class CLI
|
5
|
-
def self.execute(arguments=[])
|
5
|
+
def self.execute(stdout, arguments=[])
|
6
6
|
|
7
7
|
# NOTE: the option -p/--path= is given as an example, and should be replaced in your application.
|
8
8
|
|
@@ -23,13 +23,13 @@ module <%= module_name %>
|
|
23
23
|
opts.on("-p", "--path=PATH", String,
|
24
24
|
"This is a sample message.",
|
25
25
|
"For multiple lines, add more strings.",
|
26
|
-
"Default: ~") { |arg|
|
26
|
+
"Default: ~") { |arg| options[:path] = arg }
|
27
27
|
opts.on("-h", "--help",
|
28
|
-
"Show this help message.") { puts opts; exit }
|
28
|
+
"Show this help message.") { stdout.puts opts; exit }
|
29
29
|
opts.parse!(arguments)
|
30
30
|
|
31
31
|
if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }
|
32
|
-
puts opts; exit
|
32
|
+
stdout.puts opts; exit
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -1,8 +1,15 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
require '<%= bin_name %>/cli'
|
3
3
|
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
4
|
+
describe <%= module_name %>::CLI, "execute" do
|
5
|
+
before(:each) do
|
6
|
+
@stdout_io = StringIO.new
|
7
|
+
<%= module_name %>::CLI.execute(@stdout_io, [])
|
8
|
+
@stdout_io.rewind
|
9
|
+
@stdout = @stdout_io.read
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should do something" do
|
13
|
+
@stdout.should_not =~ /To update this executable/
|
7
14
|
end
|
8
15
|
end
|
@@ -2,7 +2,14 @@ require File.join(File.dirname(__FILE__), "test_helper.rb")
|
|
2
2
|
require '<%= bin_name %>/cli'
|
3
3
|
|
4
4
|
class Test<%= module_name %>Cli < Test::Unit::TestCase
|
5
|
-
def
|
6
|
-
|
5
|
+
def setup
|
6
|
+
@stdout_io = StringIO.new
|
7
|
+
<%= module_name %>::CLI.execute(@stdout_io, [])
|
8
|
+
@stdout_io.rewind
|
9
|
+
@stdout = @stdout_io.read
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_not_print_default_output
|
13
|
+
assert_no_match(/To update this executable/, @stdout)
|
7
14
|
end
|
8
15
|
end
|
@@ -10,7 +10,6 @@ class ExtconfGenerator < RubiGen::Base
|
|
10
10
|
@name = args.shift
|
11
11
|
@module_name = name.camelcase
|
12
12
|
@test_module_name = @module_name + "Extn"
|
13
|
-
extract_options
|
14
13
|
end
|
15
14
|
|
16
15
|
def manifest
|
@@ -18,20 +17,30 @@ class ExtconfGenerator < RubiGen::Base
|
|
18
17
|
# Ensure appropriate folder(s) exists
|
19
18
|
m.directory "ext/#{name}"
|
20
19
|
m.directory "tasks/extconf"
|
21
|
-
m.directory "test"
|
22
20
|
|
23
21
|
# Create stubs
|
24
22
|
m.template "ext/c_file.c.erb", "ext/#{name}/#{name}.c"
|
25
23
|
m.template "ext/extconf.rb.erb", "ext/#{name}/extconf.rb"
|
26
|
-
|
24
|
+
if using_rspec?
|
25
|
+
m.directory "spec"
|
26
|
+
m.template "spec/spec.rb.erb", "spec/#{name}_extn_spec.rb"
|
27
|
+
else
|
28
|
+
m.directory "test"
|
29
|
+
m.template "test/test.rb.erb", "test/test_#{name}_extn.rb"
|
30
|
+
end
|
31
|
+
|
27
32
|
m.file "tasks/extconf.rake", "tasks/extconf.rake"
|
28
33
|
m.file "tasks/extconf_name.rake", "tasks/extconf/#{name}.rake"
|
29
34
|
|
30
|
-
m.
|
35
|
+
m.template "autotest.rb.erb", ".autotest"
|
31
36
|
m.readme "README.txt"
|
32
37
|
end
|
33
38
|
end
|
34
39
|
|
40
|
+
def using_rspec?
|
41
|
+
!Dir[File.join(destination_root, 'spec')].empty?
|
42
|
+
end
|
43
|
+
|
35
44
|
protected
|
36
45
|
def banner
|
37
46
|
<<-EOS
|
@@ -44,21 +53,4 @@ USAGE: #{$0} #{spec.name} name
|
|
44
53
|
EOS
|
45
54
|
end
|
46
55
|
|
47
|
-
def add_options!(opts)
|
48
|
-
# opts.separator ''
|
49
|
-
# opts.separator 'Options:'
|
50
|
-
# For each option below, place the default
|
51
|
-
# at the top of the file next to "default_options"
|
52
|
-
# opts.on("-a", "--author=\"Your Name\"", String,
|
53
|
-
# "Some comment about this option",
|
54
|
-
# "Default: none") { |options[:author]| }
|
55
|
-
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
56
|
-
end
|
57
|
-
|
58
|
-
def extract_options
|
59
|
-
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
60
|
-
# Templates can access these value via the attr_reader-generated methods, but not the
|
61
|
-
# raw instance variable value.
|
62
|
-
# @author = options[:author]
|
63
|
-
end
|
64
56
|
end
|
@@ -9,5 +9,5 @@ Feature: Development processes of newgem itself (rake tasks)
|
|
9
9
|
And 'pkg' folder is deleted
|
10
10
|
When task 'rake gem' is invoked
|
11
11
|
Then folder 'pkg' is created
|
12
|
-
And file with name matching 'pkg/*.gem' is created else you should run "rake manifest
|
12
|
+
And file with name matching 'pkg/*.gem' is created else you should run "rake manifest" to fix this
|
13
13
|
And gem spec key 'rdoc_options' contains /--mainREADME.rdoc/
|
@@ -1,12 +1,18 @@
|
|
1
1
|
def in_project_folder(&block)
|
2
|
-
project_folder = @active_project_folder
|
2
|
+
project_folder = @active_project_folder || @tmp_root
|
3
3
|
FileUtils.chdir(project_folder, &block)
|
4
4
|
end
|
5
5
|
|
6
|
+
def in_home_folder(&block)
|
7
|
+
FileUtils.chdir(@home_path, &block)
|
8
|
+
end
|
9
|
+
|
6
10
|
Given %r{^a safe folder} do
|
7
11
|
FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp"
|
8
12
|
FileUtils.mkdir_p @tmp_root
|
13
|
+
FileUtils.mkdir_p @home_path = File.expand_path(File.join(@tmp_root, "home"))
|
9
14
|
@lib_path = File.expand_path(File.dirname(__FILE__) + '/../../lib')
|
15
|
+
Given "env variable $HOME set to '#{@home_path}'"
|
10
16
|
end
|
11
17
|
|
12
18
|
Given %r{^this project is active project folder} do
|
@@ -114,6 +120,15 @@ Then %r{^output (does|does not) match \/(.*)\/} do |does, regex|
|
|
114
120
|
actual_output.should_not(match(/#{regex}/))
|
115
121
|
end
|
116
122
|
|
123
|
+
Then %r{^contents of file '(.*)' (does|does not) match \/(.*)\/} do |file, does, regex|
|
124
|
+
in_project_folder do
|
125
|
+
actual_output = File.read(file)
|
126
|
+
(does == 'does') ?
|
127
|
+
actual_output.should(match(/#{regex}/)) :
|
128
|
+
actual_output.should_not(match(/#{regex}/))
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
117
132
|
Then %r{^all (\d+) tests pass} do |expected_test_count|
|
118
133
|
expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
|
119
134
|
actual_output = File.read(@stdout)
|
@@ -11,20 +11,6 @@ class TestExtconfGenerator < Test::Unit::TestCase
|
|
11
11
|
bare_teardown
|
12
12
|
end
|
13
13
|
|
14
|
-
# Some generator-related assertions:
|
15
|
-
# assert_generated_file(name, &block) # block passed the file contents
|
16
|
-
# assert_directory_exists(name)
|
17
|
-
# assert_generated_class(name, &block)
|
18
|
-
# assert_generated_module(name, &block)
|
19
|
-
# assert_generated_test_for(name, &block)
|
20
|
-
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
21
|
-
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
22
|
-
#
|
23
|
-
# Other helper methods are:
|
24
|
-
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
25
|
-
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
26
|
-
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
27
|
-
|
28
14
|
def test_generator_without_options
|
29
15
|
name = "my_ext"
|
30
16
|
run_generator('extconf', [name], sources)
|
@@ -38,6 +24,21 @@ class TestExtconfGenerator < Test::Unit::TestCase
|
|
38
24
|
assert_generated_file(".autotest")
|
39
25
|
end
|
40
26
|
|
27
|
+
def test_generator_for_rspec_project
|
28
|
+
name = "my_ext"
|
29
|
+
FileUtils.mkdir_p(File.join(APP_ROOT, 'spec'))
|
30
|
+
`touch #{APP_ROOT}/spec/spec_helper.rb`
|
31
|
+
run_generator('extconf', [name], sources)
|
32
|
+
assert_directory_exists("ext/my_ext")
|
33
|
+
assert_directory_exists("tasks/extconf")
|
34
|
+
assert_generated_file("ext/my_ext/extconf.rb")
|
35
|
+
assert_generated_file("ext/my_ext/my_ext.c")
|
36
|
+
assert_generated_file("tasks/extconf.rake")
|
37
|
+
assert_generated_file("tasks/extconf/my_ext.rake")
|
38
|
+
assert_generated_file("spec/my_ext_extn_spec.rb")
|
39
|
+
assert_generated_file(".autotest")
|
40
|
+
end
|
41
|
+
|
41
42
|
private
|
42
43
|
def sources
|
43
44
|
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
data/website/index.html
CHANGED
@@ -39,7 +39,7 @@
|
|
39
39
|
|
40
40
|
<div id="version"> <!-- class="clickable" onclick='document.location = "http://rubyforge.org/projects/newgem"; return true' -->
|
41
41
|
<p>Get Version</p>
|
42
|
-
<a href="http://rubyforge.org/projects/newgem" class="numbers">1.0
|
42
|
+
<a href="http://rubyforge.org/projects/newgem" class="numbers">1.1.0</a>
|
43
43
|
<p>Featured in</p>
|
44
44
|
<a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2FBeginning-Ruby-Novice-Professional-Experts%2Fdp%2F1590597664%2F&tag=drnic-20&linkCode=ur2&camp=1789&creative=9325" class="book"><img src="images/beginning-ruby.jpg" /></a>
|
45
45
|
</div>
|
data/website/rubyforge.html
CHANGED
@@ -39,7 +39,7 @@
|
|
39
39
|
|
40
40
|
<div id="version"> <!-- class="clickable" onclick='document.location = "http://rubyforge.org/projects/newgem"; return true' -->
|
41
41
|
<p>Get Version</p>
|
42
|
-
<a href="http://rubyforge.org/projects/newgem" class="numbers">1.0
|
42
|
+
<a href="http://rubyforge.org/projects/newgem" class="numbers">1.1.0</a>
|
43
43
|
<p>Featured in</p>
|
44
44
|
<a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2FBeginning-Ruby-Novice-Professional-Experts%2Fdp%2F1590597664%2F&tag=drnic-20&linkCode=ur2&camp=1789&creative=9325" class="book"><img src="images/beginning-ruby.jpg" /></a>
|
45
45
|
</div>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newgem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dr Nic Williams
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-11-
|
12
|
+
date: 2008-11-11 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- features/development.feature
|
144
144
|
- features/executable_generator.feature
|
145
145
|
- features/expected_outputs/newgem.out
|
146
|
+
- features/extconf.feature
|
146
147
|
- features/install_cucumber.feature
|
147
148
|
- features/install_website.feature
|
148
149
|
- features/newgem_cli.feature
|
@@ -187,9 +188,10 @@ files:
|
|
187
188
|
- rubygems_generators/extconf/USAGE
|
188
189
|
- rubygems_generators/extconf/extconf_generator.rb
|
189
190
|
- rubygems_generators/extconf/templates/README.txt
|
190
|
-
- rubygems_generators/extconf/templates/autotest.rb
|
191
|
+
- rubygems_generators/extconf/templates/autotest.rb.erb
|
191
192
|
- rubygems_generators/extconf/templates/ext/c_file.c.erb
|
192
193
|
- rubygems_generators/extconf/templates/ext/extconf.rb.erb
|
194
|
+
- rubygems_generators/extconf/templates/spec/spec.rb.erb
|
193
195
|
- rubygems_generators/extconf/templates/tasks/extconf.rake
|
194
196
|
- rubygems_generators/extconf/templates/tasks/extconf_name.rake
|
195
197
|
- rubygems_generators/extconf/templates/test/test.rb.erb
|