Sha256: e9ef71128217b7562cc0d58bdc14f156a8b69e08fa3ef45e0a9c733284b6c218
Contents?: true
Size: 1.25 KB
Versions: 10
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true require "spec_helper" RSpec.describe RuboCop::Cop::Discourse::Plugins::UsePluginInstanceOn, :config do subject(:cop) { described_class.new(config) } let(:config) { RuboCop::Config.new } context "when outside `plugin.rb`" do context "when `DiscourseEvent.on` is called" do it "registers an offense" do expect_offense(<<~RUBY, "another_file.rb") DiscourseEvent.on(:topic_status_updated) { do_something } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Discourse/Plugins/UsePluginInstanceOn: Don’t call `DiscourseEvent.on` outside `plugin.rb`. RUBY end end end context "when inside `plugin.rb`" do context "when `DiscourseEvent.on` is called" do it "registers an offense" do expect_offense(<<~RUBY, "plugin.rb") DiscourseEvent.on(:topic_status_updated) { do_something } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Discourse/Plugins/UsePluginInstanceOn: Use `on` instead of `DiscourseEvent.on` [...] RUBY end end context "when `on` is called" do it "does not register an offense" do expect_no_offenses(<<~RUBY, "plugin.rb") on(:topic_status_updated) { do_something } RUBY end end end end
Version data entries
10 entries across 10 versions & 1 rubygems