Sha256: 3b0057f0a7d14b8e23aefa7fcc5255736363f2154b0627ba949bb16bdbb2e5d7

Contents?: true

Size: 1.57 KB

Versions: 12

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

require 'puppet/node/environment'
require 'puppet/network/http'
require 'matchers/json'

describe Puppet::Network::HTTP::API::V2::Environments do
  include JSONMatchers

  it "responds with all of the available environments" do
    environment = Puppet::Node::Environment.create(:production, ["/first", "/second"], '/manifests')
    loader = Puppet::Environments::Static.new(environment)
    handler = Puppet::Network::HTTP::API::V2::Environments.new(loader)
    response = Puppet::Network::HTTP::MemoryResponse.new

    handler.call(Puppet::Network::HTTP::Request.from_hash(:headers => { 'accept' => 'application/json' }), response)

    expect(response.code).to eq(200)
    expect(response.type).to eq("application/json")
    expect(JSON.parse(response.body)).to eq({
      "search_paths" => loader.search_paths,
      "environments" => {
        "production" => {
          "settings" => {
            "modulepath" => [File.expand_path("/first"), File.expand_path("/second")],
            "manifest" => File.expand_path("/manifests")
          }
        }
      }
    })
  end

  it "the response conforms to the environments schema" do
    environment = Puppet::Node::Environment.create(:production, [])
    handler = Puppet::Network::HTTP::API::V2::Environments.new(Puppet::Environments::Static.new(environment))
    response = Puppet::Network::HTTP::MemoryResponse.new

    handler.call(Puppet::Network::HTTP::Request.from_hash(:headers => { 'accept' => 'application/json' }), response)

    expect(response.body).to validate_against('api/schemas/environments.json')
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
puppet-3.6.2 spec/unit/network/http/api/v2/environments_spec.rb
puppet-3.6.2-x86-mingw32 spec/unit/network/http/api/v2/environments_spec.rb
puppet-3.6.1 spec/unit/network/http/api/v2/environments_spec.rb
puppet-3.6.1-x86-mingw32 spec/unit/network/http/api/v2/environments_spec.rb
puppet-3.6.0 spec/unit/network/http/api/v2/environments_spec.rb
puppet-3.6.0-x86-mingw32 spec/unit/network/http/api/v2/environments_spec.rb
puppet-3.6.0.rc1 spec/unit/network/http/api/v2/environments_spec.rb
puppet-3.6.0.rc1-x86-mingw32 spec/unit/network/http/api/v2/environments_spec.rb
puppet-3.5.1 spec/unit/network/http/api/v2/environments_spec.rb
puppet-3.5.1-x86-mingw32 spec/unit/network/http/api/v2/environments_spec.rb
puppet-3.5.1.rc1 spec/unit/network/http/api/v2/environments_spec.rb
puppet-3.5.1.rc1-x86-mingw32 spec/unit/network/http/api/v2/environments_spec.rb