Sha256: 2284ab3a8f8a75bd474dcb5fc0cdadbfb73aeb5d1149d111b737163d17bfa855

Contents?: true

Size: 1.42 KB

Versions: 18

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'

describe Riveter::Service do
  describe "class" do
    subject { TestService }

    it "automatically registers as handler for TestCommand" do
      Riveter::Service::Base.resolve(:test_command).should eq(subject)
    end

    describe ".register_as_handler_for" do
      let(:command_class) { TestCommand }

      it { should respond_to(:register_as_handler_for) }

      it "registers as handler for given command" do
        expect(subject).to receive(:register_type).with(subject, command_class)
        subject.register_as_handler_for(command_class)
      end

      it "allows for more than one registration" do
        my_test_command_class = Class.new(Riveter::Command::Base)
        allow(my_test_command_class).to receive(:name) { 'MyTestCommand' } # anonymous classes need a name!

        TestService.register_as_handler_for my_test_command_class
        Riveter::Service::Base.resolve(:my_test_command).should eq(subject)
      end
    end
  end

  describe "instance" do
    subject { TestService.new() }

    describe "#perform" do
      it { should respond_to(:perform) }

      it "should raise NotImplementedError if not implemented" do
        expect {
          subject.perform(nil)
        }.to raise_error(NotImplementedError)
      end

      it "should invoke" do
        expect(subject).to receive(:perform) { true }
        subject.perform(TestCommand.new()).should be_truthy
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
riveter-0.8.3 spec/riveter/service_spec.rb
riveter-0.8.2 spec/riveter/service_spec.rb
riveter-0.8.1 spec/riveter/service_spec.rb
riveter-0.8.0 spec/riveter/service_spec.rb
riveter-0.7.0 spec/riveter/service_spec.rb
riveter-0.6.0 spec/riveter/service_spec.rb
riveter-0.3.0 spec/riveter/service_spec.rb
riveter-0.2.1 spec/riveter/service_spec.rb
riveter-0.2.0 spec/riveter/service_spec.rb
riveter-0.1.1 spec/riveter/service_spec.rb
riveter-0.0.15 spec/riveter/service_spec.rb
riveter-0.0.14 spec/riveter/service_spec.rb
riveter-0.0.13 spec/riveter/service_spec.rb
riveter-0.0.12 spec/riveter/service_spec.rb
riveter-0.0.11 spec/riveter/service_spec.rb
riveter-0.0.10 spec/riveter/service_spec.rb
riveter-0.0.9 spec/riveter/service_spec.rb
riveter-0.0.8 spec/riveter/service_spec.rb