generator-spec 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/generator-spec.gemspec +8 -8
- data/lib/generator-spec/rspec/generator.rb +2 -1
- data/lib/generator-spec/rspec/macro.rb +17 -0
- data/spec/generator_spec/generators/controller_gen_spec.rb +16 -5
- data/spec/generator_spec/matchers/generate_artifact_spec.rb +19 -5
- metadata +7 -7
data/Rakefile
CHANGED
@@ -16,8 +16,8 @@ begin
|
|
16
16
|
gem.add_dependency "rails", "~> 3.0.0"
|
17
17
|
gem.add_dependency "test-unit", "~> 2.0.9"
|
18
18
|
gem.add_dependency "require_all", "~> 1.1.0"
|
19
|
-
gem.add_dependency "sugar-high", "~> 0.2.
|
20
|
-
gem.add_dependency "rails3_artifactor", "~> 0.2.
|
19
|
+
gem.add_dependency "sugar-high", "~> 0.2.9"
|
20
|
+
gem.add_dependency "rails3_artifactor", "~> 0.2.3"
|
21
21
|
|
22
22
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
23
23
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.4
|
data/generator-spec.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{generator-spec}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kristian Mandrup"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-17}
|
13
13
|
s.description = %q{RSpec 2 library to facilitate creating generator specs}
|
14
14
|
s.email = %q{kmandrup@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -90,8 +90,8 @@ Gem::Specification.new do |s|
|
|
90
90
|
s.add_runtime_dependency(%q<rails>, ["~> 3.0.0"])
|
91
91
|
s.add_runtime_dependency(%q<test-unit>, ["~> 2.0.9"])
|
92
92
|
s.add_runtime_dependency(%q<require_all>, ["~> 1.1.0"])
|
93
|
-
s.add_runtime_dependency(%q<sugar-high>, ["~> 0.2.
|
94
|
-
s.add_runtime_dependency(%q<rails3_artifactor>, ["~> 0.2.
|
93
|
+
s.add_runtime_dependency(%q<sugar-high>, ["~> 0.2.9"])
|
94
|
+
s.add_runtime_dependency(%q<rails3_artifactor>, ["~> 0.2.3"])
|
95
95
|
else
|
96
96
|
s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.22"])
|
97
97
|
s.add_dependency(%q<mocha>, ["~> 0.9.8"])
|
@@ -101,8 +101,8 @@ Gem::Specification.new do |s|
|
|
101
101
|
s.add_dependency(%q<rails>, ["~> 3.0.0"])
|
102
102
|
s.add_dependency(%q<test-unit>, ["~> 2.0.9"])
|
103
103
|
s.add_dependency(%q<require_all>, ["~> 1.1.0"])
|
104
|
-
s.add_dependency(%q<sugar-high>, ["~> 0.2.
|
105
|
-
s.add_dependency(%q<rails3_artifactor>, ["~> 0.2.
|
104
|
+
s.add_dependency(%q<sugar-high>, ["~> 0.2.9"])
|
105
|
+
s.add_dependency(%q<rails3_artifactor>, ["~> 0.2.3"])
|
106
106
|
end
|
107
107
|
else
|
108
108
|
s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.22"])
|
@@ -113,8 +113,8 @@ Gem::Specification.new do |s|
|
|
113
113
|
s.add_dependency(%q<rails>, ["~> 3.0.0"])
|
114
114
|
s.add_dependency(%q<test-unit>, ["~> 2.0.9"])
|
115
115
|
s.add_dependency(%q<require_all>, ["~> 1.1.0"])
|
116
|
-
s.add_dependency(%q<sugar-high>, ["~> 0.2.
|
117
|
-
s.add_dependency(%q<rails3_artifactor>, ["~> 0.2.
|
116
|
+
s.add_dependency(%q<sugar-high>, ["~> 0.2.9"])
|
117
|
+
s.add_dependency(%q<rails3_artifactor>, ["~> 0.2.3"])
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rails/all'
|
2
|
+
require 'active_support/inflector'
|
2
3
|
require 'rails/generators'
|
3
4
|
require 'rails/generators/test_case'
|
4
5
|
require 'generator-spec/rspec/generator/configure'
|
@@ -56,7 +57,7 @@ module RSpec::Generator
|
|
56
57
|
end
|
57
58
|
|
58
59
|
def get_generator test_method_name=nil
|
59
|
-
@generator ||= RSpec::Generator::TestCase.new(test_method_name + '_spec')
|
60
|
+
@generator ||= RSpec::Generator::TestCase.new(test_method_name.to_s.underscore + '_spec')
|
60
61
|
end
|
61
62
|
|
62
63
|
end # class self
|
@@ -6,7 +6,24 @@ module RSpec::Generator
|
|
6
6
|
|
7
7
|
def setup_generator test_method_name=nil, &block
|
8
8
|
RSpec::Generator.setup_generator test_method_name, &block
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_rails_app app_name = nil
|
12
|
+
app_name ||= 'rails_app'
|
13
|
+
Dir.mkdir ::TmpRails.root if !File.directory?(::TmpRails.root)
|
14
|
+
Dir.chdir ::TmpRails.root do
|
15
|
+
FileUtils.rm_rf app_name
|
16
|
+
%x[rails new #{app_name} --force]
|
17
|
+
end
|
9
18
|
end
|
19
|
+
|
20
|
+
def remove_rails_app app_name = nil
|
21
|
+
app_name ||= 'rails_app'
|
22
|
+
Dir.mkdir ::TmpRails.root if !File.directory?(::TmpRails.root)
|
23
|
+
Dir.chdir ::TmpRails.root do
|
24
|
+
FileUtils.rm_rf app_name
|
25
|
+
end
|
26
|
+
end
|
10
27
|
end
|
11
28
|
end
|
12
29
|
|
@@ -2,21 +2,32 @@ require 'spec_helper'
|
|
2
2
|
require_generator :controller
|
3
3
|
|
4
4
|
describe 'helper_generator' do
|
5
|
-
|
5
|
+
use_helpers :controller, :special
|
6
|
+
|
7
|
+
before do
|
8
|
+
create_rails_app
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
remove_rails_app
|
13
|
+
end
|
6
14
|
|
7
15
|
before :each do
|
8
|
-
setup_generator
|
16
|
+
setup_generator :controller do
|
9
17
|
tests ControllerGenerator
|
10
18
|
end
|
11
19
|
remove_controller :account
|
12
20
|
end
|
13
21
|
|
14
22
|
after :each do
|
15
|
-
|
23
|
+
remove_controller :account
|
16
24
|
end
|
25
|
+
|
26
|
+
it "should have created temporary Rails app with a Gemfile"
|
27
|
+
read_gem_file.should_not be_empty
|
28
|
+
end
|
17
29
|
|
18
|
-
it "should not work without an Account controller file" do
|
19
|
-
remove_controller :account
|
30
|
+
it "should not work without an Account controller file" do
|
20
31
|
with_generator do |g|
|
21
32
|
g.run_generator :account.args
|
22
33
|
g.should_not generate_controller :account
|
@@ -2,17 +2,20 @@ require 'spec_helper'
|
|
2
2
|
require_generator :model
|
3
3
|
|
4
4
|
describe 'model_generator' do
|
5
|
-
use_orm
|
6
|
-
|
7
|
-
before
|
8
|
-
setup_generator
|
5
|
+
use_orm :mongoid
|
6
|
+
|
7
|
+
before do
|
8
|
+
setup_generator :model do
|
9
9
|
tests ModelGenerator
|
10
10
|
end
|
11
|
+
end
|
12
|
+
|
13
|
+
before :each do
|
11
14
|
remove_model :account
|
12
15
|
end
|
13
16
|
|
14
17
|
after :each do
|
15
|
-
|
18
|
+
remove_model :account
|
16
19
|
end
|
17
20
|
|
18
21
|
it "should not work without an Account model file" do
|
@@ -27,10 +30,21 @@ describe 'model_generator' do
|
|
27
30
|
create_model :account
|
28
31
|
g.run_generator :account.args
|
29
32
|
g.should generate_artifact :account, :model
|
33
|
+
|
34
|
+
g.should_not generate_model :user
|
35
|
+
g.should_not generate_controller :user
|
36
|
+
|
30
37
|
g.should generate_model :account do |content|
|
31
38
|
puts content
|
32
39
|
content.should include_module 'Canable::Ables'
|
33
40
|
end
|
34
41
|
end
|
35
42
|
end
|
43
|
+
|
44
|
+
it "should not have generated other things!" do
|
45
|
+
with_generator do |g|
|
46
|
+
g.should_not generate_model :user
|
47
|
+
g.should_not generate_controller :user
|
48
|
+
end
|
49
|
+
end
|
36
50
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 4
|
9
|
+
version: 0.6.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kristian Mandrup
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-09-
|
17
|
+
date: 2010-09-17 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -152,8 +152,8 @@ dependencies:
|
|
152
152
|
segments:
|
153
153
|
- 0
|
154
154
|
- 2
|
155
|
-
-
|
156
|
-
version: 0.2.
|
155
|
+
- 9
|
156
|
+
version: 0.2.9
|
157
157
|
type: :runtime
|
158
158
|
version_requirements: *id009
|
159
159
|
- !ruby/object:Gem::Dependency
|
@@ -167,8 +167,8 @@ dependencies:
|
|
167
167
|
segments:
|
168
168
|
- 0
|
169
169
|
- 2
|
170
|
-
-
|
171
|
-
version: 0.2.
|
170
|
+
- 3
|
171
|
+
version: 0.2.3
|
172
172
|
type: :runtime
|
173
173
|
version_requirements: *id010
|
174
174
|
description: RSpec 2 library to facilitate creating generator specs
|