genspec 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +122 -0
  3. data/Rakefile +55 -0
  4. data/VERSION +1 -0
  5. data/genspec.gemspec +83 -0
  6. data/lib/genspec.rb +14 -0
  7. data/lib/genspec/generation_matchers.rb +27 -0
  8. data/lib/genspec/generation_matchers/generation_matcher.rb +147 -0
  9. data/lib/genspec/generation_matchers/result_matcher.rb +42 -0
  10. data/lib/genspec/generator_example_group.rb +71 -0
  11. data/pkg/genspec-0.0.0.gem +0 -0
  12. data/pkg/genspec-0.1.0.gem +0 -0
  13. data/rdoc/classes/GenSpec.html +124 -0
  14. data/rdoc/classes/GenSpec/GenerationMatchers.html +197 -0
  15. data/rdoc/classes/GenSpec/GenerationMatchers/GenerationMatcher.html +363 -0
  16. data/rdoc/classes/GenSpec/GenerationMatchers/ResultMatcher.html +241 -0
  17. data/rdoc/classes/GenSpec/GeneratorExampleGroup.html +285 -0
  18. data/rdoc/created.rid +1 -0
  19. data/rdoc/files/README_rdoc.html +261 -0
  20. data/rdoc/files/lib/genspec/generation_matchers/generation_matcher_rb.html +101 -0
  21. data/rdoc/files/lib/genspec/generation_matchers/result_matcher_rb.html +101 -0
  22. data/rdoc/files/lib/genspec/generation_matchers_rb.html +109 -0
  23. data/rdoc/files/lib/genspec/generator_example_group_rb.html +101 -0
  24. data/rdoc/files/lib/genspec_rb.html +114 -0
  25. data/rdoc/fr_class_index.html +31 -0
  26. data/rdoc/fr_file_index.html +32 -0
  27. data/rdoc/fr_method_index.html +46 -0
  28. data/rdoc/index.html +26 -0
  29. data/rdoc/rdoc-style.css +208 -0
  30. data/spec/environment_spec.rb +18 -0
  31. data/spec/generators/test_spec.rb +96 -0
  32. data/spec/spec_helper.rb +4 -0
  33. data/spec/support/generators/test/templates/file +1 -0
  34. data/spec/support/generators/test/test_generator.rb +29 -0
  35. metadata +124 -0
@@ -0,0 +1,208 @@
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; }
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ # To make sure test environment is loading. Other successful tests will render
4
+ # this one redundant, so it's safe to remove.
5
+ #
6
+ # For those who would flame me, this gem evolved out of a bit of test code that
7
+ # was written for another project. Since the test code itself became a gem, I
8
+ # didn't necessarily have tests for my tests.
9
+ #
10
+ # Since I'm starting with a code base before the test environment exists, this
11
+ # file merely assures me that the test environment is loading.
12
+ #
13
+ describe "rails" do
14
+ it "should be defined" do
15
+ Rails
16
+ GenSpec
17
+ end
18
+ end
@@ -0,0 +1,96 @@
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
@@ -0,0 +1,4 @@
1
+ require File.expand_path("../../../../../config/environment", __FILE__)
2
+
3
+ Rails::Generator::Base.append_sources Rails::Generator::PathSource.new(:test,
4
+ File.expand_path("../support/generators", __FILE__))
@@ -0,0 +1 @@
1
+ content!
@@ -0,0 +1,29 @@
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
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: genspec
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 1
9
+ version: 0.1.1
10
+ platform: ruby
11
+ authors:
12
+ - Colin MacKenzie IV
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-06-21 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: sc-core-ext
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 1
41
+ - 2
42
+ - 0
43
+ version: 1.2.0
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ description: Just like rspec-rails uses the structure of your spec/ directory to infer which test is being run (controllers, helpers, lib, etc.), you just need to create a spec/generators directory and put your generator specs in there.
47
+ email: sinisterchipmunk@gmail.com
48
+ executables: []
49
+
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - LICENSE
54
+ - README.rdoc
55
+ files:
56
+ - LICENSE
57
+ - README.rdoc
58
+ - Rakefile
59
+ - VERSION
60
+ - genspec.gemspec
61
+ - lib/genspec.rb
62
+ - lib/genspec/generation_matchers.rb
63
+ - lib/genspec/generation_matchers/generation_matcher.rb
64
+ - lib/genspec/generation_matchers/result_matcher.rb
65
+ - lib/genspec/generator_example_group.rb
66
+ - pkg/genspec-0.0.0.gem
67
+ - pkg/genspec-0.1.0.gem
68
+ - rdoc/classes/GenSpec.html
69
+ - rdoc/classes/GenSpec/GenerationMatchers.html
70
+ - rdoc/classes/GenSpec/GenerationMatchers/GenerationMatcher.html
71
+ - rdoc/classes/GenSpec/GenerationMatchers/ResultMatcher.html
72
+ - rdoc/classes/GenSpec/GeneratorExampleGroup.html
73
+ - rdoc/created.rid
74
+ - rdoc/files/README_rdoc.html
75
+ - rdoc/files/lib/genspec/generation_matchers/generation_matcher_rb.html
76
+ - rdoc/files/lib/genspec/generation_matchers/result_matcher_rb.html
77
+ - rdoc/files/lib/genspec/generation_matchers_rb.html
78
+ - rdoc/files/lib/genspec/generator_example_group_rb.html
79
+ - rdoc/files/lib/genspec_rb.html
80
+ - rdoc/fr_class_index.html
81
+ - rdoc/fr_file_index.html
82
+ - rdoc/fr_method_index.html
83
+ - rdoc/index.html
84
+ - rdoc/rdoc-style.css
85
+ - spec/environment_spec.rb
86
+ - spec/generators/test_spec.rb
87
+ - spec/spec_helper.rb
88
+ - spec/support/generators/test/templates/file
89
+ - spec/support/generators/test/test_generator.rb
90
+ has_rdoc: true
91
+ homepage: http://www.thoughtsincomputation.com
92
+ licenses: []
93
+
94
+ post_install_message:
95
+ rdoc_options:
96
+ - --charset=UTF-8
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ requirements: []
114
+
115
+ rubyforge_project:
116
+ rubygems_version: 1.3.6
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: Simple, expressive Rails generator testing for RSpec.
120
+ test_files:
121
+ - spec/environment_spec.rb
122
+ - spec/generators/test_spec.rb
123
+ - spec/spec_helper.rb
124
+ - spec/support/generators/test/test_generator.rb