Sha256: 5ef58d740454bd94e5584337a51f3cc2246ee7284fc7f9eca9bd9fb503c74030

Contents?: true

Size: 1.53 KB

Versions: 13

Compression:

Stored size: 1.53 KB

Contents

require 'activity_notification/optional_targets/slack'
describe ActivityNotification::OptionalTarget::Slack do
  let(:test_instance) { ActivityNotification::OptionalTarget::Slack.new(skip_initializing_target: true) }

  describe "as public instance methods" do
    describe "#to_optional_target_name" do
      it "is return demodulized symbol class name" do
        expect(test_instance.to_optional_target_name).to eq(:slack)
      end
    end

    describe "#initialize_target" do
      it "does not raise NotImplementedError but URI::InvalidURIError" do
        expect { test_instance.initialize_target }
          .to raise_error(URI::InvalidURIError)
      end
    end

    describe "#notify" do
      it "does not raise NotImplementedError but NoMethodError" do
        expect { test_instance.notify(create(:notification)) }
          .to raise_error(NoMethodError)
      end
    end
  end

  describe "as protected instance methods" do
    describe "#render_notification_message" do
      context "as default" do
        it "renders notification message with slack default template" do
          expect(test_instance.send(:render_notification_message, create(:notification))).to be_include("<!channel>") 
        end
      end

      context "with unexisting template as fallback option" do
        it "raise ActionView::MissingTemplate" do
          expect { expect(test_instance.send(:render_notification_message, create(:notification), fallback: :hoge)) }
            .to raise_error(ActionView::MissingTemplate)
        end
      end
    end
  end
  
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
activity_notification-2.3.2 spec/optional_targets/slack_spec.rb
activity_notification-2.3.1 spec/optional_targets/slack_spec.rb
activity_notification-2.3.0 spec/optional_targets/slack_spec.rb
activity_notification-2.2.4 spec/optional_targets/slack_spec.rb
activity_notification-2.2.3 spec/optional_targets/slack_spec.rb
activity_notification-2.2.2 spec/optional_targets/slack_spec.rb
activity_notification-2.2.1 spec/optional_targets/slack_spec.rb
activity_notification-2.2.0 spec/optional_targets/slack_spec.rb
activity_notification-2.1.4 spec/optional_targets/slack_spec.rb
activity_notification-2.1.3 spec/optional_targets/slack_spec.rb
activity_notification-2.1.2 spec/optional_targets/slack_spec.rb
activity_notification-2.1.1 spec/optional_targets/slack_spec.rb
activity_notification-2.1.0 spec/optional_targets/slack_spec.rb