diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/reports/store_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/unit/reports/store_spec.rb b/spec/unit/reports/store_spec.rb new file mode 100644 index 000000000..1acb5badd --- /dev/null +++ b/spec/unit/reports/store_spec.rb @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby + +Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") } + +require 'puppet/reports' +require 'time' + +processor = Puppet::Reports.report(:store) + +describe processor do + describe "#process" do + include PuppetSpec::Files + before :each do + Puppet[:reportdir] = tmpdir('reports') + @report = YAML.load_file(File.join(PuppetSpec::FIXTURE_DIR, 'yaml/report2.6.x.yaml')).extend processor + end + + it "should create a report directory for the client if one doesn't exist" do + @report.process + + File.should be_directory(File.join(Puppet[:reportdir], @report.host)) + end + + it "should write the report to the file in YAML" do + Time.stubs(:now).returns(Time.parse("2011-01-06 12:00:00 UTC")) + @report.process + + File.read(File.join(Puppet[:reportdir], @report.host, "201101061200.yaml")).should == @report.to_yaml + end + end +end |