File: system_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 (35 lines) | stat: -rw-r--r-- 964 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
35
# Generators are not automatically loaded by rails
require 'generators/rspec/system/system_generator'
require 'support/generators'

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

  describe "system specs" do
    subject(:system_spec) { file("spec/system/posts_spec.rb") }

    describe "are generated independently from the command line" do
      before do
        run_generator %w[posts]
      end

      describe "the spec" do
        it "contains the standard boilerplate" do
          expect(system_spec).to contain(/require 'rails_helper'/).and(contain(/^RSpec.describe "Posts", #{type_metatag(:system)}/))
        end
      end
    end

    describe "are not generated" do
      before do
        run_generator %w[posts --no-system-specs]
      end

      describe "the spec" do
        it "does not exist" do
          expect(File.exist?(system_spec)).to be false
        end
      end
    end
  end
end