Sha256: 3fb3f715d6e7b57869918cb9c7fe3bc2328bb3f2eae015fa227d930910a5fe3f

Contents?: true

Size: 949 Bytes

Versions: 8

Compression:

Stored size: 949 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
    # @todo name
    # name :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_samples("sample1")).to eq([{}, "sample1", "real"])
    expect(SampleService::Real.new.list_samples("sample2")).to eq(["sample2", "real"])
    expect(SampleService::Mock.new.list_samples("sample3")).to eq(["sample3", "mock"])

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cistern-1.0.1.pre6 spec/request_spec.rb
cistern-1.0.1.pre5 spec/request_spec.rb
cistern-1.0.1.pre4 spec/request_spec.rb
cistern-1.0.1.pre3 spec/request_spec.rb
cistern-1.0.1.pre2 spec/request_spec.rb
cistern-1.0.1.pre1 spec/request_spec.rb
cistern-1.0.0.pre spec/request_spec.rb
cistern-0.11.2.pre2 spec/request_spec.rb