Sha256: bc6fc1e61479105d68dd6b75cdb316bf0fad697983ebca5d985e95130c9ea334

Contents?: true

Size: 1.06 KB

Versions: 7

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

describe RestPack::Service::Command do
  context 'with a commands in a namespace like TextService::Commands::Text::Reverse' do
    it 'defines sugar methods' do
      expect(TextService::Text).to respond_to(:reverse, :reverse!)
      expect(TextService::Text.reverse!(text: 'gavin')).to eq('nivag')
    end

    it 'defines aliases' do
      Command = TextService::Commands::Text::Reverse
      command = Command.new

      expect(Command::Model).to eq(TextService::Models::Text)
      expect(command.Model).to eq(TextService::Models::Text)

      expect(Command::Serializer).to eq(TextService::Serializers::Text)
      expect(command.Serializer).to eq(TextService::Serializers::Text)

      expect(Command::Commands).to eq(TextService::Commands)
      expect(Command::Models).to eq(TextService::Models)
    end
  end

  context 'with a commands in a namespace like Commands::Template::Create' do
    it 'defines sugar methods' do
      expect(Commands::Math).to respond_to(:add, :add!)
      expect(Commands::Math.add!(a: 1, b: 2)).to eq(3)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
restpack_service-0.0.75 spec/command_spec.rb
restpack_service-0.0.74 spec/command_spec.rb
restpack_service-0.0.73 spec/command_spec.rb
restpack_service-0.0.72 spec/command_spec.rb
restpack_service-0.0.71 spec/command_spec.rb
restpack_service-0.0.70 spec/command_spec.rb
restpack_service-0.0.69 spec/command_spec.rb