Sha256: d94052ecdde969f0fb4b41b37ce1025c2d5d8ad02cfc21084db9ff0ddbb569b4

Contents?: true

Size: 884 Bytes

Versions: 1

Compression:

Stored size: 884 Bytes

Contents

require "spec_helper"
require "pubsub_notifier/acts_as_notifier"

RSpec.describe PubsubNotifier::ActsAsNotifier do
  let(:dummy) do
    Class.new do
      include PubsubNotifier::ActsAsNotifier
      acts_as_notifier

      class << self
        def action_methods
          %w[welcome]
        end
      end
    end
  end

  before do
    allow_any_instance_of(ActionMailer::MessageDelivery).to receive(:deliver)
  end

  describe ".method_missing" do
    subject { dummy.send(method_name) }

    context "when method_name is included one of actions" do
      let(:method_name) { :welcome }
      it { is_expected.to be_a ActionMailer::MessageDelivery }
    end

    context "when method_name is not included one of actions" do
      let(:method_name) { :hello }

      it "returns raise error" do
        expect { subject }.to raise_error(NoMethodError)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pubsub_notifier-0.1.2 spec/lib/acts_as_notifier_spec.rb