Skip to content

Commit a7489f5

Browse files
committed
Clean up generator for generator specs
Don't force pluralization of the generator name in the generated spec and use the full generator name in the spec description. Also clean up an extra whitespace and empty line in the template. Note that the generator class constant cannot be directly used in the spec description as it isn't loaded by default.
1 parent 260b3bf commit a7489f5

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

features/generator_specs/generator_specs.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Feature: Generator spec
1212
create lib/generators/my_generator/USAGE
1313
create lib/generators/my_generator/templates
1414
invoke rspec
15-
create spec/generator/my_generators_generator_spec.rb
15+
create spec/generator/my_generator_generator_spec.rb
1616
"""
1717

1818
Scenario: Use custom generator with customized `default-path`
@@ -29,5 +29,5 @@ Feature: Generator spec
2929
create lib/generators/my_generator/USAGE
3030
create lib/generators/my_generator/templates
3131
invoke rspec
32-
create behaviour/generator/my_generators_generator_spec.rb
32+
create behaviour/generator/my_generator_generator_spec.rb
3333
"""

lib/generators/rspec/generator/generator_generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Rspec
44
module Generators
55
# @private
66
class GeneratorGenerator < Base
7-
class_option :generator_specs, type: :boolean, default: true, desc: "Generate generator specs"
7+
class_option :generator_specs, type: :boolean, default: true, desc: 'Generate generator specs'
88

99
def generate_generator_spec
1010
return unless options[:generator_specs]
@@ -17,7 +17,7 @@ def template_name
1717
end
1818

1919
def filename
20-
"#{table_name}_generator_spec.rb"
20+
"#{file_name}_generator_spec.rb"
2121
end
2222
end
2323
end
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require 'rails_helper'
22

3-
RSpec.describe "<%= class_name.pluralize %>", <%= type_metatag(:generator) %> do
4-
3+
RSpec.describe "<%= class_name %>Generator", <%= type_metatag(:generator) %> do
54
pending "add some scenarios (or delete) #{__FILE__}"
65
end

spec/generators/rspec/generator/generator_generator_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
end
1212

1313
it "include the standard boilerplate" do
14-
expect(generator_spec).to contain(/require 'rails_helper'/).and(contain(/^RSpec.describe "Posts", #{type_metatag(:generator)}/))
14+
expect(generator_spec).to contain(/require 'rails_helper'/).and(contain(/^RSpec.describe "PostsGenerator", #{type_metatag(:generator)}/))
1515
end
1616
end
1717
end

0 commit comments

Comments
 (0)