File: job_generator_spec.rb

package info (click to toggle)
ruby-rspec-rails 8.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,804 kB
  • sloc: ruby: 10,881; sh: 198; makefile: 6
file content (29 lines) | stat: -rw-r--r-- 971 bytes parent folder | download | duplicates (2)
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/job/job_generator'
require 'support/generators'

RSpec.describe Rspec::Generators::JobGenerator, type: :generator, skip: !RSpec::Rails::FeatureCheck.has_active_job? do
  setup_default_destination

  describe 'the generated files' do
    before { run_generator [file_name] }

    subject(:job_spec) { file('spec/jobs/user_job_spec.rb') }

    context 'with file_name without job as suffix' do
      let(:file_name) { 'user' }

      it 'creates the standard boiler plate' do
        expect(job_spec).to contain(/require 'rails_helper'/).and(contain(/describe UserJob, #{type_metatag(:job)}/))
      end
    end

    context 'with file_name with job as suffix' do
      let(:file_name) { 'user_job' }

      it 'creates the standard boiler plate' do
        expect(job_spec).to contain(/require 'rails_helper'/).and(contain(/describe UserJob, #{type_metatag(:job)}/))
      end
    end
  end
end