blob: b538485855f6d697a38bf99a40f5ef49c3c36d24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
require 'spec_helper'
require 'puppet/module_tool/applications'
require 'puppet_spec/modules'
describe Puppet::ModuleTool::Applications::Searcher do
include PuppetSpec::Files
describe "when searching" do
let(:forge) { mock 'forge', :host => 'http://nowhe.re' }
let(:searcher) do
described_class.new('search_term', forge)
end
it "should return results from a forge query when successful" do
results = 'mock results'
forge.expects(:search).with('search_term').returns(results)
search_result = searcher.run
search_result.should == {
:result => :success,
:answers => results,
}
end
it "should return an error when the forge query throws an exception" do
forge.expects(:search).with('search_term').raises Puppet::Forge::Errors::ForgeError.new("something went wrong")
search_result = searcher.run
search_result.should == {
:result => :failure,
:error => {
:oneline => 'something went wrong',
:multiline => 'something went wrong',
},
}
end
end
end
|