Sha256: ee22778774d3b9aeff2a74c81cf8325591e908a8729f9439397e26a77fc7bb53
Contents?: true
Size: 1.25 KB
Versions: 6
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true RSpec.describe RuboCop::Cop::Discourse::FabricatorShorthand, :config do subject(:cop) { described_class.new(config) } let(:config) { RuboCop::Config.new } it "registers an offense when not using the fabricator shorthand" do expect_offense(<<~RUBY) RSpec.describe "Foo" do fab!(:foo) { Fabricate(:foo) } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Discourse/FabricatorShorthand: Use the fabricator shorthand: `fab!(:foo)` end RUBY end it "does not register an offense when the fabricator has attributes" do expect_no_offenses(<<~RUBY) RSpec.describe "Foo" do fab!(:foo) { Fabricate(:foo, bar: 1) } end RUBY end it "does not register an offense when the identifier doesn't match" do expect_no_offenses(<<~RUBY) RSpec.describe "Foo" do fab!(:bar) { Fabricate(:foo) } end RUBY end it "supports autocorrect" do expect_offense(<<~RUBY) RSpec.describe "Foo" do fab!(:foo) { Fabricate(:foo) } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Discourse/FabricatorShorthand: Use the fabricator shorthand: `fab!(:foo)` end RUBY expect_correction(<<~RUBY) RSpec.describe "Foo" do fab!(:foo) end RUBY end end
Version data entries
6 entries across 6 versions & 1 rubygems