source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/spec/functions/load_module_metadata_spec.rb@ 30960

Last change on this file since 30960 was 30960, checked in by davidb, 7 years ago

Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster

  • Property svn:executable set to *
File size: 1.9 KB
Line 
1require 'spec_helper'
2
3describe 'load_module_metadata' do
4 it { is_expected.not_to eq(nil) }
5 it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
6 it { is_expected.to run.with_params("one", "two", "three").and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
7
8 describe "when calling with valid arguments" do
9 before :each do
10 if RSpec.configuration.puppet_future
11 allow(File).to receive(:read).with(/\/stdlib\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}')
12 else
13 allow(File).to receive(:read).with(/\/stdlib\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}')
14 end
15 end
16 it "should json parse the file" do
17 allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/')
18 allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(true)
19 allow(File).to receive(:read).with('/path/to/module/metadata.json').and_return('{"name": "spencer-science"}')
20
21 result = subject.call(['science'])
22 expect(result['name']).to eq('spencer-science')
23 end
24
25 it "should fail by default if there is no metadata.json" do
26 allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/')
27 allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false)
28 expect {subject.call(['science'])}.to raise_error(Puppet::ParseError)
29 end
30
31 it "should return nil if user allows empty metadata.json" do
32 allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/')
33 allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false)
34 result = subject.call(['science', true])
35 expect(result).to eq({})
36 end
37 end
38end
Note: See TracBrowser for help on using the repository browser.