Sha256: 9e78b2967eef51d445bf0a9d5c1b53fabfbd54ae4727b8878bf910c53290ef40

Contents?: true

Size: 957 Bytes

Versions: 8

Compression:

Stored size: 957 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(["sample2", "real"])
    expect(SampleService::Mock.new.list_all_samples("sample3")).to eq(["sample3", "mock"])

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cistern-2.2.3 spec/request_spec.rb
cistern-2.2.1 spec/request_spec.rb
cistern-2.1.0 spec/request_spec.rb
cistern-2.0.5 spec/request_spec.rb
cistern-2.0.4 spec/request_spec.rb
cistern-2.0.3 spec/request_spec.rb
cistern-2.0.2 spec/request_spec.rb
cistern-2.0.1 spec/request_spec.rb