File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- require 'rubygems'
2- require 'puppetlabs_spec_helper/rake_tasks'
1+ require 'rake'
2+ require 'rspec/core/rake_task'
3+
4+ desc "Run all RSpec code examples"
5+ RSpec ::Core ::RakeTask . new ( :rspec ) do |t |
6+ t . rspec_opts = File . read ( "spec/spec.opts" ) . chomp || ""
7+ end
8+
9+ SPEC_SUITES = ( Dir . entries ( 'spec' ) - [ '.' , '..' , 'fixtures' ] ) . select { |e | File . directory? "spec/#{ e } " }
10+ namespace :rspec do
11+ SPEC_SUITES . each do |suite |
12+ desc "Run #{ suite } RSpec code examples"
13+ RSpec ::Core ::RakeTask . new ( suite ) do |t |
14+ t . pattern = "spec/#{ suite } /**/*_spec.rb"
15+ t . rspec_opts = File . read ( "spec/spec.opts" ) . chomp || ""
16+ end
17+ end
18+ end
19+ task :default => :rspec
20+
21+ begin
22+ if Gem ::Specification ::find_by_name ( 'puppet-lint' )
23+ require 'puppet-lint/tasks/puppet-lint'
24+ PuppetLint . configuration . ignore_paths = [ "spec/**/*.pp" , "vendor/**/*.pp" ]
25+ task :default => [ :rspec , :lint ]
26+ end
27+ rescue Gem ::LoadError
28+ end
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ describe 'java::config' do
4+ let ( :title ) { '6' }
5+ let ( :params ) { {
6+ :java_default_version => '6'
7+ } }
8+
9+ context 'with operatingsystem => Ubuntu and operatingsystemrelease => 10.04' do
10+ let ( :facts ) { {
11+ :operatingsystem => 'Ubuntu' ,
12+ :operatingsystemrelease => '10.04'
13+ } }
14+
15+ it { should contain_exec ( 'set_java' ) . with_command ( /\/ usr\/ lib\/ jvm\/ java-6-openjdk\/ jre\/ bin\/ java/ ) }
16+ end
17+
18+ context 'with operatingsystem => Ubuntu and operatingsystemrelease => 12.04' do
19+ let ( :facts ) { {
20+ :operatingsystem => 'Ubuntu' ,
21+ :operatingsystemrelease => '12.04' ,
22+ :architecture => 'amd64'
23+ } }
24+
25+ it { should contain_exec ( 'set_java' ) . with_command ( /\/ usr\/ lib\/ jvm\/ java-6-openjdk-amd64\/ jre\/ bin\/ java/ ) }
26+ end
27+
28+ context 'with operatingsystem => Ubuntu and operatingsystemrelease => foo' do
29+ let ( :facts ) { {
30+ :operatingsystem => 'Ubuntu' ,
31+ :operatingsystemrelease => 'foo'
32+ } }
33+
34+ it do
35+ expect {
36+ should compile
37+ } . to raise_error ( Puppet ::Error , /not supported on Ubuntu release foo/ )
38+ end
39+ end
40+
41+ context 'with operatingsystem => foo' do
42+ let ( :facts ) { {
43+ :operatingsystem => 'foo'
44+ } }
45+
46+ it do
47+ expect {
48+ should compile
49+ } . to raise_error ( Puppet ::Error , /not supported on an foo distribution/ )
50+ end
51+ end
52+
53+ end
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ describe 'java::install' do
4+
5+ context 'with java_version => 6' do
6+ let ( :title ) { '6' }
7+
8+ it { should contain_package ( 'openjdk-6-jdk' ) . with_ensure ( 'installed' ) }
9+ end
10+
11+ context 'with java_version => 7' do
12+ let ( :title ) { '7' }
13+
14+ it { should contain_package ( 'openjdk-7-jdk' ) . with_ensure ( 'installed' ) }
15+ end
16+
17+ end
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ describe 'java' do
4+ let ( :title ) { '6' }
5+
6+ it { should compile }
7+ it { should contain_java__install ( '6' ) . that_comes_before ( 'Java::Config[6]' ) }
8+ it { should contain_java__config ( '6' ) }
9+ end
10+
Original file line number Diff line number Diff line change 1- require 'rubygems'
2- require 'puppetlabs_spec_helper/module_spec_helper'
1+ require 'rspec-puppet'
2+
3+ fixture_path = File . expand_path ( File . join ( __FILE__ , '..' , 'fixtures' ) )
4+
5+ RSpec . configure do |c |
6+ c . module_path = File . join ( fixture_path , 'modules' )
7+ c . manifest_dir = File . join ( fixture_path , 'manifests' )
8+ end
You can’t perform that action at this time.
0 commit comments