File: helper_generator_spec.rb

package info (click to toggle)
ruby-rspec-rails 7.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,796 kB
  • sloc: ruby: 11,068; sh: 198; makefile: 6
file content (29 lines) | stat: -rw-r--r-- 807 bytes parent folder | download
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
# Generators are not automatically loaded by Rails
require 'generators/rspec/helper/helper_generator'
require 'support/generators'

RSpec.describe Rspec::Generators::HelperGenerator, type: :generator do
  setup_default_destination

  subject(:helper_spec) { file('spec/helpers/posts_helper_spec.rb') }

  describe 'generated by default' do
    before do
      run_generator %w[posts]
    end

    it 'includes the standard boilerplate' do
      expect(helper_spec).to contain(/require 'rails_helper'/).and(contain(/^RSpec.describe PostsHelper, #{type_metatag(:helper)}/))
    end
  end

  describe 'skipped with a flag' do
    before do
      run_generator %w[posts --no-helper_specs]
    end

    it 'does not create the helper spec' do
      expect(File.exist?(helper_spec)).to be false
    end
  end
end