Sha256: 3ed145f603b2ae1227581fcce395cff7064c16acc3ea5daff4b9191f25f5f875

Contents?: true

Size: 1.63 KB

Versions: 15

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'
require 'puppet/forge'
require 'net/http'
require 'puppet/module_tool'

describe Puppet::Forge do
  include PuppetSpec::Files

  let(:response_body) do
  <<-EOF
    [
      {
        "author": "puppetlabs",
        "name": "bacula",
        "tag_list": ["backup", "bacula"],
        "releases": [{"version": "0.0.1"}, {"version": "0.0.2"}],
        "full_name": "puppetlabs/bacula",
        "version": "0.0.2",
        "project_url": "http://github.com/puppetlabs/puppetlabs-bacula",
        "desc": "bacula"
      }
    ]
  EOF
  end
  let(:response) { stub(:body => response_body, :code => '200') }

  before do
    Puppet::Forge::Repository.any_instance.stubs(:make_http_request).returns(response)
    Puppet::Forge::Repository.any_instance.stubs(:retrieve).returns("/tmp/foo")
  end

  describe "the behavior of the search method" do
    context "when there are matches for the search term" do
      before do
        Puppet::Forge::Repository.any_instance.stubs(:make_http_request).returns(response)
      end

      it "should return a list of matches from the forge" do
        Puppet::Forge.search('bacula').should == PSON.load(response_body)
      end
    end

    context "when the connection to the forge fails" do
      let(:response)  { stub(:body => '{}', :code => '404') }

      it "should raise an error for search" do
        lambda { Puppet::Forge.search('bacula') }.should raise_error RuntimeError
      end

      it "should raise an error for remote_dependency_info" do
        lambda { Puppet::Forge.remote_dependency_info('puppetlabs', 'bacula', '0.0.1') }.should raise_error RuntimeError
      end
    end
  end

end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
puppet-2.7.26 spec/unit/forge_spec.rb
puppet-2.7.25 spec/unit/forge_spec.rb
puppet-2.7.24 spec/unit/forge_spec.rb
puppet-2.7.23 spec/unit/forge_spec.rb
puppet-2.7.22 spec/unit/forge_spec.rb
puppet-2.7.21 spec/unit/forge_spec.rb
puppet-2.7.20 spec/unit/forge_spec.rb
puppet-2.7.20.rc1 spec/unit/forge_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/forge_spec.rb
puppet-2.7.19 spec/unit/forge_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/forge_spec.rb
puppet-2.7.18 spec/unit/forge_spec.rb
puppet-2.7.17 spec/unit/forge_spec.rb
puppet-2.7.16 spec/unit/forge_spec.rb
puppet-2.7.14 spec/unit/forge_spec.rb