Sha256: 496ad5b366f6c97048a4a36a11761b66292a8e6a763b0ab2aaf1b4bf11003907

Contents?: true

Size: 947 Bytes

Versions: 4

Compression:

Stored size: 947 Bytes

Contents

require 'spec_helper'

describe 'Cistern::Request' do
  class SampleService < Cistern::Service
    recognizes :key

    class Real
      attr_reader :service_args

      def initialize(*args)
        @service_args = args
      end
    end
  end

  # @todo Sample::Service.request
  class ListSamples < SampleService::Request
    service_method :list_all_samples

    def real(*args)
      service.service_args + args + ['real']
    end

    def mock(*args)
      args + ['mock']
    end
  end

  it 'should execute a new-style request' do
    expect(SampleService.new.list_all_samples('sample1')).to eq([{}, 'sample1', 'real'])
    expect(SampleService::Real.new.list_all_samples('sample2')).to eq(%w(sample2 real))
    expect(SampleService::Mock.new.list_all_samples('sample3')).to eq(%w(sample3 mock))

    # service access
    expect(SampleService.new(key: 'value').list_all_samples('stat')).to eq([{ key: 'value' }, 'stat', 'real'])
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cistern-2.2.7 spec/request_spec.rb
cistern-2.2.6 spec/request_spec.rb
cistern-2.2.5 spec/request_spec.rb
cistern-2.2.4 spec/request_spec.rb