From b3490f6318f6c6d5da7a7c8316379df571daa9b9 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 3 Mar 2014 12:45:43 -0800 Subject: Supported Release 3.2.1 Summary This is a supported release Bugfixes - Fixed `is_integer`/`is_float`/`is_numeric` for checking the value of arithmatic expressions. Known bugs * No known bugs --- .gitignore | 1 - CHANGELOG | 177 ------------------------------------------- CHANGELOG.md | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Modulefile | 2 +- metadata.json | 88 ++++++++++++++++++++++ 5 files changed, 325 insertions(+), 179 deletions(-) delete mode 100644 CHANGELOG create mode 100644 CHANGELOG.md create mode 100644 metadata.json diff --git a/.gitignore b/.gitignore index 481fc81..db949df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ pkg/ .DS_Store -metadata.json coverage/ diff --git a/CHANGELOG b/CHANGELOG deleted file mode 100644 index 313b83c..0000000 --- a/CHANGELOG +++ /dev/null @@ -1,177 +0,0 @@ -2012-11-28 - Peter Meier - 3.2.0 - * Add reject() function (a79b2cd) - -2012-09-18 - Chad Metcalf - 3.2.0 - * Add an ensure_packages function. (8a8c09e) - -2012-11-23 - Erik Dalén - 3.2.0 - * (#17797) min() and max() functions (9954133) - -2012-05-23 - Peter Meier - 3.2.0 - * (#14670) autorequire a file_line resource's path (dfcee63) - -2012-11-19 - Joshua Harlan Lifton - 3.2.0 - * Add join_keys_to_values function (ee0f2b3) - -2012-11-17 - Joshua Harlan Lifton - 3.2.0 - * Extend delete function for strings and hashes (7322e4d) - -2012-08-03 - Gary Larizza - 3.2.0 - * Add the pick() function (ba6dd13) - -2012-03-20 - Wil Cooley - 3.2.0 - * (#13974) Add predicate functions for interface facts (f819417) - -2012-11-06 - Joe Julian - 3.2.0 - * Add function, uriescape, to URI.escape strings. Redmine #17459 (70f4a0e) - -2012-10-25 - Jeff McCune - 3.1.1 - * (maint) Fix spec failures resulting from Facter API changes (97f836f) - -2012-10-23 - Matthaus Owens - 3.1.0 - * Add PE facts to stdlib (cdf3b05) - -2012-08-16 - Jeff McCune - 3.0.1 - * Fix accidental removal of facts_dot_d.rb in 3.0.0 release - -2012-08-16 - Jeff McCune - 3.0.0 - * stdlib 3.0 drops support with Puppet 2.6 - * stdlib 3.0 preserves support with Puppet 2.7 - -2012-08-07 - Dan Bode - 3.0.0 - * Add function ensure_resource and defined_with_params (ba789de) - -2012-07-10 - Hailee Kenney - 3.0.0 - * (#2157) Remove facter_dot_d for compatibility with external facts (f92574f) - -2012-04-10 - Chris Price - 3.0.0 - * (#13693) moving logic from local spec_helper to puppetlabs_spec_helper (85f96df) - -2012-10-25 - Jeff McCune - 2.5.1 - * (maint) Fix spec failures resulting from Facter API changes (97f836f) - -2012-10-23 - Matthaus Owens - 2.5.0 - * Add PE facts to stdlib (cdf3b05) - -2012-08-15 - Dan Bode - 2.5.0 - * Explicitly load functions used by ensure_resource (9fc3063) - -2012-08-13 - Dan Bode - 2.5.0 - * Add better docs about duplicate resource failures (97d327a) - -2012-08-13 - Dan Bode - 2.5.0 - * Handle undef for parameter argument (4f8b133) - -2012-08-07 - Dan Bode - 2.5.0 - * Add function ensure_resource and defined_with_params (a0cb8cd) - -2012-08-20 - Jeff McCune - 2.5.0 - * Disable tests that fail on 2.6.x due to #15912 (c81496e) - -2012-08-20 - Jeff McCune - 2.5.0 - * (Maint) Fix mis-use of rvalue functions as statements (4492913) - -2012-08-20 - Jeff McCune - 2.5.0 - * Add .rspec file to repo root (88789e8) - -2012-06-07 - Chris Price - 2.4.0 - * Add support for a 'match' parameter to file_line (a06c0d8) - -2012-08-07 - Erik Dalén - 2.4.0 - * (#15872) Add to_bytes function (247b69c) - -2012-07-19 - Jeff McCune - 2.4.0 - * (Maint) use PuppetlabsSpec::PuppetInternals.scope (master) (deafe88) - -2012-07-10 - Hailee Kenney - 2.4.0 - * (#2157) Make facts_dot_d compatible with external facts (5fb0ddc) - -2012-03-16 - Steve Traylen - 2.4.0 - * (#13205) Rotate array/string randomley based on fqdn, fqdn_rotate() (fef247b) - -2012-05-22 - Peter Meier - 2.3.3 - * fix regression in #11017 properly (f0a62c7) - -2012-05-10 - Jeff McCune - 2.3.3 - * Fix spec tests using the new spec_helper (7d34333) - -2012-05-10 - Puppet Labs - 2.3.2 - * Make file_line default to ensure => present (1373e70) - * Memoize file_line spec instance variables (20aacc5) - * Fix spec tests using the new spec_helper (1ebfa5d) - * (#13595) initialize_everything_for_tests couples modules Puppet ver (3222f35) - * (#13439) Fix MRI 1.9 issue with spec_helper (15c5fd1) - * (#13439) Fix test failures with Puppet 2.6.x (665610b) - * (#13439) refactor spec helper for compatibility with both puppet 2.7 and master (82194ca) - * (#13494) Specify the behavior of zero padded strings (61891bb) - -2012-03-29 Puppet Labs - 2.1.3 -* (#11607) Add Rakefile to enable spec testing -* (#12377) Avoid infinite loop when retrying require json - -2012-03-13 Puppet Labs - 2.3.1 -* (#13091) Fix LoadError bug with puppet apply and puppet_vardir fact - -2012-03-12 Puppet Labs - 2.3.0 -* Add a large number of new Puppet functions -* Backwards compatibility preserved with 2.2.x - -2011-12-30 Puppet Labs - 2.2.1 -* Documentation only release for the Forge - -2011-12-30 Puppet Labs - 2.1.2 -* Documentation only release for PE 2.0.x - -2011-11-08 Puppet Labs - 2.2.0 -* #10285 - Refactor json to use pson instead. -* Maint - Add watchr autotest script -* Maint - Make rspec tests work with Puppet 2.6.4 -* #9859 - Add root_home fact and tests - -2011-08-18 Puppet Labs - 2.1.1 -* Change facts.d paths to match Facter 2.0 paths. -* /etc/facter/facts.d -* /etc/puppetlabs/facter/facts.d - -2011-08-17 Puppet Labs - 2.1.0 -* Add R.I. Pienaar's facts.d custom facter fact -* facts defined in /etc/facts.d and /etc/puppetlabs/facts.d are - automatically loaded now. - -2011-08-04 Puppet Labs - 2.0.0 -* Rename whole_line to file_line -* This is an API change and as such motivating a 2.0.0 release according to semver.org. - -2011-08-04 Puppet Labs - 1.1.0 -* Rename append_line to whole_line -* This is an API change and as such motivating a 1.1.0 release. - -2011-08-04 Puppet Labs - 1.0.0 -* Initial stable release -* Add validate_array and validate_string functions -* Make merge() function work with Ruby 1.8.5 -* Add hash merging function -* Add has_key function -* Add loadyaml() function -* Add append_line native - -2011-06-21 Jeff McCune - 0.1.7 -* Add validate_hash() and getvar() functions - -2011-06-15 Jeff McCune - 0.1.6 -* Add anchor resource type to provide containment for composite classes - -2011-06-03 Jeff McCune - 0.1.5 -* Add validate_bool() function to stdlib - -0.1.4 2011-05-26 Jeff McCune -* Move most stages after main - -0.1.3 2011-05-25 Jeff McCune -* Add validate_re() function - -0.1.2 2011-05-24 Jeff McCune -* Update to add annotated tag - -0.1.1 2011-05-24 Jeff McCune -* Add stdlib::stages class with a standard set of stages diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7f0ec67 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,236 @@ +##2014-03-04 - Supported Release - 3.2.1 +###Summary +This is a supported release + +####Bugfixes +- Fixed `is_integer`/`is_float`/`is_numeric` for checking the value of arithmatic expressions. + +####Known bugs +* No known bugs + +--- + +##### 2012-09-18 - Chad Metcalf - 3.2.0 + + * Add an ensure\_packages function. (8a8c09e) + +##### 2012-11-23 - Erik Dalén - 3.2.0 + + * (#17797) min() and max() functions (9954133) + +##### 2012-05-23 - Peter Meier - 3.2.0 + + * (#14670) autorequire a file\_line resource's path (dfcee63) + +##### 2012-11-19 - Joshua Harlan Lifton - 3.2.0 + + * Add join\_keys\_to\_values function (ee0f2b3) + +##### 2012-11-17 - Joshua Harlan Lifton - 3.2.0 + + * Extend delete function for strings and hashes (7322e4d) + +##### 2012-08-03 - Gary Larizza - 3.2.0 + + * Add the pick() function (ba6dd13) + +##### 2012-03-20 - Wil Cooley - 3.2.0 + + * (#13974) Add predicate functions for interface facts (f819417) + +##### 2012-11-06 - Joe Julian - 3.2.0 + + * Add function, uriescape, to URI.escape strings. Redmine #17459 (70f4a0e) + +##### 2012-10-25 - Jeff McCune - 3.1.1 + + * (maint) Fix spec failures resulting from Facter API changes (97f836f) + +##### 2012-10-23 - Matthaus Owens - 3.1.0 + + * Add PE facts to stdlib (cdf3b05) + +##### 2012-08-16 - Jeff McCune - 3.0.1 + + * Fix accidental removal of facts\_dot\_d.rb in 3.0.0 release + +##### 2012-08-16 - Jeff McCune - 3.0.0 + + * stdlib 3.0 drops support with Puppet 2.6 + * stdlib 3.0 preserves support with Puppet 2.7 + +##### 2012-08-07 - Dan Bode - 3.0.0 + + * Add function ensure\_resource and defined\_with\_params (ba789de) + +##### 2012-07-10 - Hailee Kenney - 3.0.0 + + * (#2157) Remove facter\_dot\_d for compatibility with external facts (f92574f) + +##### 2012-04-10 - Chris Price - 3.0.0 + + * (#13693) moving logic from local spec\_helper to puppetlabs\_spec\_helper (85f96df) + +##### 2012-10-25 - Jeff McCune - 2.5.1 + + * (maint) Fix spec failures resulting from Facter API changes (97f836f) + +##### 2012-10-23 - Matthaus Owens - 2.5.0 + + * Add PE facts to stdlib (cdf3b05) + +##### 2012-08-15 - Dan Bode - 2.5.0 + + * Explicitly load functions used by ensure\_resource (9fc3063) + +##### 2012-08-13 - Dan Bode - 2.5.0 + + * Add better docs about duplicate resource failures (97d327a) + +##### 2012-08-13 - Dan Bode - 2.5.0 + + * Handle undef for parameter argument (4f8b133) + +##### 2012-08-07 - Dan Bode - 2.5.0 + + * Add function ensure\_resource and defined\_with\_params (a0cb8cd) + +##### 2012-08-20 - Jeff McCune - 2.5.0 + + * Disable tests that fail on 2.6.x due to #15912 (c81496e) + +##### 2012-08-20 - Jeff McCune - 2.5.0 + + * (Maint) Fix mis-use of rvalue functions as statements (4492913) + +##### 2012-08-20 - Jeff McCune - 2.5.0 + + * Add .rspec file to repo root (88789e8) + +##### 2012-06-07 - Chris Price - 2.4.0 + + * Add support for a 'match' parameter to file\_line (a06c0d8) + +##### 2012-08-07 - Erik Dalén - 2.4.0 + + * (#15872) Add to\_bytes function (247b69c) + +##### 2012-07-19 - Jeff McCune - 2.4.0 + + * (Maint) use PuppetlabsSpec::PuppetInternals.scope (master) (deafe88) + +##### 2012-07-10 - Hailee Kenney - 2.4.0 + + * (#2157) Make facts\_dot\_d compatible with external facts (5fb0ddc) + +##### 2012-03-16 - Steve Traylen - 2.4.0 + + * (#13205) Rotate array/string randomley based on fqdn, fqdn\_rotate() (fef247b) + +##### 2012-05-22 - Peter Meier - 2.3.3 + + * fix regression in #11017 properly (f0a62c7) + +##### 2012-05-10 - Jeff McCune - 2.3.3 + + * Fix spec tests using the new spec\_helper (7d34333) + +##### 2012-05-10 - Puppet Labs - 2.3.2 + + * Make file\_line default to ensure => present (1373e70) + * Memoize file\_line spec instance variables (20aacc5) + * Fix spec tests using the new spec\_helper (1ebfa5d) + * (#13595) initialize\_everything\_for\_tests couples modules Puppet ver (3222f35) + * (#13439) Fix MRI 1.9 issue with spec\_helper (15c5fd1) + * (#13439) Fix test failures with Puppet 2.6.x (665610b) + * (#13439) refactor spec helper for compatibility with both puppet 2.7 and master (82194ca) + * (#13494) Specify the behavior of zero padded strings (61891bb) + +##### 2012-03-29 Puppet Labs - 2.1.3 + +* (#11607) Add Rakefile to enable spec testing +* (#12377) Avoid infinite loop when retrying require json + +##### 2012-03-13 Puppet Labs - 2.3.1 + +* (#13091) Fix LoadError bug with puppet apply and puppet\_vardir fact + +##### 2012-03-12 Puppet Labs - 2.3.0 + +* Add a large number of new Puppet functions +* Backwards compatibility preserved with 2.2.x + +##### 2011-12-30 Puppet Labs - 2.2.1 + +* Documentation only release for the Forge + +##### 2011-12-30 Puppet Labs - 2.1.2 + +* Documentation only release for PE 2.0.x + +##### 2011-11-08 Puppet Labs - 2.2.0 + +* #10285 - Refactor json to use pson instead. +* Maint - Add watchr autotest script +* Maint - Make rspec tests work with Puppet 2.6.4 +* #9859 - Add root\_home fact and tests + +##### 2011-08-18 Puppet Labs - 2.1.1 + +* Change facts.d paths to match Facter 2.0 paths. +* /etc/facter/facts.d +* /etc/puppetlabs/facter/facts.d + +##### 2011-08-17 Puppet Labs - 2.1.0 + +* Add R.I. Pienaar's facts.d custom facter fact +* facts defined in /etc/facts.d and /etc/puppetlabs/facts.d are + automatically loaded now. + +##### 2011-08-04 Puppet Labs - 2.0.0 + +* Rename whole\_line to file\_line +* This is an API change and as such motivating a 2.0.0 release according to semver.org. + +##### 2011-08-04 Puppet Labs - 1.1.0 + +* Rename append\_line to whole\_line +* This is an API change and as such motivating a 1.1.0 release. + +##### 2011-08-04 Puppet Labs - 1.0.0 + +* Initial stable release +* Add validate\_array and validate\_string functions +* Make merge() function work with Ruby 1.8.5 +* Add hash merging function +* Add has\_key function +* Add loadyaml() function +* Add append\_line native + +##### 2011-06-21 Jeff McCune - 0.1.7 + +* Add validate\_hash() and getvar() functions + +##### 2011-06-15 Jeff McCune - 0.1.6 + +* Add anchor resource type to provide containment for composite classes + +##### 2011-06-03 Jeff McCune - 0.1.5 + +* Add validate\_bool() function to stdlib + +##### 0.1.4 2011-05-26 Jeff McCune + +* Move most stages after main + +##### 0.1.3 2011-05-25 Jeff McCune + +* Add validate\_re() function + +##### 0.1.2 2011-05-24 Jeff McCune + +* Update to add annotated tag + +##### 0.1.1 2011-05-24 Jeff McCune + +* Add stdlib::stages class with a standard set of stages diff --git a/Modulefile b/Modulefile index 34564fa..07cd697 100644 --- a/Modulefile +++ b/Modulefile @@ -1,5 +1,5 @@ name 'puppetlabs-stdlib' -version '3.2.0' +version '3.2.1' source 'git://github.com/puppetlabs/puppetlabs-stdlib' author 'puppetlabs' license 'Apache 2.0' diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..b17b0f1 --- /dev/null +++ b/metadata.json @@ -0,0 +1,88 @@ +{ + "operatingsystem_support": [ + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "4", + "5", + "6" + ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "4", + "5", + "6" + ] + }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "4", + "5", + "6" + ] + }, + { + "operatingsystem": "Scientific", + "operatingsystemrelease": [ + "4", + "5", + "6" + ] + }, + { + "operatingsystem": "SLES", + "operatingsystemrelease": [ + "11 SP1" + ] + }, + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "10.04", + "12.04" + ] + }, + { + "operatingsystem": "Solaris", + "operatingsystemrelease": [ + "10", + "11" + ] + }, + { + "operatingsystem": "Windows", + "operatingsystemrelease": [ + "Server 2003", + "Server 2003 R2", + "Server 2008", + "Server 2008 R2", + "Server 2012", + "Server 2012 R2", + "7" + "8" + ] + }, + { + "operatingsystem": "AIX", + "operatingsystemrelease": [ + "5.3", + "6.1", + "7.1" + ] + } + ], + "requirements": [ + { "name": "pe", "version_requirement": "3.2.x" }, + { "name": "puppet", "version_requirement": ">=2.7.20 <4.0.0" } + ] +} -- cgit v1.2.3 From 4f65539c2e6734af69216d8d6d6fed68e631358b Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Mon, 3 Mar 2014 13:56:13 -0800 Subject: Patch metadata --- metadata.json | 189 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 103 insertions(+), 86 deletions(-) diff --git a/metadata.json b/metadata.json index b17b0f1..5e9fb0e 100644 --- a/metadata.json +++ b/metadata.json @@ -1,88 +1,105 @@ { - "operatingsystem_support": [ - { - "operatingsystem": "RedHat", - "operatingsystemrelease": [ - "4", - "5", - "6" - ] - }, - { - "operatingsystem": "CentOS", - "operatingsystemrelease": [ - "4", - "5", - "6" - ] - }, - { - "operatingsystem": "OracleLinux", - "operatingsystemrelease": [ - "4", - "5", - "6" - ] - }, - { - "operatingsystem": "Scientific", - "operatingsystemrelease": [ - "4", - "5", - "6" - ] - }, - { - "operatingsystem": "SLES", - "operatingsystemrelease": [ - "11 SP1" - ] - }, - { - "operatingsystem": "Debian", - "operatingsystemrelease": [ - "6", - "7" - ] - }, - { - "operatingsystem": "Ubuntu", - "operatingsystemrelease": [ - "10.04", - "12.04" - ] - }, - { - "operatingsystem": "Solaris", - "operatingsystemrelease": [ - "10", - "11" - ] - }, - { - "operatingsystem": "Windows", - "operatingsystemrelease": [ - "Server 2003", - "Server 2003 R2", - "Server 2008", - "Server 2008 R2", - "Server 2012", - "Server 2012 R2", - "7" - "8" - ] - }, - { - "operatingsystem": "AIX", - "operatingsystemrelease": [ - "5.3", - "6.1", - "7.1" - ] - } - ], - "requirements": [ - { "name": "pe", "version_requirement": "3.2.x" }, - { "name": "puppet", "version_requirement": ">=2.7.20 <4.0.0" } - ] + "operatingsystem_support": [ + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "4", + "5", + "6" + ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "4", + "5", + "6" + ] + }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "4", + "5", + "6" + ] + }, + { + "operatingsystem": "Scientific", + "operatingsystemrelease": [ + "4", + "5", + "6" + ] + }, + { + "operatingsystem": "SLES", + "operatingsystemrelease": [ + "11 SP1" + ] + }, + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "10.04", + "12.04" + ] + }, + { + "operatingsystem": "Solaris", + "operatingsystemrelease": [ + "10", + "11" + ] + }, + { + "operatingsystem": "Windows", + "operatingsystemrelease": [ + "Server 2003", + "Server 2003 R2", + "Server 2008", + "Server 2008 R2", + "Server 2012", + "Server 2012 R2", + "7", + "8" + ] + }, + { + "operatingsystem": "AIX", + "operatingsystemrelease": [ + "5.3", + "6.1", + "7.1" + ] + } + ], + "requirements": [ + { + "name": "pe", + "version_requirement": "3.2.x" + }, + { + "name": "puppet", + "version_requirement": ">=2.7.20 <4.0.0" + } + ], + "name": "puppetlabs-stdlib", + "version": "3.2.1", + "source": "git://github.com/puppetlabs/puppetlabs-stdlib", + "author": "puppetlabs", + "license": "Apache 2.0", + "summary": "Puppet Module Standard Library", + "description": "Standard Library for Puppet Modules", + "project_page": "https://github.com/puppetlabs/puppetlabs-stdlib", + "dependencies": [ + + ] } -- cgit v1.2.3 From dbb29980a170623c578c51c471af71ff66e23e9c Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 5 Mar 2014 15:43:58 -0500 Subject: Numerous changes to update testing gems. This work updates a number of Gems to the latest versions (rspec, rspec-puppet), and updates and tweaks a bunch of tests to work with the updated gems. --- Gemfile | 24 +++++ spec/classes/anchor_spec.rb | 31 ++++++ spec/functions/ensure_packages_spec.rb | 60 +++++++---- spec/functions/ensure_resource_spec.rb | 75 ++++++++----- spec/lib/puppet_spec/compiler.rb | 46 ++++++++ spec/lib/puppet_spec/database.rb | 29 +++++ spec/lib/puppet_spec/files.rb | 60 +++++++++++ spec/lib/puppet_spec/fixtures.rb | 28 +++++ spec/lib/puppet_spec/matchers.rb | 120 +++++++++++++++++++++ spec/lib/puppet_spec/modules.rb | 26 +++++ spec/lib/puppet_spec/pops.rb | 16 +++ spec/lib/puppet_spec/scope.rb | 14 +++ spec/lib/puppet_spec/settings.rb | 15 +++ spec/lib/puppet_spec/verbose.rb | 9 ++ spec/spec_helper.rb | 30 ++++-- spec/unit/puppet/parser/functions/merge_spec.rb | 7 +- .../functions/validate_absolute_path_spec.rb | 4 +- spec/unit/puppet/provider/file_line/ruby_spec.rb | 2 +- spec/unit/puppet/type/anchor_spec.rb | 2 +- spec/unit/puppet/type/file_line_spec.rb | 2 +- spec/watchr.rb | 86 --------------- 21 files changed, 539 insertions(+), 147 deletions(-) create mode 100644 Gemfile create mode 100644 spec/classes/anchor_spec.rb create mode 100644 spec/lib/puppet_spec/compiler.rb create mode 100644 spec/lib/puppet_spec/database.rb create mode 100755 spec/lib/puppet_spec/files.rb create mode 100755 spec/lib/puppet_spec/fixtures.rb create mode 100644 spec/lib/puppet_spec/matchers.rb create mode 100644 spec/lib/puppet_spec/modules.rb create mode 100644 spec/lib/puppet_spec/pops.rb create mode 100644 spec/lib/puppet_spec/scope.rb create mode 100644 spec/lib/puppet_spec/settings.rb create mode 100755 spec/lib/puppet_spec/verbose.rb delete mode 100644 spec/watchr.rb diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..3d6d5ea --- /dev/null +++ b/Gemfile @@ -0,0 +1,24 @@ +source ENV['GEM_SOURCE'] || 'https://rubygems.org' + +group :development, :test do + gem 'rake', :require => false + gem 'rspec-puppet', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'rspec-system', :require => false + gem 'rspec-system-puppet', :require => false + gem 'rspec-system-serverspec', :require => false + gem 'serverspec', :require => false + gem 'puppet-lint', :require => false + gem 'pry', :require => false + gem 'simplecov', :require => false + gem 'beaker', :require => false + gem 'beaker-rspec', :require => false +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end + +# vim:ft=ruby diff --git a/spec/classes/anchor_spec.rb b/spec/classes/anchor_spec.rb new file mode 100644 index 0000000..6754811 --- /dev/null +++ b/spec/classes/anchor_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' +require 'puppet_spec/compiler' + +describe "anchorrefresh" do + include PuppetSpec::Compiler + + let :transaction do + apply_compiled_manifest(<<-ANCHORCLASS) + class anchored { + anchor { 'anchored::begin': } + ~> anchor { 'anchored::end': } + } + + class anchorrefresh { + notify { 'first': } + ~> class { 'anchored': } + ~> anchor { 'final': } + } + + include anchorrefresh + ANCHORCLASS + end + + it 'propagates events through the anchored class' do + require 'pry' + binding.pry + resource = transaction.resource_status('Anchor[final]') + + expect(resource.restarted).to eq(true) + end +end diff --git a/spec/functions/ensure_packages_spec.rb b/spec/functions/ensure_packages_spec.rb index 1c2a328..4163d69 100644 --- a/spec/functions/ensure_packages_spec.rb +++ b/spec/functions/ensure_packages_spec.rb @@ -2,41 +2,65 @@ require 'spec_helper' require 'rspec-puppet' +require 'puppet_spec/compiler' describe 'ensure_packages' do - let(:scope) { PuppetlabsSpec::PuppetInternals.scope } + include PuppetSpec::Compiler + + before :each do + Puppet::Parser::Functions.autoloader.loadall + Puppet::Parser::Functions.function(:ensure_packages) + Puppet::Parser::Functions.function(:ensure_resource) + Puppet::Parser::Functions.function(:defined_with_params) + Puppet::Parser::Functions.function(:create_resources) + end + + let :node do Puppet::Node.new('localhost') end + let :compiler do Puppet::Parser::Compiler.new(node) end + let :scope do + if Puppet.version.to_f >= 3.0 + Puppet::Parser::Scope.new(compiler) + else + newscope = Puppet::Parser::Scope.new + newscope.compiler = compiler + newscope.source = Puppet::Resource::Type.new(:node, :localhost) + newscope + end + end describe 'argument handling' do it 'fails with no arguments' do - should run.with_params().and_raise_error(Puppet::ParseError) + expect { + scope.function_ensure_packages([]) + }.to raise_error(Puppet::ParseError, /0 for 1/) end - it 'requires an array' do - lambda { scope.function_ensure_packages([['foo']]) }.should_not raise_error - end - it 'fails when given a string' do - should run.with_params('foo').and_raise_error(Puppet::ParseError) + + it 'accepts an array of values' do + scope.function_ensure_packages([['foo']]) end end - context 'given a catalog containing Package[puppet]{ensure => absent}' do - let :pre_condition do - 'package { puppet: ensure => absent }' + context 'given a catalog with puppet package => absent' do + let :catalog do + compile_to_catalog(<<-EOS + ensure_packages(['facter']) + package { puppet: ensure => absent } + EOS + ) end - # NOTE: should run.with_params has the side effect of making the compiler - # available to the test harness. it 'has no effect on Package[puppet]' do - should run.with_params(['puppet']) - rsrc = compiler.catalog.resource('Package[puppet]') - rsrc.to_hash.should == {:ensure => "absent"} + expect(catalog.resource(:package, 'puppet')['ensure']).to eq('absent') end end context 'given a clean catalog' do + let :catalog do + compile_to_catalog('ensure_packages(["facter"])') + end + it 'declares package resources with ensure => present' do - should run.with_params(['facter']) - rsrc = compiler.catalog.resource('Package[facter]') - rsrc.to_hash.should == {:name => "facter", :ensure => "present"} + expect(catalog.resource(:package, 'facter')['ensure']).to eq('present') end end end diff --git a/spec/functions/ensure_resource_spec.rb b/spec/functions/ensure_resource_spec.rb index 611666e..430691c 100644 --- a/spec/functions/ensure_resource_spec.rb +++ b/spec/functions/ensure_resource_spec.rb @@ -1,40 +1,61 @@ -#! /usr/bin/env ruby -S rspec require 'spec_helper' - require 'rspec-puppet' +require 'puppet_spec/compiler' + describe 'ensure_resource' do + include PuppetSpec::Compiler + + before :all do + Puppet::Parser::Functions.autoloader.loadall + Puppet::Parser::Functions.function(:ensure_packages) + end + + let :node do Puppet::Node.new('localhost') end + let :compiler do Puppet::Parser::Compiler.new(node) end + let :scope do Puppet::Parser::Scope.new(compiler) end + describe 'when a type or title is not specified' do - it do - should run.with_params().and_raise_error(ArgumentError) - should run.with_params(['type']).and_raise_error(ArgumentError) - end + it { expect { scope.function_ensure_resource([]) }.to raise_error } + it { expect { scope.function_ensure_resource(['type']) }.to raise_error } end + describe 'when compared against a resource with no attributes' do - let :pre_condition do - 'user { "dan": }' + let :catalog do + compile_to_catalog(<<-EOS + user { "dan": } + ensure_resource('user', 'dan', {}) + EOS + ) end - it do - should run.with_params('user', 'dan', {}) - compiler.catalog.resource('User[dan]').to_s.should == 'User[dan]' + + it 'should contain the the ensured resources' do + expect(catalog.resource(:user, 'dan').to_s).to eq('User[dan]') end end - describe 'when compared against a resource with attributes' do - let :pre_condition do - 'user { "dan": ensure => present, shell => "/bin/csh", managehome => false}' - end - it do - # these first three should not fail - should run.with_params('User', 'dan', {}) - should run.with_params('User', 'dan', '') - should run.with_params('User', 'dan', {'ensure' => 'present'}) - should run.with_params('User', 'dan', - {'ensure' => 'present', 'managehome' => false} - ) - # test that this fails - should run.with_params('User', 'dan', - {'ensure' => 'absent', 'managehome' => false} - ).and_raise_error(Puppet::Error) + describe 'works when compared against a resource with non-conflicting attributes' do + [ + "ensure_resource('User', 'dan', {})", + "ensure_resource('User', 'dan', '')", + "ensure_resource('User', 'dan', {'ensure' => 'present'})", + "ensure_resource('User', 'dan', {'ensure' => 'present', 'managehome' => false})" + ].each do |ensure_resource| + pp = <<-EOS + user { "dan": ensure => present, shell => "/bin/csh", managehome => false} + #{ensure_resource} + EOS + + it { expect { compile_to_catalog(pp) }.to_not raise_error } end end + + describe 'fails when compared against a resource with conflicting attributes' do + pp = <<-EOS + user { "dan": ensure => present, shell => "/bin/csh", managehome => false} + ensure_resource('User', 'dan', {'ensure' => 'absent', 'managehome' => false}) + EOS + + it { expect { compile_to_catalog(pp) }.to raise_error } + end + end diff --git a/spec/lib/puppet_spec/compiler.rb b/spec/lib/puppet_spec/compiler.rb new file mode 100644 index 0000000..22e923d --- /dev/null +++ b/spec/lib/puppet_spec/compiler.rb @@ -0,0 +1,46 @@ +module PuppetSpec::Compiler + def compile_to_catalog(string, node = Puppet::Node.new('foonode')) + Puppet[:code] = string + Puppet::Parser::Compiler.compile(node) + end + + def compile_to_ral(manifest) + catalog = compile_to_catalog(manifest) + ral = catalog.to_ral + ral.finalize + ral + end + + def compile_to_relationship_graph(manifest, prioritizer = Puppet::Graph::SequentialPrioritizer.new) + ral = compile_to_ral(manifest) + graph = Puppet::Graph::RelationshipGraph.new(prioritizer) + graph.populate_from(ral) + graph + end + + if Puppet.version.to_f >= 3.3 + def apply_compiled_manifest(manifest, prioritizer = Puppet::Graph::SequentialPrioritizer.new) + transaction = Puppet::Transaction.new(compile_to_ral(manifest), + Puppet::Transaction::Report.new("apply"), + prioritizer) + transaction.evaluate + transaction.report.finalize_report + + transaction + end + else + def apply_compiled_manifest(manifest) + transaction = Puppet::Transaction.new(compile_to_ral(manifest), Puppet::Transaction::Report.new("apply")) + transaction.evaluate + transaction.report.finalize_report + + transaction + end + end + + def order_resources_traversed_in(relationships) + order_seen = [] + relationships.traverse { |resource| order_seen << resource.ref } + order_seen + end +end diff --git a/spec/lib/puppet_spec/database.rb b/spec/lib/puppet_spec/database.rb new file mode 100644 index 0000000..069ca15 --- /dev/null +++ b/spec/lib/puppet_spec/database.rb @@ -0,0 +1,29 @@ +# This just makes some nice things available at global scope, and for setup of +# tests to use a real fake database, rather than a fake stubs-that-don't-work +# version of the same. Fun times. +def sqlite? + if $sqlite.nil? + begin + require 'sqlite3' + $sqlite = true + rescue LoadError + $sqlite = false + end + end + $sqlite +end + +def can_use_scratch_database? + sqlite? and Puppet.features.rails? +end + + +# This is expected to be called in your `before :each` block, and will get you +# ready to roll with a serious database and all. Cleanup is handled +# automatically for you. Nothing to do there. +def setup_scratch_database + Puppet[:dbadapter] = 'sqlite3' + Puppet[:dblocation] = ':memory:' + Puppet[:railslog] = PuppetSpec::Files.tmpfile('storeconfigs.log') + Puppet::Rails.init +end diff --git a/spec/lib/puppet_spec/files.rb b/spec/lib/puppet_spec/files.rb new file mode 100755 index 0000000..65b04aa --- /dev/null +++ b/spec/lib/puppet_spec/files.rb @@ -0,0 +1,60 @@ +require 'fileutils' +require 'tempfile' +require 'tmpdir' +require 'pathname' + +# A support module for testing files. +module PuppetSpec::Files + def self.cleanup + $global_tempfiles ||= [] + while path = $global_tempfiles.pop do + begin + Dir.unstub(:entries) + FileUtils.rm_rf path, :secure => true + rescue Errno::ENOENT + # nothing to do + end + end + end + + def make_absolute(path) PuppetSpec::Files.make_absolute(path) end + def self.make_absolute(path) + path = File.expand_path(path) + path[0] = 'c' if Puppet.features.microsoft_windows? + path + end + + def tmpfile(name, dir = nil) PuppetSpec::Files.tmpfile(name, dir) end + def self.tmpfile(name, dir = nil) + # Generate a temporary file, just for the name... + source = dir ? Tempfile.new(name, dir) : Tempfile.new(name) + path = source.path + source.close! + + record_tmp(File.expand_path(path)) + + path + end + + def file_containing(name, contents) PuppetSpec::Files.file_containing(name, contents) end + def self.file_containing(name, contents) + file = tmpfile(name) + File.open(file, 'wb') { |f| f.write(contents) } + file + end + + def tmpdir(name) PuppetSpec::Files.tmpdir(name) end + def self.tmpdir(name) + dir = Dir.mktmpdir(name) + + record_tmp(dir) + + dir + end + + def self.record_tmp(tmp) + # ...record it for cleanup, + $global_tempfiles ||= [] + $global_tempfiles << tmp + end +end diff --git a/spec/lib/puppet_spec/fixtures.rb b/spec/lib/puppet_spec/fixtures.rb new file mode 100755 index 0000000..7f6bc2a --- /dev/null +++ b/spec/lib/puppet_spec/fixtures.rb @@ -0,0 +1,28 @@ +module PuppetSpec::Fixtures + def fixtures(*rest) + File.join(PuppetSpec::FIXTURE_DIR, *rest) + end + def my_fixture_dir + callers = caller + while line = callers.shift do + next unless found = line.match(%r{/spec/(.*)_spec\.rb:}) + return fixtures(found[1]) + end + fail "sorry, I couldn't work out your path from the caller stack!" + end + def my_fixture(name) + file = File.join(my_fixture_dir, name) + unless File.readable? file then + fail Puppet::DevError, "fixture '#{name}' for #{my_fixture_dir} is not readable" + end + return file + end + def my_fixtures(glob = '*', flags = 0) + files = Dir.glob(File.join(my_fixture_dir, glob), flags) + unless files.length > 0 then + fail Puppet::DevError, "fixture '#{glob}' for #{my_fixture_dir} had no files!" + end + block_given? and files.each do |file| yield file end + files + end +end diff --git a/spec/lib/puppet_spec/matchers.rb b/spec/lib/puppet_spec/matchers.rb new file mode 100644 index 0000000..448bd18 --- /dev/null +++ b/spec/lib/puppet_spec/matchers.rb @@ -0,0 +1,120 @@ +require 'stringio' + +######################################################################## +# Backward compatibility for Jenkins outdated environment. +module RSpec + module Matchers + module BlockAliases + alias_method :to, :should unless method_defined? :to + alias_method :to_not, :should_not unless method_defined? :to_not + alias_method :not_to, :should_not unless method_defined? :not_to + end + end +end + + +######################################################################## +# Custom matchers... +RSpec::Matchers.define :have_matching_element do |expected| + match do |actual| + actual.any? { |item| item =~ expected } + end +end + + +RSpec::Matchers.define :exit_with do |expected| + actual = nil + match do |block| + begin + block.call + rescue SystemExit => e + actual = e.status + end + actual and actual == expected + end + failure_message_for_should do |block| + "expected exit with code #{expected} but " + + (actual.nil? ? " exit was not called" : "we exited with #{actual} instead") + end + failure_message_for_should_not do |block| + "expected that exit would not be called with #{expected}" + end + description do + "expect exit with #{expected}" + end +end + +class HavePrintedMatcher + attr_accessor :expected, :actual + + def initialize(expected) + case expected + when String, Regexp + @expected = expected + else + @expected = expected.to_s + end + end + + def matches?(block) + begin + $stderr = $stdout = StringIO.new + $stdout.set_encoding('UTF-8') if $stdout.respond_to?(:set_encoding) + block.call + $stdout.rewind + @actual = $stdout.read + ensure + $stdout = STDOUT + $stderr = STDERR + end + + if @actual then + case @expected + when String + @actual.include? @expected + when Regexp + @expected.match @actual + end + else + false + end + end + + def failure_message_for_should + if @actual.nil? then + "expected #{@expected.inspect}, but nothing was printed" + else + "expected #{@expected.inspect} to be printed; got:\n#{@actual}" + end + end + + def failure_message_for_should_not + "expected #{@expected.inspect} to not be printed; got:\n#{@actual}" + end + + def description + "expect #{@expected.inspect} to be printed" + end +end + +def have_printed(what) + HavePrintedMatcher.new(what) +end + +RSpec::Matchers.define :equal_attributes_of do |expected| + match do |actual| + actual.instance_variables.all? do |attr| + actual.instance_variable_get(attr) == expected.instance_variable_get(attr) + end + end +end + +RSpec::Matchers.define :be_one_of do |*expected| + match do |actual| + expected.include? actual + end + + failure_message_for_should do |actual| + "expected #{actual.inspect} to be one of #{expected.map(&:inspect).join(' or ')}" + end +end diff --git a/spec/lib/puppet_spec/modules.rb b/spec/lib/puppet_spec/modules.rb new file mode 100644 index 0000000..6835e44 --- /dev/null +++ b/spec/lib/puppet_spec/modules.rb @@ -0,0 +1,26 @@ +module PuppetSpec::Modules + class << self + def create(name, dir, options = {}) + module_dir = File.join(dir, name) + FileUtils.mkdir_p(module_dir) + + environment = options[:environment] + + if metadata = options[:metadata] + metadata[:source] ||= 'github' + metadata[:author] ||= 'puppetlabs' + metadata[:version] ||= '9.9.9' + metadata[:license] ||= 'to kill' + metadata[:dependencies] ||= [] + + metadata[:name] = "#{metadata[:author]}/#{name}" + + File.open(File.join(module_dir, 'metadata.json'), 'w') do |f| + f.write(metadata.to_pson) + end + end + + Puppet::Module.new(name, module_dir, environment) + end + end +end diff --git a/spec/lib/puppet_spec/pops.rb b/spec/lib/puppet_spec/pops.rb new file mode 100644 index 0000000..442c85b --- /dev/null +++ b/spec/lib/puppet_spec/pops.rb @@ -0,0 +1,16 @@ +module PuppetSpec::Pops + extend RSpec::Matchers::DSL + + # Checks if an Acceptor has a specific issue in its list of diagnostics + matcher :have_issue do |expected| + match do |actual| + actual.diagnostics.index { |i| i.issue == expected } != nil + end + failure_message_for_should do |actual| + "expected Acceptor[#{actual.diagnostics.collect { |i| i.issue.issue_code }.join(',')}] to contain issue #{expected.issue_code}" + end + failure_message_for_should_not do |actual| + "expected Acceptor[#{actual.diagnostics.collect { |i| i.issue.issue_code }.join(',')}] to not contain issue #{expected.issue_code}" + end + end +end diff --git a/spec/lib/puppet_spec/scope.rb b/spec/lib/puppet_spec/scope.rb new file mode 100644 index 0000000..c14ab47 --- /dev/null +++ b/spec/lib/puppet_spec/scope.rb @@ -0,0 +1,14 @@ + +module PuppetSpec::Scope + # Initialize a new scope suitable for testing. + # + def create_test_scope_for_node(node_name) + node = Puppet::Node.new(node_name) + compiler = Puppet::Parser::Compiler.new(node) + scope = Puppet::Parser::Scope.new(compiler) + scope.source = Puppet::Resource::Type.new(:node, node_name) + scope.parent = compiler.topscope + scope + end + +end \ No newline at end of file diff --git a/spec/lib/puppet_spec/settings.rb b/spec/lib/puppet_spec/settings.rb new file mode 100644 index 0000000..f3dbc42 --- /dev/null +++ b/spec/lib/puppet_spec/settings.rb @@ -0,0 +1,15 @@ +module PuppetSpec::Settings + + # It would probably be preferable to refactor defaults.rb such that the real definitions of + # these settings were available as a variable, which was then accessible for use during tests. + # However, I'm not doing that yet because I don't want to introduce any additional moving parts + # to this already very large changeset. + # Would be nice to clean this up later. --cprice 2012-03-20 + TEST_APP_DEFAULT_DEFINITIONS = { + :name => { :default => "test", :desc => "name" }, + :logdir => { :type => :directory, :default => "test", :desc => "logdir" }, + :confdir => { :type => :directory, :default => "test", :desc => "confdir" }, + :vardir => { :type => :directory, :default => "test", :desc => "vardir" }, + :rundir => { :type => :directory, :default => "test", :desc => "rundir" }, + } +end diff --git a/spec/lib/puppet_spec/verbose.rb b/spec/lib/puppet_spec/verbose.rb new file mode 100755 index 0000000..d9834f2 --- /dev/null +++ b/spec/lib/puppet_spec/verbose.rb @@ -0,0 +1,9 @@ +# Support code for running stuff with warnings disabled. +module Kernel + def with_verbose_disabled + verbose, $VERBOSE = $VERBOSE, nil + result = yield + $VERBOSE = verbose + return result + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 931d35c..cf1981b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,21 +1,31 @@ dir = File.expand_path(File.dirname(__FILE__)) $LOAD_PATH.unshift File.join(dir, 'lib') -# Don't want puppet getting the command line arguments for rake or autotest -ARGV.clear +# So everyone else doesn't have to include this base constant. +module PuppetSpec + FIXTURE_DIR = File.join(dir = File.expand_path(File.dirname(__FILE__)), "fixtures") unless defined?(FIXTURE_DIR) +end require 'puppet' -require 'facter' -require 'mocha' -gem 'rspec', '>=2.0.0' -require 'rspec/expectations' - +require 'rspec-puppet' +require 'simplecov' require 'puppetlabs_spec_helper/module_spec_helper' +require 'puppet_spec/verbose' +require 'puppet_spec/files' +require 'puppet_spec/settings' +require 'puppet_spec/fixtures' +require 'puppet_spec/matchers' +require 'puppet_spec/database' +require 'monkey_patches/alias_should_to_must' +require 'mocha/setup' + + +SimpleCov.start do + add_filter "/spec/" +end + RSpec.configure do |config| - # FIXME REVISIT - We may want to delegate to Facter like we do in - # Puppet::PuppetSpecInitializer.initialize_via_testhelper(config) because - # this behavior is a duplication of the spec_helper in Facter. config.before :each do # Ensure that we don't accidentally cache facts and environment between # test cases. This requires each example group to explicitly load the diff --git a/spec/unit/puppet/parser/functions/merge_spec.rb b/spec/unit/puppet/parser/functions/merge_spec.rb index db7d837..79079b6 100644 --- a/spec/unit/puppet/parser/functions/merge_spec.rb +++ b/spec/unit/puppet/parser/functions/merge_spec.rb @@ -25,7 +25,12 @@ describe Puppet::Parser::Functions.function(:merge) do describe 'when calling merge on the scope instance' do it 'should require all parameters are hashes' do - expect { new_hash = scope.function_merge([{}, '2'])}.should raise_error(Puppet::ParseError, /unexpected argument type String/) + expect { new_hash = scope.function_merge([{}, '2'])}.to raise_error(Puppet::ParseError, /unexpected argument type String/) + expect { new_hash = scope.function_merge([{}, 2])}.to raise_error(Puppet::ParseError, /unexpected argument type Fixnum/) + end + + it 'should accept empty strings as puppet undef' do + expect { new_hash = scope.function_merge([{}, ''])}.to raise_error end it 'should be able to merge two hashes' do diff --git a/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb b/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb index 08aaf78..1c9cce2 100644 --- a/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb +++ b/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb @@ -35,7 +35,7 @@ describe Puppet::Parser::Functions.function(:validate_absolute_path) do end valid_paths.each do |path| it "validate_absolute_path(#{path.inspect}) should not fail" do - expect { subject.call [path] }.not_to raise_error Puppet::ParseError + expect { subject.call [path] }.not_to raise_error end end end @@ -43,7 +43,7 @@ describe Puppet::Parser::Functions.function(:validate_absolute_path) do context "Puppet without mocking" do valid_paths.each do |path| it "validate_absolute_path(#{path.inspect}) should not fail" do - expect { subject.call [path] }.not_to raise_error Puppet::ParseError + expect { subject.call [path] }.not_to raise_error end end end diff --git a/spec/unit/puppet/provider/file_line/ruby_spec.rb b/spec/unit/puppet/provider/file_line/ruby_spec.rb index 7857d39..50f5840 100644 --- a/spec/unit/puppet/provider/file_line/ruby_spec.rb +++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb @@ -1,4 +1,4 @@ -require 'puppet' +require 'spec_helper' require 'tempfile' provider_class = Puppet::Type.type(:file_line).provider(:ruby) describe provider_class do diff --git a/spec/unit/puppet/type/anchor_spec.rb b/spec/unit/puppet/type/anchor_spec.rb index 2030b83..f92065f 100644 --- a/spec/unit/puppet/type/anchor_spec.rb +++ b/spec/unit/puppet/type/anchor_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require 'puppet' +require 'spec_helper' anchor = Puppet::Type.type(:anchor).new(:name => "ntp::begin") diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index 0cd8a26..37f3861 100644 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -1,4 +1,4 @@ -require 'puppet' +require 'spec_helper' require 'tempfile' describe Puppet::Type.type(:file_line) do let :file_line do diff --git a/spec/watchr.rb b/spec/watchr.rb deleted file mode 100644 index 885ef1d..0000000 --- a/spec/watchr.rb +++ /dev/null @@ -1,86 +0,0 @@ -ENV['FOG_MOCK'] ||= 'true' -ENV['AUTOTEST'] = 'true' -ENV['WATCHR'] = '1' - -system 'clear' - -def growl(message) - growlnotify = `which growlnotify`.chomp - title = "Watchr Test Results" - image = case message - when /(\d+)\s+?(failure|error)/i - ($1.to_i == 0) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png" - else - '~/.watchr_images/unknown.png' - end - options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'" - system %(#{growlnotify} #{options} &) -end - -def run(cmd) - puts(cmd) - `#{cmd}` -end - -def run_spec_test(file) - if File.exist? file - result = run "rspec --format p --color #{file}" - growl result.split("\n").last - puts result - else - puts "FIXME: No test #{file} [#{Time.now}]" - end -end - -def filter_rspec(data) - data.split("\n").find_all do |l| - l =~ /^(\d+)\s+exampl\w+.*?(\d+).*?failur\w+.*?(\d+).*?pending/ - end.join("\n") -end - -def run_all_tests - system('clear') - files = Dir.glob("spec/**/*_spec.rb").join(" ") - result = run "rspec #{files}" - growl_results = filter_rspec result - growl growl_results - puts result - puts "GROWL: #{growl_results}" -end - -# Ctrl-\ -Signal.trap 'QUIT' do - puts " --- Running all tests ---\n\n" - run_all_tests -end - -@interrupted = false - -# Ctrl-C -Signal.trap 'INT' do - if @interrupted then - @wants_to_quit = true - abort("\n") - else - puts "Interrupt a second time to quit" - @interrupted = true - Kernel.sleep 1.5 - # raise Interrupt, nil # let the run loop catch it - run_suite - end -end - -def file2spec(file) - result = file.sub('lib/puppet/', 'spec/unit/puppet/').gsub(/\.rb$/, '_spec.rb') - result = file.sub('lib/facter/', 'spec/unit/facter/').gsub(/\.rb$/, '_spec.rb') -end - - -watch( 'spec/.*_spec\.rb' ) do |md| - #run_spec_test(md[0]) - run_all_tests -end -watch( 'lib/.*\.rb' ) do |md| - # run_spec_test(file2spec(md[0])) - run_all_tests -end -- cgit v1.2.3 From 0bf470a71b8e6476645fb241faef12e30b2193ac Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Mon, 10 Mar 2014 13:07:43 -0700 Subject: Remove pry, whoops. --- spec/classes/anchor_spec.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/classes/anchor_spec.rb b/spec/classes/anchor_spec.rb index 6754811..2e1fcba 100644 --- a/spec/classes/anchor_spec.rb +++ b/spec/classes/anchor_spec.rb @@ -22,8 +22,6 @@ describe "anchorrefresh" do end it 'propagates events through the anchored class' do - require 'pry' - binding.pry resource = transaction.resource_status('Anchor[final]') expect(resource.restarted).to eq(true) -- cgit v1.2.3 From 3feb846cf41d53a6ca7c0f4ea420df56c687a2ec Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Tue, 11 Mar 2014 09:21:37 -0700 Subject: Ensure Gemfile retains facilities for Jenkins. --- Gemfile | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 3d6d5ea..4604d1b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,15 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' +def location_for(place, fake_version = nil) + if place =~ /^(git[:@][^#]*)#(.*)/ + [fake_version, { :git => $1, :branch => $2, :require => false }].compact + elsif place =~ /^file:\/\/(.*)/ + ['>= 0', { :path => File.expand_path($1), :require => false }] + else + [place, { :require => false }] + end +end + group :development, :test do gem 'rake', :require => false gem 'rspec-puppet', :require => false @@ -15,8 +25,10 @@ group :development, :test do gem 'beaker-rspec', :require => false end -if puppetversion = ENV['PUPPET_GEM_VERSION'] - gem 'puppet', puppetversion, :require => false +ENV['GEM_PUPPET_VERSION'] ||= ENV['PUPPET_GEM_VERSION'] +puppetversion = ENV['GEM_PUPPET_VERSION'] +if puppetversion + gem 'puppet', *location_for(puppetversion) else gem 'puppet', :require => false end -- cgit v1.2.3 From 9aa28f1c100d7703aa1bb9fbe2bcf02bf781b486 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 13 Mar 2014 11:10:01 -0700 Subject: Remove this test. It turns out that in 3.x the refresh functionality doesn't actually exist yet, so testing it makes no sense. --- spec/classes/anchor_spec.rb | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 spec/classes/anchor_spec.rb diff --git a/spec/classes/anchor_spec.rb b/spec/classes/anchor_spec.rb deleted file mode 100644 index 2e1fcba..0000000 --- a/spec/classes/anchor_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' -require 'puppet_spec/compiler' - -describe "anchorrefresh" do - include PuppetSpec::Compiler - - let :transaction do - apply_compiled_manifest(<<-ANCHORCLASS) - class anchored { - anchor { 'anchored::begin': } - ~> anchor { 'anchored::end': } - } - - class anchorrefresh { - notify { 'first': } - ~> class { 'anchored': } - ~> anchor { 'final': } - } - - include anchorrefresh - ANCHORCLASS - end - - it 'propagates events through the anchored class' do - resource = transaction.resource_status('Anchor[final]') - - expect(resource.restarted).to eq(true) - end -end -- cgit v1.2.3