1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
# Generators are not automatically loaded by rails
require 'generators/rspec/feature/feature_generator'
require 'support/generators'
RSpec.describe Rspec::Generators::FeatureGenerator, type: :generator do
setup_default_destination
describe 'feature specs' do
describe 'are generated independently from the command line' do
before do
run_generator %w[posts]
end
describe 'the spec' do
subject(:feature_spec) { file('spec/features/posts_spec.rb') }
it 'includes the standard boilerplate' do
expect(
feature_spec
).to contain(/require 'rails_helper'/).and(contain(/^RSpec.feature "Posts", #{type_metatag(:feature)}/))
end
end
end
describe 'are generated with the correct namespace' do
before do
run_generator %w[folder/posts]
end
describe 'the spec' do
subject(:feature_spec) { file('spec/features/folder/posts_spec.rb') }
it 'includes the standard boilerplate' do
expect(feature_spec).to contain(/^RSpec.feature "Folder::Posts", #{type_metatag(:feature)}/)
end
end
end
describe 'are singularized appropriately with the --singularize flag' do
before do
run_generator %w[posts --singularize]
end
describe 'the spec' do
subject(:feature_spec) { file('spec/features/post_spec.rb') }
it "contains the singularized feature" do
expect(feature_spec).to contain(/^RSpec.feature "Post", #{type_metatag(:feature)}/)
end
end
end
describe "are not generated" do
before do
run_generator %w[posts --no-feature-specs]
end
describe "the spec" do
subject(:feature_spec) { file('spec/features/posts_spec.rb') }
it "does not exist" do
expect(File.exist?(feature_spec)).to be false
end
end
end
end
end
|