puppetlabs_spec_helper 1.1.1 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +0,0 @@
1
- require 'puppet/type'
2
-
3
- Puppet::Type.newtype(:spechelper) do
4
- @doc = "This is the spechelper type"
5
- end
6
-
data/spec/spec_helper.rb DELETED
@@ -1,2 +0,0 @@
1
- RSpec.configure do |c|
2
- end
@@ -1,91 +0,0 @@
1
- require 'spec_helper'
2
- require 'puppetlabs_spec_helper/puppet_spec_helper'
3
- require 'puppetlabs_spec_helper/puppetlabs_spec/puppet_internals'
4
-
5
- describe PuppetlabsSpec::PuppetInternals do
6
- before(:all) do
7
- Puppet.initialize_settings
8
- end
9
- describe ".scope" do
10
- it "should return a Puppet::Parser::Scope instance" do
11
- subject.scope.should be_a_kind_of Puppet::Parser::Scope
12
- end
13
-
14
- xit "should be suitable for function testing" do
15
- # split is now a puppet 4x core function
16
- subject.scope.function_split(["one;two", ";"]).should == [ 'one', 'two' ]
17
- end
18
-
19
- it "should accept a compiler" do
20
- compiler = subject.compiler
21
- scope = subject.scope(:compiler => compiler)
22
- scope.compiler.should == compiler
23
- end
24
-
25
- it "should have a source set" do
26
- scope = subject.scope
27
- scope.source.should_not be_nil
28
- scope.source.name.should eq('foo')
29
- end
30
- end
31
-
32
- describe ".resource" do
33
- it "can have a defined type" do
34
- subject.resource(:type => :node).type.should == :node
35
- end
36
-
37
- it "defaults to a type of hostclass" do
38
- subject.resource.type.should == :hostclass
39
- end
40
-
41
- it "can have a defined name" do
42
- subject.resource(:name => "testingrsrc").name.should == "testingrsrc"
43
- end
44
-
45
- it "defaults to a name of testing" do
46
- subject.resource.name.should == "testing"
47
- end
48
- end
49
-
50
- describe ".compiler" do
51
- let(:node) { subject.node }
52
-
53
- it "can have a defined node" do
54
- subject.compiler(:node => node).node.should be node
55
- end
56
- end
57
-
58
- describe ".node" do
59
- it "can have a defined name" do
60
- subject.node(:name => "mine").name.should == "mine"
61
- end
62
-
63
- it "can have a defined environment" do
64
- subject.node(:environment => "mine").environment.name.should == :mine
65
- end
66
-
67
- it "defaults to a name of testinghost" do
68
- subject.node.name.should == "testinghost"
69
- end
70
-
71
- it "accepts facts via options for rspec-puppet" do
72
- fact_values = { 'fqdn' => "jeff.puppetlabs.com" }
73
- node = subject.node(:options => { :parameters => fact_values })
74
- node.parameters.should == fact_values
75
- end
76
- end
77
-
78
- describe ".function_method" do
79
- it "accepts an injected scope" do
80
- Puppet::Parser::Functions.expects(:function).with("my_func").returns(true)
81
- scope = mock()
82
- scope.expects(:method).with(:function_my_func).returns(:fake_method)
83
- subject.function_method("my_func", :scope => scope).should == :fake_method
84
- end
85
- it "returns nil if the function doesn't exist" do
86
- Puppet::Parser::Functions.expects(:function).with("my_func").returns(false)
87
- scope = mock()
88
- subject.function_method("my_func", :scope => scope).should be_nil
89
- end
90
- end
91
- end
data/spec/watchr.rb DELETED
@@ -1,79 +0,0 @@
1
- ENV['FOG_MOCK'] ||= 'true'
2
- ENV['AUTOTEST'] = 'true'
3
- ENV['WATCHR'] = '1'
4
-
5
- system 'clear'
6
-
7
- def growl(message)
8
- growlnotify = `which growlnotify`.chomp
9
- title = "Watchr Test Results"
10
- image = case message
11
- when /(\d+)\s+?(failure|error)/i
12
- ($1.to_i == 0) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
13
- else
14
- '~/.watchr_images/unknown.png'
15
- end
16
- options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
17
- system %(#{growlnotify} #{options} &)
18
- end
19
-
20
- def run(cmd)
21
- puts(cmd)
22
- `#{cmd}`
23
- end
24
-
25
- def run_spec_test(file)
26
- if File.exist? file
27
- result = run "rspec --format p --color #{file}"
28
- growl result.split("\n").last
29
- puts result
30
- else
31
- puts "FIXME: No test #{file} [#{Time.now}]"
32
- end
33
- end
34
-
35
- def filter_rspec(data)
36
- data.split("\n").find_all do |l|
37
- l =~ /^(\d+)\s+exampl\w+.*?(\d+).*?failur\w+.*?(\d+).*?pending/
38
- end.join("\n")
39
- end
40
-
41
- def run_all_tests
42
- system('clear')
43
- files = Dir.glob("spec/**/*_spec.rb").join(" ")
44
- result = run "rspec #{files}"
45
- growl_results = filter_rspec result
46
- growl growl_results
47
- puts result
48
- puts "GROWL: #{growl_results}"
49
- end
50
-
51
- # Ctrl-\
52
- Signal.trap 'QUIT' do
53
- puts " --- Running all tests ---\n\n"
54
- run_all_tests
55
- end
56
-
57
- @interrupted = false
58
-
59
- # Ctrl-C
60
- Signal.trap 'INT' do
61
- if @interrupted then
62
- @wants_to_quit = true
63
- abort("\n")
64
- else
65
- puts "Interrupt a second time to quit"
66
- @interrupted = true
67
- Kernel.sleep 1.5
68
- # raise Interrupt, nil # let the run loop catch it
69
- run_suite
70
- end
71
- end
72
-
73
- watch( 'spec/.*_spec\.rb' ) do |md|
74
- run_all_tests
75
- end
76
-
77
- watch( 'lib/.*\.rb' ) do |md|
78
- run_all_tests
79
- end