Sha256: f7d54bb55af8dcedc4744285cd68ae6527129eebc2e690eaace49e9e7b98cf26

Contents?: true

Size: 1.65 KB

Versions: 25

Compression:

Stored size: 1.65 KB

Contents

module CcApiStub
  module Spaces
    extend Helper

    class << self
      def succeed_to_load(options={})
        response_body = Helper.load_fixtures(options.delete(:fixture) || "fake_cc_#{object_name}", options)
        stub_get(object_endpoint(options[:id]), {}, response(200, response_body))
      end

      def succeed_to_create
        response_body = Helper.load_fixtures("fake_cc_created_space")
        stub_post(collection_endpoint, {}, response(201, response_body))
      end

      def summary_fixture
        Helper.load_fixtures("fake_cc_space_summary")
      end

      def succeed_to_load_summary(options={})
        response_body = summary_fixture
        response_body["services"] = [] if options.delete(:no_services)
        stub_get(%r{/v2/spaces/[^/]+/summary$}, {}, response(200, response_body))
      end

      def succeed_to_load_apps(options={})
        response = response_from_options(options.reverse_merge!({:fixture => "fake_cc_space_apps"}))
        stub_get(%r{/v2/spaces/[^/]+/apps\?inline-relations-depth=1}, {}, response(200, response))
      end

      def fail_to_find(space_id)
        stub_get(%r{/v2/spaces/#{space_id}}, {}, response(404, {:code => 40004, :description => "The app space could not be found:"}))
      end

      def space_fixture_hash
        {
          :metadata => {
            :guid => "space-id-1",
            :url => "/v2/spaces/space-id-1"
          },
          :entity => {
            :name => "space-name-1"
          }
        }
      end

      private

      def collection_endpoint
        %r{/v2/spaces$}
      end

      def object_endpoint(id = nil)
        %r{/v2/spaces/#{id}[^/]+$}
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 3 rubygems

Version Path
new_cfoundry-4.9.4 lib/cc_api_stub/spaces.rb
new_cfoundry-4.9.3 lib/cc_api_stub/spaces.rb
ncfoundry-4.9.4 lib/cc_api_stub/spaces.rb
ncfoundry-4.9.3 lib/cc_api_stub/spaces.rb
ncfoundry-4.9.2 lib/cc_api_stub/spaces.rb
new_cfoundry-4.9.2 lib/cc_api_stub/spaces.rb
new_cfoundry-4.9.1 lib/cc_api_stub/spaces.rb
new_cfoundry-4.9.0 lib/cc_api_stub/spaces.rb
new_cfoundry-4.8.3 lib/cc_api_stub/spaces.rb
new_cfoundry-4.8.2 lib/cc_api_stub/spaces.rb
cfoundry-4.7.2.rc1 lib/cc_api_stub/spaces.rb
cfoundry-4.7.1 lib/cc_api_stub/spaces.rb
cfoundry-4.7.1.rc1 lib/cc_api_stub/spaces.rb
cfoundry-4.7.0 lib/cc_api_stub/spaces.rb
cfoundry-4.6.3.rc3 lib/cc_api_stub/spaces.rb
cfoundry-4.6.3.rc2 lib/cc_api_stub/spaces.rb
cfoundry-4.6.3.rc1 lib/cc_api_stub/spaces.rb
cfoundry-4.6.2 lib/cc_api_stub/spaces.rb
cfoundry-4.6.1 lib/cc_api_stub/spaces.rb
cfoundry-4.6.0 lib/cc_api_stub/spaces.rb