generator-spec 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +53 -37
- data/VERSION +1 -1
- data/lib/{rspec_for_generators.rb → generator_spec.rb} +1 -1
- data/lib/generator_spec/extensions/core_ext.rb +17 -0
- data/lib/{rspec_for_generators/rails_spec_helper.rb → generator_spec/helpers/configure_rails.rb} +0 -4
- data/lib/{rspec_for_generators → generator_spec/helpers}/migration_helper.rb +0 -0
- data/lib/generator_spec/main.rb +42 -0
- data/lib/generator_spec/matchers/content/content_matcher.rb +21 -0
- data/lib/{rspec_for_generators → generator_spec}/matchers/content/have_block.rb +17 -8
- data/lib/{rspec_for_generators → generator_spec}/matchers/content/have_call.rb +6 -6
- data/lib/{rspec_for_generators → generator_spec}/matchers/content/have_calls.rb +5 -5
- data/lib/{rspec_for_generators → generator_spec}/matchers/content/have_class.rb +14 -6
- data/lib/{rspec_for_generators → generator_spec}/matchers/content/have_method.rb +17 -8
- data/lib/{rspec_for_generators → generator_spec}/matchers/content/have_module.rb +7 -6
- data/lib/generator_spec/matchers/content/have_region.rb +49 -0
- data/lib/{rspec_for_generators → generator_spec}/matchers/content/have_subclass.rb +19 -7
- data/lib/{rspec_for_generators → generator_spec}/matchers/content/include_module.rb +5 -5
- data/lib/{rspec_for_generators → generator_spec}/matchers/content/inherit_from.rb +7 -3
- data/lib/{rspec_for_generators → generator_spec}/matchers/file/generate_directory.rb +1 -1
- data/lib/{rspec_for_generators → generator_spec}/matchers/file/generate_file.rb +6 -0
- data/lib/{rspec_for_generators → generator_spec}/matchers/file/generate_migration.rb +1 -1
- data/lib/{rspec_for_generators → generator_spec}/matchers/helpers/content.rb +0 -0
- data/lib/{rspec_for_generators → generator_spec}/matchers/helpers/file.rb +0 -0
- data/lib/{rspec_for_generators → generator_spec}/matchers/helpers/migration.rb +1 -1
- data/lib/{rspec_for_generators → generator_spec}/matchers/migration/have_column.rb +0 -0
- data/lib/{rspec_for_generators → generator_spec}/matchers/migration/have_index.rb +0 -0
- data/lib/{rspec_for_generators → generator_spec}/matchers/migration/have_table.rb +0 -0
- data/lib/{rspec_for_generators → generator_spec}/matchers/migration/have_tbl_column.rb +0 -0
- data/lib/{rspec_for_generators → generator_spec}/matchers/migration/have_up_down.rb +0 -0
- data/lib/generator_spec/rails_helpers/rails_app.rb +159 -0
- data/lib/{rspec_for_generators → generator_spec}/rails_helpers/rails_controller.rb +4 -2
- data/lib/{rspec_for_generators → generator_spec}/rails_helpers/rails_helper.rb +4 -2
- data/lib/{rspec_for_generators → generator_spec}/rails_helpers/rails_mailer.rb +4 -2
- data/lib/{rspec_for_generators → generator_spec}/rails_helpers/rails_migration.rb +1 -1
- data/lib/{rspec_for_generators → generator_spec}/rails_helpers/rails_model.rb +4 -2
- data/lib/{rspec_for_generators → generator_spec}/rails_helpers/rails_observer.rb +4 -2
- data/lib/{rspec_for_generators → generator_spec}/rails_helpers/rails_orm.rb +37 -17
- data/lib/{rspec_for_generators → generator_spec}/rails_helpers/rails_view.rb +3 -1
- data/lib/generator_spec/require_generator.rb +67 -0
- data/lib/generator_spec/rspec_generator/configure.rb +51 -0
- data/lib/generator_spec/rspec_generator/generator_util.rb +57 -0
- data/lib/generator_spec/rspec_generator/routes.rb +2 -0
- data/lib/generator_spec/rspec_generator/test_case.rb +25 -0
- data/spec/{rspec_for_generators → generator_spec}/controller_generator_spec.rb +0 -0
- data/spec/{rspec_for_generators → generator_spec}/helper_generator_spec.rb +10 -10
- data/spec/{rspec_for_generators → generator_spec}/migration_generator_spec.rb +0 -0
- data/spec/{rspec_for_generators → generator_spec}/model_generator_spec.rb +0 -0
- data/spec/{rspec_for_generators → generator_spec}/observer_generator_spec.rb +0 -0
- data/spec/{rspec_for_generators → generator_spec}/view_generator_spec.rb +0 -0
- data/spec/spec_helper.rb +12 -9
- metadata +55 -51
- data/generator-spec.gemspec +0 -128
- data/lib/rspec_for_generators/fixtures/routes.rb +0 -2
- data/lib/rspec_for_generators/generator_spec_helper.rb +0 -151
- data/lib/rspec_for_generators/main.rb +0 -19
- data/lib/rspec_for_generators/rails_helpers/rails_app.rb +0 -119
- data/lib/rspec_for_generators/rspec_test_case.rb +0 -26
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'rspec/autorun'
|
3
|
-
require '
|
3
|
+
require 'generator_spec'
|
4
4
|
|
5
|
-
RSpec::Generator.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def self.logger
|
11
|
-
@logger ||= Logger.new(STDOUT)
|
12
|
-
end
|
5
|
+
RSpec::Generator.configure do |config|
|
6
|
+
config.debug = false
|
7
|
+
config.remove_temp_dir = true
|
8
|
+
config.default_rails_root(__FILE__)
|
9
|
+
config.lib = File.dirname(__FILE__) + '/../lib'
|
13
10
|
end
|
14
11
|
|
12
|
+
# module Rails
|
13
|
+
# def self.logger
|
14
|
+
# @logger ||= Logger.new(STDOUT)
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
|
15
18
|
# class Railtie < ::Rails::Railtie
|
16
19
|
# # config.
|
17
20
|
#
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 4
|
9
|
+
version: 0.4.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kristian Mandrup
|
@@ -128,7 +128,47 @@ files:
|
|
128
128
|
- README.markdown
|
129
129
|
- Rakefile
|
130
130
|
- VERSION
|
131
|
-
-
|
131
|
+
- lib/generator_spec.rb
|
132
|
+
- lib/generator_spec/extensions/core_ext.rb
|
133
|
+
- lib/generator_spec/helpers/configure_rails.rb
|
134
|
+
- lib/generator_spec/helpers/migration_helper.rb
|
135
|
+
- lib/generator_spec/main.rb
|
136
|
+
- lib/generator_spec/matchers/content/content_matcher.rb
|
137
|
+
- lib/generator_spec/matchers/content/have_block.rb
|
138
|
+
- lib/generator_spec/matchers/content/have_call.rb
|
139
|
+
- lib/generator_spec/matchers/content/have_calls.rb
|
140
|
+
- lib/generator_spec/matchers/content/have_class.rb
|
141
|
+
- lib/generator_spec/matchers/content/have_method.rb
|
142
|
+
- lib/generator_spec/matchers/content/have_module.rb
|
143
|
+
- lib/generator_spec/matchers/content/have_region.rb
|
144
|
+
- lib/generator_spec/matchers/content/have_subclass.rb
|
145
|
+
- lib/generator_spec/matchers/content/include_module.rb
|
146
|
+
- lib/generator_spec/matchers/content/inherit_from.rb
|
147
|
+
- lib/generator_spec/matchers/file/generate_directory.rb
|
148
|
+
- lib/generator_spec/matchers/file/generate_file.rb
|
149
|
+
- lib/generator_spec/matchers/file/generate_migration.rb
|
150
|
+
- lib/generator_spec/matchers/helpers/content.rb
|
151
|
+
- lib/generator_spec/matchers/helpers/file.rb
|
152
|
+
- lib/generator_spec/matchers/helpers/migration.rb
|
153
|
+
- lib/generator_spec/matchers/migration/have_column.rb
|
154
|
+
- lib/generator_spec/matchers/migration/have_index.rb
|
155
|
+
- lib/generator_spec/matchers/migration/have_table.rb
|
156
|
+
- lib/generator_spec/matchers/migration/have_tbl_column.rb
|
157
|
+
- lib/generator_spec/matchers/migration/have_up_down.rb
|
158
|
+
- lib/generator_spec/rails_helpers/rails_app.rb
|
159
|
+
- lib/generator_spec/rails_helpers/rails_controller.rb
|
160
|
+
- lib/generator_spec/rails_helpers/rails_helper.rb
|
161
|
+
- lib/generator_spec/rails_helpers/rails_mailer.rb
|
162
|
+
- lib/generator_spec/rails_helpers/rails_migration.rb
|
163
|
+
- lib/generator_spec/rails_helpers/rails_model.rb
|
164
|
+
- lib/generator_spec/rails_helpers/rails_observer.rb
|
165
|
+
- lib/generator_spec/rails_helpers/rails_orm.rb
|
166
|
+
- lib/generator_spec/rails_helpers/rails_view.rb
|
167
|
+
- lib/generator_spec/require_generator.rb
|
168
|
+
- lib/generator_spec/rspec_generator/configure.rb
|
169
|
+
- lib/generator_spec/rspec_generator/generator_util.rb
|
170
|
+
- lib/generator_spec/rspec_generator/routes.rb
|
171
|
+
- lib/generator_spec/rspec_generator/test_case.rb
|
132
172
|
- lib/generators/controller/controller_generator.rb
|
133
173
|
- lib/generators/helper/helper_generator.rb
|
134
174
|
- lib/generators/migration/migration_generator.rb
|
@@ -136,49 +176,13 @@ files:
|
|
136
176
|
- lib/generators/model/model_generator.rb
|
137
177
|
- lib/generators/observer/observer_generator.rb
|
138
178
|
- lib/generators/view/view_generator.rb
|
139
|
-
- lib/rspec_for_generators.rb
|
140
|
-
- lib/rspec_for_generators/fixtures/routes.rb
|
141
|
-
- lib/rspec_for_generators/generator_spec_helper.rb
|
142
|
-
- lib/rspec_for_generators/main.rb
|
143
|
-
- lib/rspec_for_generators/matchers/content/have_block.rb
|
144
|
-
- lib/rspec_for_generators/matchers/content/have_call.rb
|
145
|
-
- lib/rspec_for_generators/matchers/content/have_calls.rb
|
146
|
-
- lib/rspec_for_generators/matchers/content/have_class.rb
|
147
|
-
- lib/rspec_for_generators/matchers/content/have_method.rb
|
148
|
-
- lib/rspec_for_generators/matchers/content/have_module.rb
|
149
|
-
- lib/rspec_for_generators/matchers/content/have_subclass.rb
|
150
|
-
- lib/rspec_for_generators/matchers/content/include_module.rb
|
151
|
-
- lib/rspec_for_generators/matchers/content/inherit_from.rb
|
152
|
-
- lib/rspec_for_generators/matchers/file/generate_directory.rb
|
153
|
-
- lib/rspec_for_generators/matchers/file/generate_file.rb
|
154
|
-
- lib/rspec_for_generators/matchers/file/generate_migration.rb
|
155
|
-
- lib/rspec_for_generators/matchers/helpers/content.rb
|
156
|
-
- lib/rspec_for_generators/matchers/helpers/file.rb
|
157
|
-
- lib/rspec_for_generators/matchers/helpers/migration.rb
|
158
|
-
- lib/rspec_for_generators/matchers/migration/have_column.rb
|
159
|
-
- lib/rspec_for_generators/matchers/migration/have_index.rb
|
160
|
-
- lib/rspec_for_generators/matchers/migration/have_table.rb
|
161
|
-
- lib/rspec_for_generators/matchers/migration/have_tbl_column.rb
|
162
|
-
- lib/rspec_for_generators/matchers/migration/have_up_down.rb
|
163
|
-
- lib/rspec_for_generators/migration_helper.rb
|
164
|
-
- lib/rspec_for_generators/rails_helpers/rails_app.rb
|
165
|
-
- lib/rspec_for_generators/rails_helpers/rails_controller.rb
|
166
|
-
- lib/rspec_for_generators/rails_helpers/rails_helper.rb
|
167
|
-
- lib/rspec_for_generators/rails_helpers/rails_mailer.rb
|
168
|
-
- lib/rspec_for_generators/rails_helpers/rails_migration.rb
|
169
|
-
- lib/rspec_for_generators/rails_helpers/rails_model.rb
|
170
|
-
- lib/rspec_for_generators/rails_helpers/rails_observer.rb
|
171
|
-
- lib/rspec_for_generators/rails_helpers/rails_orm.rb
|
172
|
-
- lib/rspec_for_generators/rails_helpers/rails_view.rb
|
173
|
-
- lib/rspec_for_generators/rails_spec_helper.rb
|
174
|
-
- lib/rspec_for_generators/rspec_test_case.rb
|
175
179
|
- rspec_for_generators.gemspec
|
176
|
-
- spec/
|
177
|
-
- spec/
|
178
|
-
- spec/
|
179
|
-
- spec/
|
180
|
-
- spec/
|
181
|
-
- spec/
|
180
|
+
- spec/generator_spec/controller_generator_spec.rb
|
181
|
+
- spec/generator_spec/helper_generator_spec.rb
|
182
|
+
- spec/generator_spec/migration_generator_spec.rb
|
183
|
+
- spec/generator_spec/model_generator_spec.rb
|
184
|
+
- spec/generator_spec/observer_generator_spec.rb
|
185
|
+
- spec/generator_spec/view_generator_spec.rb
|
182
186
|
- spec/spec_helper.rb
|
183
187
|
- wiki/Custom Rails 3 Generators.textile
|
184
188
|
- wiki/content_matchers.textile
|
@@ -218,10 +222,10 @@ signing_key:
|
|
218
222
|
specification_version: 3
|
219
223
|
summary: RSpec 2 library for writing generator specs
|
220
224
|
test_files:
|
221
|
-
- spec/
|
222
|
-
- spec/
|
223
|
-
- spec/
|
224
|
-
- spec/
|
225
|
-
- spec/
|
226
|
-
- spec/
|
225
|
+
- spec/generator_spec/controller_generator_spec.rb
|
226
|
+
- spec/generator_spec/helper_generator_spec.rb
|
227
|
+
- spec/generator_spec/migration_generator_spec.rb
|
228
|
+
- spec/generator_spec/model_generator_spec.rb
|
229
|
+
- spec/generator_spec/observer_generator_spec.rb
|
230
|
+
- spec/generator_spec/view_generator_spec.rb
|
227
231
|
- spec/spec_helper.rb
|
data/generator-spec.gemspec
DELETED
@@ -1,128 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{generator-spec}
|
8
|
-
s.version = "0.4.3"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Kristian Mandrup"]
|
12
|
-
s.date = %q{2010-08-09}
|
13
|
-
s.description = %q{RSpec 2 library to assist in writing generator specs}
|
14
|
-
s.email = %q{kmandrup@gmail.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.markdown"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
".rspec",
|
23
|
-
"LICENSE",
|
24
|
-
"README.markdown",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"generator-spec.gemspec",
|
28
|
-
"lib/generators/controller/controller_generator.rb",
|
29
|
-
"lib/generators/helper/helper_generator.rb",
|
30
|
-
"lib/generators/migration/migration_generator.rb",
|
31
|
-
"lib/generators/migration/templates/create_users.erb",
|
32
|
-
"lib/generators/model/model_generator.rb",
|
33
|
-
"lib/generators/observer/observer_generator.rb",
|
34
|
-
"lib/generators/view/view_generator.rb",
|
35
|
-
"lib/rspec_for_generators.rb",
|
36
|
-
"lib/rspec_for_generators/fixtures/routes.rb",
|
37
|
-
"lib/rspec_for_generators/generator_spec_helper.rb",
|
38
|
-
"lib/rspec_for_generators/main.rb",
|
39
|
-
"lib/rspec_for_generators/matchers/content/have_block.rb",
|
40
|
-
"lib/rspec_for_generators/matchers/content/have_call.rb",
|
41
|
-
"lib/rspec_for_generators/matchers/content/have_calls.rb",
|
42
|
-
"lib/rspec_for_generators/matchers/content/have_class.rb",
|
43
|
-
"lib/rspec_for_generators/matchers/content/have_method.rb",
|
44
|
-
"lib/rspec_for_generators/matchers/content/have_module.rb",
|
45
|
-
"lib/rspec_for_generators/matchers/content/have_subclass.rb",
|
46
|
-
"lib/rspec_for_generators/matchers/content/include_module.rb",
|
47
|
-
"lib/rspec_for_generators/matchers/content/inherit_from.rb",
|
48
|
-
"lib/rspec_for_generators/matchers/file/generate_directory.rb",
|
49
|
-
"lib/rspec_for_generators/matchers/file/generate_file.rb",
|
50
|
-
"lib/rspec_for_generators/matchers/file/generate_migration.rb",
|
51
|
-
"lib/rspec_for_generators/matchers/helpers/content.rb",
|
52
|
-
"lib/rspec_for_generators/matchers/helpers/file.rb",
|
53
|
-
"lib/rspec_for_generators/matchers/helpers/migration.rb",
|
54
|
-
"lib/rspec_for_generators/matchers/migration/have_column.rb",
|
55
|
-
"lib/rspec_for_generators/matchers/migration/have_index.rb",
|
56
|
-
"lib/rspec_for_generators/matchers/migration/have_table.rb",
|
57
|
-
"lib/rspec_for_generators/matchers/migration/have_tbl_column.rb",
|
58
|
-
"lib/rspec_for_generators/matchers/migration/have_up_down.rb",
|
59
|
-
"lib/rspec_for_generators/migration_helper.rb",
|
60
|
-
"lib/rspec_for_generators/rails_helpers/rails_app.rb",
|
61
|
-
"lib/rspec_for_generators/rails_helpers/rails_controller.rb",
|
62
|
-
"lib/rspec_for_generators/rails_helpers/rails_helper.rb",
|
63
|
-
"lib/rspec_for_generators/rails_helpers/rails_mailer.rb",
|
64
|
-
"lib/rspec_for_generators/rails_helpers/rails_migration.rb",
|
65
|
-
"lib/rspec_for_generators/rails_helpers/rails_model.rb",
|
66
|
-
"lib/rspec_for_generators/rails_helpers/rails_observer.rb",
|
67
|
-
"lib/rspec_for_generators/rails_helpers/rails_orm.rb",
|
68
|
-
"lib/rspec_for_generators/rails_helpers/rails_view.rb",
|
69
|
-
"lib/rspec_for_generators/rails_spec_helper.rb",
|
70
|
-
"lib/rspec_for_generators/rspec_test_case.rb",
|
71
|
-
"rspec_for_generators.gemspec",
|
72
|
-
"spec/rspec_for_generators/controller_generator_spec.rb",
|
73
|
-
"spec/rspec_for_generators/helper_generator_spec.rb",
|
74
|
-
"spec/rspec_for_generators/migration_generator_spec.rb",
|
75
|
-
"spec/rspec_for_generators/model_generator_spec.rb",
|
76
|
-
"spec/rspec_for_generators/observer_generator_spec.rb",
|
77
|
-
"spec/rspec_for_generators/view_generator_spec.rb",
|
78
|
-
"spec/spec_helper.rb",
|
79
|
-
"wiki/Custom Rails 3 Generators.textile",
|
80
|
-
"wiki/content_matchers.textile",
|
81
|
-
"wiki/file_matchers.textile",
|
82
|
-
"wiki/migration_matchers.textile",
|
83
|
-
"wiki/rails_helpers.textile"
|
84
|
-
]
|
85
|
-
s.homepage = %q{http://github.com/kristianmandrup/rspec_for_generators}
|
86
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
87
|
-
s.require_paths = ["lib"]
|
88
|
-
s.rubygems_version = %q{1.3.7}
|
89
|
-
s.summary = %q{RSpec 2 library for writing generator specs}
|
90
|
-
s.test_files = [
|
91
|
-
"spec/rspec_for_generators/controller_generator_spec.rb",
|
92
|
-
"spec/rspec_for_generators/helper_generator_spec.rb",
|
93
|
-
"spec/rspec_for_generators/migration_generator_spec.rb",
|
94
|
-
"spec/rspec_for_generators/model_generator_spec.rb",
|
95
|
-
"spec/rspec_for_generators/observer_generator_spec.rb",
|
96
|
-
"spec/rspec_for_generators/view_generator_spec.rb",
|
97
|
-
"spec/spec_helper.rb"
|
98
|
-
]
|
99
|
-
|
100
|
-
if s.respond_to? :specification_version then
|
101
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
102
|
-
s.specification_version = 3
|
103
|
-
|
104
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
105
|
-
s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta19"])
|
106
|
-
s.add_runtime_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
|
107
|
-
s.add_runtime_dependency(%q<rake>, [">= 0.8.7"])
|
108
|
-
s.add_runtime_dependency(%q<rails>, [">= 3.0.0.rc"])
|
109
|
-
s.add_runtime_dependency(%q<test-unit>, [">= 2.0.9"])
|
110
|
-
s.add_runtime_dependency(%q<require_all>, [">= 1.1.0"])
|
111
|
-
else
|
112
|
-
s.add_dependency(%q<rspec>, [">= 2.0.0.beta19"])
|
113
|
-
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
|
114
|
-
s.add_dependency(%q<rake>, [">= 0.8.7"])
|
115
|
-
s.add_dependency(%q<rails>, [">= 3.0.0.rc"])
|
116
|
-
s.add_dependency(%q<test-unit>, [">= 2.0.9"])
|
117
|
-
s.add_dependency(%q<require_all>, [">= 1.1.0"])
|
118
|
-
end
|
119
|
-
else
|
120
|
-
s.add_dependency(%q<rspec>, [">= 2.0.0.beta19"])
|
121
|
-
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.19"])
|
122
|
-
s.add_dependency(%q<rake>, [">= 0.8.7"])
|
123
|
-
s.add_dependency(%q<rails>, [">= 3.0.0.rc"])
|
124
|
-
s.add_dependency(%q<test-unit>, [">= 2.0.9"])
|
125
|
-
s.add_dependency(%q<require_all>, [">= 1.1.0"])
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
@@ -1,151 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'rails/all'
|
3
|
-
require 'rails/generators'
|
4
|
-
require 'rails/generators/test_case'
|
5
|
-
require 'rspec_for_generators/rails_spec_helper'
|
6
|
-
|
7
|
-
# Call configure to load the settings from
|
8
|
-
# Rails.application.config.generators to Rails::Generators
|
9
|
-
|
10
|
-
class Array
|
11
|
-
def args
|
12
|
-
flatten.map(&:to_s)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# require the generators
|
17
|
-
def require_generators *generator_list
|
18
|
-
req = RSpec::Generator::Require
|
19
|
-
generator_list.each do |name, generators|
|
20
|
-
case name
|
21
|
-
when Hash
|
22
|
-
req.parse_generator_hash name
|
23
|
-
when Symbol
|
24
|
-
if !generators || generators.empty?
|
25
|
-
req.require_generator! name
|
26
|
-
else
|
27
|
-
req.parse_generator_list name, generators
|
28
|
-
end
|
29
|
-
else
|
30
|
-
raise ArgumentError, "required generator(s) must be stated either using a symbol or array of symbols"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
alias :require_generator :require_generators
|
35
|
-
|
36
|
-
module RSpec
|
37
|
-
module Generator
|
38
|
-
module Require
|
39
|
-
class << self
|
40
|
-
def parse_generator_hash hash
|
41
|
-
parse_generator_list hash.keys.first, hash.values.flatten
|
42
|
-
end
|
43
|
-
|
44
|
-
def parse_generator_list name, generators
|
45
|
-
if generators.empty?
|
46
|
-
require_generator! name
|
47
|
-
else
|
48
|
-
generators.each do |generator_name|
|
49
|
-
require_generator! name, generator_name
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def require_generator! name, generator=nil
|
55
|
-
file = (require_file_name name, generator)
|
56
|
-
puts "Loading generator: #{file}" if RSpec::Generator.debug?
|
57
|
-
require file
|
58
|
-
end
|
59
|
-
|
60
|
-
def require_file_name name, name_space=nil
|
61
|
-
File.join('generators', name.to_s, "#{name_space}", "#{name_space || name}_generator")
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
class << self
|
67
|
-
attr_accessor :generator, :test_method_name, :remove_temp_dir, :debug
|
68
|
-
|
69
|
-
def debug?
|
70
|
-
debug
|
71
|
-
end
|
72
|
-
|
73
|
-
def remove_rails_dir!
|
74
|
-
FileUtils.rm_rf ::TmpRails.root
|
75
|
-
end
|
76
|
-
|
77
|
-
def configure_root_dir path, options = {}
|
78
|
-
::Rails.application.configure do
|
79
|
-
config.root_dir = options == :custom ? TmpRails.root_dir(File.dirname(path) + '/../tmp', :custom) : TmpRails.root_dir(path)
|
80
|
-
end
|
81
|
-
|
82
|
-
::RSpec.configure do |config|
|
83
|
-
config.after(:suite) do
|
84
|
-
::RSpec::Generator.remove_rails_dir! if remove_temp_dir
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
::RSpec::Generators::TestCase.destination ::Rails.root
|
89
|
-
::Rails::Generators.configure!
|
90
|
-
end
|
91
|
-
|
92
|
-
def run_generator *args, &block
|
93
|
-
generator.run_generator *args
|
94
|
-
if block
|
95
|
-
block.arity < 1 ? generator.instance_eval(&block) : block.call(generator, self)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def check(&block)
|
100
|
-
if block
|
101
|
-
block.arity < 1 ? self.instance_eval(&block) : block.call(self)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def with(generator, &block)
|
106
|
-
if block
|
107
|
-
block.arity < 1 ? generator.instance_eval(&block) : block.call(generator, self, generator.class)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def with_generator &block
|
112
|
-
with(get_generator, &block)
|
113
|
-
end
|
114
|
-
|
115
|
-
def setup_generator test_method_name=nil, &block
|
116
|
-
clean! if test_method_name
|
117
|
-
generator = get_generator(test_method_name).extend(RSpec::Generator::Helpers)
|
118
|
-
if block
|
119
|
-
block.arity < 1 ? generator.class.instance_eval(&block) : block.call(generator.class)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
protected
|
124
|
-
|
125
|
-
def clean!
|
126
|
-
if generator
|
127
|
-
generator.class.generator_class = nil
|
128
|
-
end
|
129
|
-
@generator = nil
|
130
|
-
end
|
131
|
-
|
132
|
-
def get_generator test_method_name=nil
|
133
|
-
@generator ||= RSpec::Generators::TestCase.new(test_method_name + '_spec')
|
134
|
-
end
|
135
|
-
|
136
|
-
end # class self
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
|
141
|
-
module RSpec::Core
|
142
|
-
class ExampleGroup
|
143
|
-
def with_generator &block
|
144
|
-
RSpec::Generator.with_generator &block
|
145
|
-
end
|
146
|
-
|
147
|
-
def setup_generator test_method_name=nil, &block
|
148
|
-
RSpec::Generator.setup_generator test_method_name, &block
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|