Sha256: 4e1578e61e17ab9ddd4a318865fe10aba75a349955c327c3997b4b08ce01f0d9

Contents?: true

Size: 764 Bytes

Versions: 7

Compression:

Stored size: 764 Bytes

Contents

require "spec_helper"

describe Qe::Action do
  NotificationWorker = Class.new do
    include Qe::Worker
    include Qe::Action

    def shutdown; end
    def default; end
  end

  let(:job) { NotificationWorker.new({}) }

  it "responds to perform" do
    expect(job).to respond_to(:perform)
  end

  it "performs specified action" do
    job.should_receive(:hello)
    job.options[:action] = :hello

    job.perform
  end

  it "executes default action when have no action" do
    job.should_receive(:default)
    job.perform
  end

  it "raises exception when action method doesn't exist" do
    job.options[:action] = :invalid

    expect {
      job.perform
    }.to raise_error(Qe::Action::MissingActionError, "the action :invalid is not defined")
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
qe-0.3.4 spec/qe/action_spec.rb
qe-0.3.3 spec/qe/action_spec.rb
qe-0.3.2 spec/qe/action_spec.rb
qe-0.3.1 spec/qe/action_spec.rb
qe-0.3.0 spec/qe/action_spec.rb
qe-0.2.1 spec/qe/action_spec.rb
qe-0.2.0 spec/qe/action_spec.rb