generator_spec 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -4
- data/README.md +3 -5
- data/generator_spec.gemspec +3 -4
- data/lib/generator_spec.rb +12 -0
- data/lib/generator_spec/generator_example_group.rb +6 -0
- data/lib/generator_spec/test_case.rb +1 -1
- data/lib/generator_spec/version.rb +1 -1
- data/spec/generator_spec/generator_example_group_spec.rb +7 -0
- data/spec/generator_spec/matcher_spec.rb +216 -201
- data/spec/generator_spec/test_case_spec.rb +4 -6
- data/spec/spec_helper.rb +2 -4
- data/spec/support/file_system.rb +5 -1
- data/spec/support/helpers.rb +21 -0
- data/spec/support/matchers.rb +11 -0
- data/spec/support/test_generator/templates/migration.rb +3 -1
- metadata +16 -37
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -12,15 +12,14 @@ group :test do
|
|
12
12
|
end
|
13
13
|
```
|
14
14
|
|
15
|
-
Spec:
|
15
|
+
Spec (files in `spec/lib/generators` are recognized as generator type example group):
|
16
16
|
|
17
17
|
```ruby
|
18
18
|
# spec/lib/generators/test/test_generator_spec.rb
|
19
19
|
|
20
|
-
require "generator_spec
|
20
|
+
require "generator_spec"
|
21
21
|
|
22
22
|
describe TestGenerator do
|
23
|
-
include GeneratorSpec::TestCase
|
24
23
|
destination File.expand_path("../../tmp", __FILE__)
|
25
24
|
arguments %w(something)
|
26
25
|
|
@@ -38,8 +37,7 @@ end
|
|
38
37
|
An RSpec file matching DSL is also provided, taken with permission from [beard](https://github.com/carlhuda/beard/blob/master/spec/support/matcher.rb) by [carlhuda](https://github.com/carlhuda).
|
39
38
|
|
40
39
|
```ruby
|
41
|
-
describe TestGenerator, "using custom matcher" do
|
42
|
-
include GeneratorSpec::TestCase
|
40
|
+
describe TestGenerator, "using custom matcher", type: :generator do
|
43
41
|
destination File.expand_path("../../tmp", __FILE__)
|
44
42
|
|
45
43
|
before do
|
data/generator_spec.gemspec
CHANGED
@@ -18,8 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
|
-
s.add_dependency '
|
22
|
-
s.add_dependency 'railties', ['>= 3.0
|
23
|
-
s.add_development_dependency 'rspec'
|
24
|
-
s.add_development_dependency 'fakefs', '~> 0.4.1'
|
21
|
+
s.add_dependency 'activesupport', ['>= 3.0.0']
|
22
|
+
s.add_dependency 'railties', ['>= 3.0.0']
|
23
|
+
s.add_development_dependency 'rspec', '>= 2.14.0'
|
25
24
|
end
|
data/lib/generator_spec.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rspec/core'
|
2
|
+
require 'generator_spec/generator_example_group'
|
3
|
+
|
4
|
+
RSpec::configure do |c|
|
5
|
+
def c.escaped_path(*parts)
|
6
|
+
Regexp.compile(parts.join('[\\\/]') + '[\\\/]')
|
7
|
+
end
|
8
|
+
|
9
|
+
c.include GeneratorSpec::GeneratorExampleGroup, :type => :generator, :example_group => {
|
10
|
+
:file_path => c.escaped_path(%w[spec lib generators])
|
11
|
+
}
|
12
|
+
end
|
@@ -1,15 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
TMP_ROOT = Pathname.new(Dir.tmpdir)
|
2
5
|
|
3
6
|
describe TestGenerator, 'using custom matcher' do
|
4
7
|
include GeneratorSpec::TestCase
|
5
|
-
destination
|
8
|
+
destination TMP_ROOT
|
6
9
|
arguments %w(test --test)
|
7
|
-
|
10
|
+
|
8
11
|
before do
|
12
|
+
delete_directory(TMP_ROOT)
|
9
13
|
prepare_destination
|
10
14
|
run_generator
|
11
15
|
end
|
12
|
-
|
16
|
+
|
13
17
|
specify do
|
14
18
|
destination_root.should have_structure {
|
15
19
|
no_file 'test.rb'
|
@@ -30,7 +34,7 @@ describe TestGenerator, 'using custom matcher' do
|
|
30
34
|
end
|
31
35
|
}
|
32
36
|
end
|
33
|
-
|
37
|
+
|
34
38
|
it 'fails when it doesnt match' do
|
35
39
|
expect {
|
36
40
|
destination_root.should have_structure {
|
@@ -44,241 +48,252 @@ describe TestGenerator, 'using custom matcher' do
|
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
describe '#matches?' do
|
52
|
-
include FakeFS::SpecHelpers
|
53
|
-
|
54
|
-
before do
|
55
|
-
@file = File.new('test_file')
|
56
|
-
@location = TMP_ROOT.join('test_file')
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'with no contains' do
|
60
|
-
it 'doesnt throw if the file exists' do
|
61
|
-
write_file(@location, '')
|
62
|
-
expect {
|
63
|
-
@file.matches?(TMP_ROOT)
|
64
|
-
}.to_not throw_symbol
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'throws :failure if it doesnt exist' do
|
68
|
-
expect {
|
69
|
-
@file.matches?(TMP_ROOT)
|
70
|
-
}.to throw_symbol(:failure)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'with contains' do
|
51
|
+
module GeneratorSpec
|
52
|
+
module Matcher
|
53
|
+
describe File do
|
54
|
+
describe '#matches?' do
|
75
55
|
before do
|
76
|
-
|
56
|
+
delete_directory(TMP_ROOT)
|
77
57
|
end
|
78
58
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
59
|
+
let(:file) { File.new('test_file') }
|
60
|
+
let(:location) { TMP_ROOT.join('test_file') }
|
61
|
+
|
62
|
+
context 'with no contains' do
|
63
|
+
it 'doesnt throw if the file exists' do
|
64
|
+
write_file(location, '')
|
65
|
+
expect {
|
66
|
+
file.matches?(TMP_ROOT)
|
67
|
+
}.to_not throw_symbol
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'throws :failure if it doesnt exist' do
|
71
|
+
expect {
|
72
|
+
file.matches?(TMP_ROOT)
|
73
|
+
}.to throw_symbol(:failure)
|
74
|
+
end
|
84
75
|
end
|
85
76
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
77
|
+
context 'with contains' do
|
78
|
+
before do
|
79
|
+
write_file(location, 'class CreatePosts')
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'doesnt throw if the content includes the string' do
|
83
|
+
file.contains 'CreatePosts'
|
84
|
+
expect {
|
85
|
+
file.matches?(TMP_ROOT)
|
86
|
+
}.to_not throw_symbol
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'throws :failure if the contents dont include the string' do
|
90
|
+
file.contains 'PostsMigration'
|
91
|
+
expect {
|
92
|
+
file.matches?(TMP_ROOT)
|
93
|
+
}.to throw_symbol(:failure)
|
94
|
+
end
|
91
95
|
end
|
92
96
|
end
|
93
97
|
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe Migration do
|
97
|
-
include FakeFS::SpecHelpers
|
98
|
-
|
99
|
-
describe '#matches?' do
|
100
|
-
before do
|
101
|
-
@migration = Migration.new('create_posts')
|
102
|
-
@location = TMP_ROOT.join('123456_create_posts.rb')
|
103
|
-
end
|
104
98
|
|
105
|
-
|
106
|
-
|
107
|
-
write_file(@location, 'class CreatePosts')
|
108
|
-
expect {
|
109
|
-
@migration.matches?(TMP_ROOT)
|
110
|
-
}.to_not throw_symbol
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'throws :failure if it doesnt exist' do
|
114
|
-
expect {
|
115
|
-
@migration.matches?(TMP_ROOT)
|
116
|
-
}.to throw_symbol(:failure)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'with contains' do
|
99
|
+
describe Migration do
|
100
|
+
describe '#matches?' do
|
121
101
|
before do
|
122
|
-
|
102
|
+
delete_directory(TMP_ROOT)
|
123
103
|
end
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
104
|
+
|
105
|
+
let(:migration) { Migration.new('create_posts') }
|
106
|
+
let(:location) { TMP_ROOT.join('123456_create_posts.rb') }
|
107
|
+
|
108
|
+
context 'with no contains' do
|
109
|
+
it 'doesnt throw if the migration exists' do
|
110
|
+
write_file(location, 'class CreatePosts')
|
111
|
+
expect {
|
112
|
+
migration.matches?(TMP_ROOT)
|
113
|
+
}.to_not throw_symbol
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'throws :failure if it doesnt exist' do
|
117
|
+
expect {
|
118
|
+
migration.matches?(TMP_ROOT)
|
119
|
+
}.to throw_symbol(:failure)
|
120
|
+
end
|
130
121
|
end
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
122
|
+
|
123
|
+
context 'with contains' do
|
124
|
+
before do
|
125
|
+
write_file(location, 'class CreatePosts')
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'doesnt throw if the migration includes the given content' do
|
129
|
+
migration.contains('CreatePosts')
|
130
|
+
expect {
|
131
|
+
migration.matches?(TMP_ROOT)
|
132
|
+
}.to_not throw_symbol
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'throws failure if the migration doesnt include the given content' do
|
136
|
+
migration.contains('CreateNotes')
|
137
|
+
expect {
|
138
|
+
migration.matches?(TMP_ROOT)
|
139
|
+
}.to throw_symbol(:failure)
|
140
|
+
end
|
137
141
|
end
|
138
142
|
end
|
139
143
|
end
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
describe '#location' do
|
146
|
-
it 'equals the full path' do
|
147
|
-
Directory.new('test').location('test_2').should eq('test/test_2')
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
describe '#directory' do
|
152
|
-
context 'without a block' do
|
153
|
-
it 'adds a directory name to the tree' do
|
154
|
-
dir = Directory.new 'test' do
|
155
|
-
directory 'dir'
|
156
|
-
end
|
157
|
-
dir.tree['dir'].should eq(false)
|
144
|
+
|
145
|
+
describe Directory do
|
146
|
+
describe '#location' do
|
147
|
+
it 'equals the full path' do
|
148
|
+
Directory.new('test').location('test_2').should eq('test/test_2')
|
158
149
|
end
|
159
150
|
end
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
directory '
|
151
|
+
|
152
|
+
describe '#directory' do
|
153
|
+
context 'without a block' do
|
154
|
+
it 'adds a directory name to the tree' do
|
155
|
+
dir = Directory.new 'test' do
|
156
|
+
directory 'dir'
|
166
157
|
end
|
158
|
+
dir.tree['dir'].should eq(false)
|
167
159
|
end
|
168
|
-
dir.tree['dir'].should be_an_instance_of(Directory)
|
169
|
-
dir.tree['dir'].tree['test_2'].should eq(false)
|
170
160
|
end
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
161
|
+
|
162
|
+
context 'with a block' do
|
163
|
+
it 'add a directory object to the tree' do
|
164
|
+
dir = Directory.new 'test' do
|
165
|
+
directory 'dir' do
|
166
|
+
directory 'test_2'
|
167
|
+
end
|
168
|
+
end
|
169
|
+
dir.tree['dir'].should be_an_instance_of(Directory)
|
170
|
+
dir.tree['dir'].tree['test_2'].should eq(false)
|
171
|
+
end
|
178
172
|
end
|
179
|
-
dir.tree['test_file'].should be_an_instance_of(File)
|
180
173
|
end
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
174
|
+
|
175
|
+
describe '#file' do
|
176
|
+
it 'adds it to the tree' do
|
177
|
+
dir = Directory.new 'test' do
|
178
|
+
file 'test_file'
|
179
|
+
end
|
180
|
+
dir.tree['test_file'].should be_an_instance_of(File)
|
187
181
|
end
|
188
|
-
dir.tree['test_file'].should be_an_instance_of(Migration)
|
189
|
-
dir.tree['test_file'].instance_variable_get('@name').should eq('test/test_file')
|
190
182
|
end
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
@dir = Directory.new 'test' do
|
197
|
-
directory 'test_2'
|
183
|
+
|
184
|
+
describe '#file' do
|
185
|
+
it 'adds it to the tree' do
|
186
|
+
dir = Directory.new 'test' do
|
187
|
+
migration 'test_file'
|
198
188
|
end
|
199
|
-
|
200
|
-
|
201
|
-
it 'doesnt throw if the directory exists' do
|
202
|
-
write_directory(TMP_ROOT.join('test/test_2'))
|
203
|
-
expect {
|
204
|
-
@dir.matches?(TMP_ROOT)
|
205
|
-
}.to_not throw_symbol
|
206
|
-
end
|
207
|
-
|
208
|
-
it 'throws :failure if it doesnt exist' do
|
209
|
-
expect {
|
210
|
-
@dir.matches?(TMP_ROOT)
|
211
|
-
}.to throw_symbol(:failure)
|
189
|
+
dir.tree['test_file'].should be_an_instance_of(Migration)
|
190
|
+
dir.tree['test_file'].instance_variable_get('@name').should eq('test/test_file')
|
212
191
|
end
|
213
192
|
end
|
214
|
-
|
215
|
-
|
193
|
+
|
194
|
+
describe '#matches?' do
|
216
195
|
before do
|
217
|
-
|
218
|
-
|
219
|
-
|
196
|
+
delete_directory(TMP_ROOT)
|
197
|
+
end
|
198
|
+
|
199
|
+
context 'with a directory name' do
|
200
|
+
let(:dir) {
|
201
|
+
Directory.new 'test' do
|
202
|
+
directory 'test_2'
|
220
203
|
end
|
204
|
+
}
|
205
|
+
|
206
|
+
it 'doesnt throw if the directory exists' do
|
207
|
+
write_directory(TMP_ROOT.join('test/test_2'))
|
208
|
+
expect {
|
209
|
+
dir.matches?(TMP_ROOT)
|
210
|
+
}.to_not throw_symbol
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'throws :failure if it doesnt exist' do
|
214
|
+
expect {
|
215
|
+
dir.matches?(TMP_ROOT)
|
216
|
+
}.to throw_symbol(:failure)
|
221
217
|
end
|
222
|
-
write_directory(TMP_ROOT.join('test/test_2'))
|
223
218
|
end
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
219
|
+
|
220
|
+
context 'with a directory object' do
|
221
|
+
let(:dir) {
|
222
|
+
Directory.new 'test' do
|
223
|
+
directory 'test_2' do
|
224
|
+
file 'test_file'
|
225
|
+
end
|
226
|
+
end
|
227
|
+
}
|
228
|
+
|
229
|
+
before do
|
230
|
+
delete_directory(TMP_ROOT)
|
231
|
+
write_directory(TMP_ROOT.join('test/test_2'))
|
232
|
+
end
|
233
|
+
|
234
|
+
it 'doesnt throw if the file exists' do
|
235
|
+
write_file(TMP_ROOT.join('test/test_2/test_file'), '')
|
236
|
+
expect {
|
237
|
+
dir.matches?(TMP_ROOT)
|
238
|
+
}.to_not throw_symbol
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'throws :failure if it doesnt exist' do
|
242
|
+
expect {
|
243
|
+
dir.matches?(TMP_ROOT)
|
244
|
+
}.to throw_symbol(:failure)
|
245
|
+
end
|
230
246
|
end
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
247
|
+
|
248
|
+
context '#no_file' do
|
249
|
+
let(:dir) {
|
250
|
+
Directory.new 'test' do
|
251
|
+
no_file 'test_file'
|
252
|
+
end
|
253
|
+
}
|
254
|
+
before do
|
255
|
+
delete_directory(TMP_ROOT)
|
256
|
+
write_directory(TMP_ROOT.join('test'))
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'doesnt throw if the file exist' do
|
260
|
+
expect {
|
261
|
+
dir.matches?(TMP_ROOT)
|
262
|
+
}.to_not throw_symbol
|
263
|
+
end
|
264
|
+
|
265
|
+
it 'throws if the file exists' do
|
266
|
+
write_file(TMP_ROOT.join('test/test_file'), '')
|
267
|
+
expect {
|
268
|
+
dir.matches?(TMP_ROOT)
|
269
|
+
}.to throw_symbol(:failure)
|
270
|
+
end
|
236
271
|
end
|
237
272
|
end
|
238
|
-
|
239
|
-
|
273
|
+
|
274
|
+
end
|
275
|
+
|
276
|
+
describe Root do
|
277
|
+
describe '#matches?' do
|
240
278
|
before do
|
241
|
-
|
242
|
-
no_file 'test_file'
|
243
|
-
end
|
244
|
-
write_directory(TMP_ROOT.join('test'))
|
279
|
+
delete_directory(TMP_ROOT)
|
245
280
|
end
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
it '
|
254
|
-
|
255
|
-
|
256
|
-
@dir.matches?(TMP_ROOT)
|
257
|
-
}.to throw_symbol(:failure)
|
281
|
+
|
282
|
+
let(:root) {
|
283
|
+
Root.new 'test' do
|
284
|
+
directory 'test_dir'
|
285
|
+
end
|
286
|
+
}
|
287
|
+
|
288
|
+
it 'returns true on no failures' do
|
289
|
+
write_directory(TMP_ROOT.join('test/test_dir'))
|
290
|
+
root.matches?(TMP_ROOT).should be_true
|
258
291
|
end
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
end
|
263
|
-
|
264
|
-
describe Root do
|
265
|
-
include FakeFS::SpecHelpers
|
266
|
-
|
267
|
-
describe '#matches?' do
|
268
|
-
before do
|
269
|
-
@root = Root.new 'test' do
|
270
|
-
directory 'test_dir'
|
292
|
+
|
293
|
+
it 'returns false on failures' do
|
294
|
+
root.matches?(TMP_ROOT).should be_false
|
271
295
|
end
|
272
296
|
end
|
273
|
-
|
274
|
-
it 'returns true on no failures' do
|
275
|
-
write_directory(TMP_ROOT.join('test/test_dir'))
|
276
|
-
@root.matches?(TMP_ROOT).should be_true
|
277
|
-
end
|
278
|
-
|
279
|
-
it 'returns false on failures' do
|
280
|
-
@root.matches?(TMP_ROOT).should be_false
|
281
|
-
end
|
282
297
|
end
|
283
298
|
end
|
284
|
-
end
|
299
|
+
end
|
@@ -10,7 +10,7 @@ describe GeneratorSpec::TestCase do
|
|
10
10
|
self.should_receive(:described_class).and_return(TestClass)
|
11
11
|
include GeneratorSpec::TestCase
|
12
12
|
end
|
13
|
-
@klass.test_case_instance =
|
13
|
+
@klass.test_case_instance = double
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'passes unknown messages on to test_case_instance' do
|
@@ -24,8 +24,7 @@ describe GeneratorSpec::TestCase do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
describe TestGenerator, 'using normal assert methods' do
|
28
|
-
include GeneratorSpec::TestCase
|
27
|
+
describe TestGenerator, 'using normal assert methods', :type => 'generator' do
|
29
28
|
destination File.expand_path('../../tmp', __FILE__)
|
30
29
|
arguments %w(test --test)
|
31
30
|
|
@@ -47,8 +46,7 @@ describe TestGenerator, 'using normal assert methods' do
|
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
50
|
-
describe TestGenerator, 'with contexts' do
|
51
|
-
include GeneratorSpec::TestCase
|
49
|
+
describe TestGenerator, 'with contexts', :type => 'generator' do
|
52
50
|
destination File.expand_path('../../tmp', __FILE__)
|
53
51
|
before { prepare_destination }
|
54
52
|
|
@@ -67,4 +65,4 @@ describe TestGenerator, 'with contexts' do
|
|
67
65
|
assert_no_file 'config/initializers/test.rb'
|
68
66
|
end
|
69
67
|
end
|
70
|
-
end
|
68
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
require 'bundler/setup'
|
2
|
-
require 'active_record'
|
3
2
|
require 'rspec'
|
4
|
-
require 'generator_spec
|
5
|
-
require 'fakefs/spec_helpers'
|
3
|
+
require 'generator_spec'
|
6
4
|
|
7
5
|
Dir[Pathname.new(File.expand_path('../', __FILE__)).join('support/**/*.rb')].each {|f| require f}
|
8
6
|
|
9
7
|
RSpec.configure do |config|
|
10
8
|
config.include Helpers::FileSystem
|
11
|
-
end
|
9
|
+
end
|
data/spec/support/file_system.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
# taken from https://github.com/rspec/rspec-rails/blob/master/spec/support/helpers.rb
|
2
|
+
module Helpers
|
3
|
+
def stub_metadata(additional_metadata)
|
4
|
+
stub_metadata = metadata_with(additional_metadata)
|
5
|
+
RSpec::Core::ExampleGroup.stub(:metadata) { stub_metadata }
|
6
|
+
end
|
7
|
+
|
8
|
+
def metadata_with(additional_metadata)
|
9
|
+
m = RSpec::Core::Metadata.new
|
10
|
+
m.process("example group")
|
11
|
+
|
12
|
+
group_metadata = additional_metadata.delete(:example_group)
|
13
|
+
if group_metadata
|
14
|
+
m[:example_group].merge!(group_metadata)
|
15
|
+
end
|
16
|
+
m.merge!(additional_metadata)
|
17
|
+
m
|
18
|
+
end
|
19
|
+
|
20
|
+
RSpec.configure {|c| c.include self}
|
21
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# taken from https://raw.github.com/rspec/rspec-rails/master/spec/support/matchers.rb
|
2
|
+
|
3
|
+
RSpec::Matchers::define :be_included_in_files_in do |path|
|
4
|
+
match do |mod|
|
5
|
+
stub_metadata(
|
6
|
+
:example_group => {:file_path => "#{path}whatever_spec.rb:15"}
|
7
|
+
)
|
8
|
+
group = RSpec::Core::ExampleGroup.describe
|
9
|
+
group.included_modules.include?(mod)
|
10
|
+
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: generator_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,19 +9,16 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06
|
12
|
+
date: 2013-11-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: activesupport
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
22
|
-
- - <=
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: '4.0'
|
21
|
+
version: 3.0.0
|
25
22
|
type: :runtime
|
26
23
|
prerelease: false
|
27
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,10 +26,7 @@ dependencies:
|
|
29
26
|
requirements:
|
30
27
|
- - ! '>='
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
33
|
-
- - <=
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: '4.0'
|
29
|
+
version: 3.0.0
|
36
30
|
- !ruby/object:Gem::Dependency
|
37
31
|
name: railties
|
38
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,10 +34,7 @@ dependencies:
|
|
40
34
|
requirements:
|
41
35
|
- - ! '>='
|
42
36
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
44
|
-
- - <=
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '4.0'
|
37
|
+
version: 3.0.0
|
47
38
|
type: :runtime
|
48
39
|
prerelease: false
|
49
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -51,10 +42,7 @@ dependencies:
|
|
51
42
|
requirements:
|
52
43
|
- - ! '>='
|
53
44
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
- - <=
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: '4.0'
|
45
|
+
version: 3.0.0
|
58
46
|
- !ruby/object:Gem::Dependency
|
59
47
|
name: rspec
|
60
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,7 +50,7 @@ dependencies:
|
|
62
50
|
requirements:
|
63
51
|
- - ! '>='
|
64
52
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
53
|
+
version: 2.14.0
|
66
54
|
type: :development
|
67
55
|
prerelease: false
|
68
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -70,23 +58,7 @@ dependencies:
|
|
70
58
|
requirements:
|
71
59
|
- - ! '>='
|
72
60
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
74
|
-
- !ruby/object:Gem::Dependency
|
75
|
-
name: fakefs
|
76
|
-
requirement: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
|
-
requirements:
|
79
|
-
- - ~>
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: 0.4.1
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
|
-
requirements:
|
87
|
-
- - ~>
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.4.1
|
61
|
+
version: 2.14.0
|
90
62
|
description: Test Rails generators with RSpec
|
91
63
|
email:
|
92
64
|
- steve@hodgkiss.me.uk
|
@@ -103,13 +75,17 @@ files:
|
|
103
75
|
- Rakefile
|
104
76
|
- generator_spec.gemspec
|
105
77
|
- lib/generator_spec.rb
|
78
|
+
- lib/generator_spec/generator_example_group.rb
|
106
79
|
- lib/generator_spec/matcher.rb
|
107
80
|
- lib/generator_spec/test_case.rb
|
108
81
|
- lib/generator_spec/version.rb
|
82
|
+
- spec/generator_spec/generator_example_group_spec.rb
|
109
83
|
- spec/generator_spec/matcher_spec.rb
|
110
84
|
- spec/generator_spec/test_case_spec.rb
|
111
85
|
- spec/spec_helper.rb
|
112
86
|
- spec/support/file_system.rb
|
87
|
+
- spec/support/helpers.rb
|
88
|
+
- spec/support/matchers.rb
|
113
89
|
- spec/support/test_generator/templates/initializer.rb
|
114
90
|
- spec/support/test_generator/templates/migration.rb
|
115
91
|
- spec/support/test_generator/test_generator.rb
|
@@ -138,10 +114,13 @@ signing_key:
|
|
138
114
|
specification_version: 3
|
139
115
|
summary: Test Rails generators with RSpec
|
140
116
|
test_files:
|
117
|
+
- spec/generator_spec/generator_example_group_spec.rb
|
141
118
|
- spec/generator_spec/matcher_spec.rb
|
142
119
|
- spec/generator_spec/test_case_spec.rb
|
143
120
|
- spec/spec_helper.rb
|
144
121
|
- spec/support/file_system.rb
|
122
|
+
- spec/support/helpers.rb
|
123
|
+
- spec/support/matchers.rb
|
145
124
|
- spec/support/test_generator/templates/initializer.rb
|
146
125
|
- spec/support/test_generator/templates/migration.rb
|
147
126
|
- spec/support/test_generator/test_generator.rb
|