genspec 0.1.1 → 0.2.0.prerails3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +79 -31
- data/Rakefile +69 -22
- data/VERSION +1 -1
- data/genspec.gemspec +31 -40
- data/lib/gen_spec.rb +1 -0
- data/lib/genspec.rb +23 -8
- data/lib/genspec/generator_example_group.rb +47 -52
- data/lib/genspec/matchers.rb +59 -0
- data/lib/genspec/matchers/base.rb +148 -0
- data/lib/genspec/matchers/generation_method_matcher.rb +88 -0
- data/lib/genspec/matchers/output_matcher.rb +34 -0
- data/lib/genspec/matchers/result_matcher.rb +28 -0
- data/lib/genspec/shell.rb +99 -0
- data/pkg/genspec-0.1.1.gem +0 -0
- data/pkg/genspec-0.2.0.pre1.gem +0 -0
- data/pkg/genspec-0.2.0.prerails3.1.gem +0 -0
- data/spec/generators/test_rails3_spec.rb +74 -0
- data/spec/rcov.opts +2 -0
- data/spec/rspec.opts +2 -0
- data/spec/spec_helper.rb +10 -3
- data/spec/support/generators/test_rails3/USAGE +8 -0
- data/spec/support/generators/{test → test_rails3}/templates/file +0 -0
- data/spec/support/generators/test_rails3/test_rails3_generator.rb +23 -0
- metadata +48 -40
- data/lib/genspec/generation_matchers.rb +0 -27
- data/lib/genspec/generation_matchers/generation_matcher.rb +0 -147
- data/lib/genspec/generation_matchers/result_matcher.rb +0 -42
- data/pkg/genspec-0.0.0.gem +0 -0
- data/pkg/genspec-0.1.0.gem +0 -0
- data/rdoc/classes/GenSpec.html +0 -124
- data/rdoc/classes/GenSpec/GenerationMatchers.html +0 -197
- data/rdoc/classes/GenSpec/GenerationMatchers/GenerationMatcher.html +0 -363
- data/rdoc/classes/GenSpec/GenerationMatchers/ResultMatcher.html +0 -241
- data/rdoc/classes/GenSpec/GeneratorExampleGroup.html +0 -285
- data/rdoc/created.rid +0 -1
- data/rdoc/files/README_rdoc.html +0 -261
- data/rdoc/files/lib/genspec/generation_matchers/generation_matcher_rb.html +0 -101
- data/rdoc/files/lib/genspec/generation_matchers/result_matcher_rb.html +0 -101
- data/rdoc/files/lib/genspec/generation_matchers_rb.html +0 -109
- data/rdoc/files/lib/genspec/generator_example_group_rb.html +0 -101
- data/rdoc/files/lib/genspec_rb.html +0 -114
- data/rdoc/fr_class_index.html +0 -31
- data/rdoc/fr_file_index.html +0 -32
- data/rdoc/fr_method_index.html +0 -46
- data/rdoc/index.html +0 -26
- data/rdoc/rdoc-style.css +0 -208
- data/spec/generators/test_spec.rb +0 -96
- data/spec/support/generators/test/test_generator.rb +0 -29
data/rdoc/rdoc-style.css
DELETED
@@ -1,208 +0,0 @@
|
|
1
|
-
|
2
|
-
body {
|
3
|
-
font-family: Verdana,Arial,Helvetica,sans-serif;
|
4
|
-
font-size: 90%;
|
5
|
-
margin: 0;
|
6
|
-
margin-left: 40px;
|
7
|
-
padding: 0;
|
8
|
-
background: white;
|
9
|
-
}
|
10
|
-
|
11
|
-
h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
|
12
|
-
h1 { font-size: 150%; }
|
13
|
-
h2,h3,h4 { margin-top: 1em; }
|
14
|
-
|
15
|
-
a { background: #eef; color: #039; text-decoration: none; }
|
16
|
-
a:hover { background: #039; color: #eef; }
|
17
|
-
|
18
|
-
/* Override the base stylesheet's Anchor inside a table cell */
|
19
|
-
td > a {
|
20
|
-
background: transparent;
|
21
|
-
color: #039;
|
22
|
-
text-decoration: none;
|
23
|
-
}
|
24
|
-
|
25
|
-
/* and inside a section title */
|
26
|
-
.section-title > a {
|
27
|
-
background: transparent;
|
28
|
-
color: #eee;
|
29
|
-
text-decoration: none;
|
30
|
-
}
|
31
|
-
|
32
|
-
/* === Structural elements =================================== */
|
33
|
-
|
34
|
-
div#index {
|
35
|
-
margin: 0;
|
36
|
-
margin-left: -40px;
|
37
|
-
padding: 0;
|
38
|
-
font-size: 90%;
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
div#index a {
|
43
|
-
margin-left: 0.7em;
|
44
|
-
}
|
45
|
-
|
46
|
-
div#index .section-bar {
|
47
|
-
margin-left: 0px;
|
48
|
-
padding-left: 0.7em;
|
49
|
-
background: #ccc;
|
50
|
-
font-size: small;
|
51
|
-
}
|
52
|
-
|
53
|
-
|
54
|
-
div#classHeader, div#fileHeader {
|
55
|
-
width: auto;
|
56
|
-
color: white;
|
57
|
-
padding: 0.5em 1.5em 0.5em 1.5em;
|
58
|
-
margin: 0;
|
59
|
-
margin-left: -40px;
|
60
|
-
border-bottom: 3px solid #006;
|
61
|
-
}
|
62
|
-
|
63
|
-
div#classHeader a, div#fileHeader a {
|
64
|
-
background: inherit;
|
65
|
-
color: white;
|
66
|
-
}
|
67
|
-
|
68
|
-
div#classHeader td, div#fileHeader td {
|
69
|
-
background: inherit;
|
70
|
-
color: white;
|
71
|
-
}
|
72
|
-
|
73
|
-
|
74
|
-
div#fileHeader {
|
75
|
-
background: #057;
|
76
|
-
}
|
77
|
-
|
78
|
-
div#classHeader {
|
79
|
-
background: #048;
|
80
|
-
}
|
81
|
-
|
82
|
-
|
83
|
-
.class-name-in-header {
|
84
|
-
font-size: 180%;
|
85
|
-
font-weight: bold;
|
86
|
-
}
|
87
|
-
|
88
|
-
|
89
|
-
div#bodyContent {
|
90
|
-
padding: 0 1.5em 0 1.5em;
|
91
|
-
}
|
92
|
-
|
93
|
-
div#description {
|
94
|
-
padding: 0.5em 1.5em;
|
95
|
-
background: #efefef;
|
96
|
-
border: 1px dotted #999;
|
97
|
-
}
|
98
|
-
|
99
|
-
div#description h1,h2,h3,h4,h5,h6 {
|
100
|
-
color: #125;;
|
101
|
-
background: transparent;
|
102
|
-
}
|
103
|
-
|
104
|
-
div#validator-badges {
|
105
|
-
text-align: center;
|
106
|
-
}
|
107
|
-
div#validator-badges img { border: 0; }
|
108
|
-
|
109
|
-
div#copyright {
|
110
|
-
color: #333;
|
111
|
-
background: #efefef;
|
112
|
-
font: 0.75em sans-serif;
|
113
|
-
margin-top: 5em;
|
114
|
-
margin-bottom: 0;
|
115
|
-
padding: 0.5em 2em;
|
116
|
-
}
|
117
|
-
|
118
|
-
|
119
|
-
/* === Classes =================================== */
|
120
|
-
|
121
|
-
table.header-table {
|
122
|
-
color: white;
|
123
|
-
font-size: small;
|
124
|
-
}
|
125
|
-
|
126
|
-
.type-note {
|
127
|
-
font-size: small;
|
128
|
-
color: #DEDEDE;
|
129
|
-
}
|
130
|
-
|
131
|
-
.xxsection-bar {
|
132
|
-
background: #eee;
|
133
|
-
color: #333;
|
134
|
-
padding: 3px;
|
135
|
-
}
|
136
|
-
|
137
|
-
.section-bar {
|
138
|
-
color: #333;
|
139
|
-
border-bottom: 1px solid #999;
|
140
|
-
margin-left: -20px;
|
141
|
-
}
|
142
|
-
|
143
|
-
|
144
|
-
.section-title {
|
145
|
-
background: #79a;
|
146
|
-
color: #eee;
|
147
|
-
padding: 3px;
|
148
|
-
margin-top: 2em;
|
149
|
-
margin-left: -30px;
|
150
|
-
border: 1px solid #999;
|
151
|
-
}
|
152
|
-
|
153
|
-
.top-aligned-row { vertical-align: top }
|
154
|
-
.bottom-aligned-row { vertical-align: bottom }
|
155
|
-
|
156
|
-
/* --- Context section classes ----------------------- */
|
157
|
-
|
158
|
-
.context-row { }
|
159
|
-
.context-item-name { font-family: monospace; font-weight: bold; color: black; }
|
160
|
-
.context-item-value { font-size: small; color: #448; }
|
161
|
-
.context-item-desc { color: #333; padding-left: 2em; }
|
162
|
-
|
163
|
-
/* --- Method classes -------------------------- */
|
164
|
-
.method-detail {
|
165
|
-
background: #efefef;
|
166
|
-
padding: 0;
|
167
|
-
margin-top: 0.5em;
|
168
|
-
margin-bottom: 1em;
|
169
|
-
border: 1px dotted #ccc;
|
170
|
-
}
|
171
|
-
.method-heading {
|
172
|
-
color: black;
|
173
|
-
background: #ccc;
|
174
|
-
border-bottom: 1px solid #666;
|
175
|
-
padding: 0.2em 0.5em 0 0.5em;
|
176
|
-
}
|
177
|
-
.method-signature { color: black; background: inherit; }
|
178
|
-
.method-name { font-weight: bold; }
|
179
|
-
.method-args { font-style: italic; }
|
180
|
-
.method-description { padding: 0 0.5em 0 0.5em; }
|
181
|
-
|
182
|
-
/* --- Source code sections -------------------- */
|
183
|
-
|
184
|
-
a.source-toggle { font-size: 90%; }
|
185
|
-
div.method-source-code {
|
186
|
-
background: #262626;
|
187
|
-
color: #ffdead;
|
188
|
-
margin: 1em;
|
189
|
-
padding: 0.5em;
|
190
|
-
border: 1px dashed #999;
|
191
|
-
overflow: hidden;
|
192
|
-
}
|
193
|
-
|
194
|
-
div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
195
|
-
|
196
|
-
/* --- Ruby keyword styles --------------------- */
|
197
|
-
|
198
|
-
.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
|
199
|
-
|
200
|
-
.ruby-constant { color: #7fffd4; background: transparent; }
|
201
|
-
.ruby-keyword { color: #00ffff; background: transparent; }
|
202
|
-
.ruby-ivar { color: #eedd82; background: transparent; }
|
203
|
-
.ruby-operator { color: #00ffee; background: transparent; }
|
204
|
-
.ruby-identifier { color: #ffdead; background: transparent; }
|
205
|
-
.ruby-node { color: #ffa07a; background: transparent; }
|
206
|
-
.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
|
207
|
-
.ruby-regexp { color: #ffa07a; background: transparent; }
|
208
|
-
.ruby-value { color: #7fffd4; background: transparent; }
|
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe :test do
|
4
|
-
context "with no options or arguments" do
|
5
|
-
it "should generate a file called default_file" do
|
6
|
-
subject.should generate("default_file")
|
7
|
-
subject.should_not generate("some_other_file")
|
8
|
-
|
9
|
-
subject.should generate(:file)
|
10
|
-
subject.should generate(:file, "file", "default_file")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should generate a file with specific content" do
|
14
|
-
subject.should generate("default_file") { |content| content.should == "content!" }
|
15
|
-
subject.should generate("default_file") { |content| content.should_not == "!content" }
|
16
|
-
subject.should_not generate("some_other_file")
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should check for class collisions" do
|
20
|
-
subject.should generate(:class_collisions)
|
21
|
-
subject.should generate(:class_collisions, 'ActionController::Base')
|
22
|
-
subject.should_not generate(:class_collisions, 'ActionController')
|
23
|
-
subject.should generate(:class_collisions, 'SomethingValid')
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should generate a template called 'default_template'" do
|
27
|
-
subject.should generate(:template)
|
28
|
-
subject.should generate(:template, 'file', 'file_template')
|
29
|
-
end
|
30
|
-
|
31
|
-
it "shoud generate a directory called 'a_directory'" do
|
32
|
-
subject.should generate(:directory)
|
33
|
-
subject.should generate(:directory, "a_directory")
|
34
|
-
subject.should generate("a_directory")
|
35
|
-
subject.should_not generate(:directory, 'another_directory')
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should generate a migration template" do
|
39
|
-
subject.should generate(:migration_template, "file", "directory", :migration_file_name => 'migration')
|
40
|
-
# Uh, is there an easier, not-so-internally-dependent way to see if migration templates are generated?
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should generate resource routes" do
|
44
|
-
subject.should generate(:route_resources, 'model')
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should generate a readme" do
|
48
|
-
# we have to silence stdout because readme prints to stdout. Duh, right?
|
49
|
-
# That's also the reason for the :readme option. That way we can default it to 'disabled' for all other
|
50
|
-
# tests.
|
51
|
-
stdout = $stdout
|
52
|
-
$stdout = StringIO.new("")
|
53
|
-
self.class.with_options :readme => true
|
54
|
-
subject.should generate(:readme)
|
55
|
-
subject.should generate(:readme, "file")
|
56
|
-
$stdout = stdout
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context "with options" do
|
61
|
-
with_options :help => true do
|
62
|
-
it "should generate 'Rails Info:'" do
|
63
|
-
subject.should output("Rails Info:")
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should generate 'Rails Info:'" do
|
67
|
-
subject.should output(/rails info\:/i)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context "with arguments" do
|
73
|
-
with_args :test_arg
|
74
|
-
|
75
|
-
it "should generate a :file from template 'file' to file 'test_arg'" do
|
76
|
-
subject.should generate(:file, "file", "test_arg")
|
77
|
-
end
|
78
|
-
|
79
|
-
it "should generate file 'test_arg'" do
|
80
|
-
subject.should generate('test_arg')
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
# FIXME: Uh, how best to write a spec around this? I'm actually trying to test #with_args with a block...
|
85
|
-
with_args :test_arg do
|
86
|
-
it "should generate file 'test_arg'" do
|
87
|
-
subject.should generate('test_arg')
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
with_options :help => true do
|
92
|
-
it "should generate 'Rails Info:'" do
|
93
|
-
subject.should output("Rails Info:")
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
class TestGenerator < Rails::Generator::Base
|
2
|
-
def manifest
|
3
|
-
record do |m|
|
4
|
-
if args.empty?
|
5
|
-
m.file "file", "default_file"
|
6
|
-
else
|
7
|
-
m.file "file", args.first
|
8
|
-
end
|
9
|
-
|
10
|
-
m.template 'file', 'file_template'
|
11
|
-
m.directory 'a_directory'
|
12
|
-
|
13
|
-
m.class_collisions 'ActionController::Base'
|
14
|
-
m.class_collisions 'SomethingValid'
|
15
|
-
|
16
|
-
m.migration_template "file", "directory", :migration_file_name => 'migration'
|
17
|
-
|
18
|
-
m.route_resources 'model'
|
19
|
-
|
20
|
-
if options[:readme]
|
21
|
-
m.readme 'file'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def add_options!(opt)
|
27
|
-
opt.on('--readme') { |o| o[:readme] = true }
|
28
|
-
end
|
29
|
-
end
|