File: authentication_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 (34 lines) | stat: -rw-r--r-- 927 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
30
31
32
33
34
# Generators are not automatically loaded by Rails
require 'generators/rspec/authentication/authentication_generator'
require 'support/generators'

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

  it 'runs both the model and fixture tasks' do
    gen = generator
    expect(gen).to receive :create_user_spec
    expect(gen).to receive :create_fixture_file
    gen.invoke_all
  end

  describe 'the generated files' do
    it 'creates the user spec' do
      run_generator

      expect(File.exist?(file('spec/models/user_spec.rb'))).to be true
    end

    describe 'with fixture replacement' do
      before do
        run_generator ['--fixture-replacement=factory_bot']
      end

      describe 'the fixtures' do
        it "will skip the file" do
          expect(File.exist?(file('spec/fixtures/users.yml'))).to be false
        end
      end
    end
  end
end