Sha256: 8312c6663eb5c323fa8aaec5a2a7a8d0fa3a38da7918a345f8028e9f29b9cb0e
Contents?: true
Size: 1.23 KB
Versions: 6
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true 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
6 entries across 6 versions & 1 rubygems