puppetry_toolbox 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 728dd6cf900292d60d1ab928de71d2d4ad72779d
4
- data.tar.gz: c5f205bfd548448e2e28cd8836707f984855f5cc
3
+ metadata.gz: 2d6648354d4386e03c4d382bac0e88e612e3e3c7
4
+ data.tar.gz: de74d6251ae3c93d93404649808a6bb7ad9b6d60
5
5
  SHA512:
6
- metadata.gz: b9215068d3e3b4f80530825be51a9cc3a94300a8ae496d96f7bddfe61e0aa5e83fb110511ba5e04d94572989545fe66ac641eef59ca4d0283ba23b8ee3822988
7
- data.tar.gz: 128342723db841153416165b5e5f485a0e519c00c174761af2a82a184f51c899c5bd65b0f6bef7693d16f6b2f111c513bf90a9657c59cdc910fcef2eee074582
6
+ metadata.gz: 809c7654c522771faa47721c6db158027e7621194877afef2e8549111be6140df70e3188318838f2fade27cd79f9045ee72f2d001689c2b3c662de7795af38c7
7
+ data.tar.gz: 3a507a31ed1bc4f12b48a71ddf540dd9748abee3e8b83526f098bca09f45554ac75bad6435db2e23b598e52f1c29397310d2a0c3d7a922330a3e46597b63e560
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ Gemfile.lock
5
5
  .bundle
6
6
  vendor
7
7
  pkg
8
+ coverage
data/README.md CHANGED
@@ -7,14 +7,14 @@
7
7
  [![Coverage Status](https://coveralls.io/repos/stefanozanella/puppetry/badge.png?branch=master)](https://coveralls.io/r/stefanozanella/puppetry?branch=master)
8
8
  ## Installation
9
9
  Puppetry is currently shipped as a gem, so you just need to install it with:
10
- ~~~
10
+ ```
11
11
  $ gem install puppetry_toolbox
12
- ~~~
12
+ ```
13
13
  or, if you're using Bundler, set the following dependency line in your
14
14
  `Gemfile`:
15
- ~~~
15
+ ```
16
16
  gem 'puppetry_toolbox'
17
- ~~~
17
+ ```
18
18
 
19
19
  ## Usage
20
20
  Puppetry can help you with the development of a Puppet module in many ways.
@@ -29,9 +29,16 @@ Since this is almost all repeatable stuff, Puppetry ships with a command to
29
29
  generate the scaffolding for a new module.
30
30
 
31
31
  Let's pretend you want to start working on the `my_nice_module` module; then you just need to:
32
- ~~~
32
+ ```
33
33
  puppetry new my_nice_module
34
- ~~~
34
+ ```
35
35
  This will generate a `my_nice_module` subdirectory in the current working
36
36
  directory. This directory will contain everything you need to start developing
37
37
  your new module.
38
+
39
+ ### Adding a new test
40
+ ```
41
+ $ puppetry test new_class
42
+ $ puppetry test -c new_class
43
+ $ puppetry test --class new_class
44
+ ```
@@ -2,12 +2,13 @@ require 'thor'
2
2
  require 'grit'
3
3
  require 'fileutils'
4
4
  require 'puppetry/version'
5
+ require 'bundler'
5
6
 
6
7
  module Puppetry
7
8
  class CLI < Thor
8
9
  desc "version", "Print application's version"
9
10
  def version
10
- puts "Puppetry v#{Puppetry::Version}"
11
+ output.puts "Puppetry v#{Puppetry::Version}"
11
12
  end
12
13
 
13
14
  desc "new NAME", "Create a new module called NAME"
@@ -22,5 +23,23 @@ module Puppetry
22
23
  end
23
24
  end
24
25
  end
26
+
27
+ no_commands do
28
+ ##
29
+ # Overrides the default output stream (`$stdout`) used by the
30
+ # application. Useful for testing.
31
+ #
32
+ # param output [IO] An IO object that will receive the CLI standard
33
+ # output
34
+ def output=(output)
35
+ @output = output
36
+ end
37
+
38
+ private
39
+
40
+ def output
41
+ @output || $stdout
42
+ end
43
+ end
25
44
  end
26
45
  end
@@ -1,3 +1,3 @@
1
1
  module Puppetry
2
- Version = VERSION = '0.0.3'.freeze
2
+ Version = VERSION = '0.0.4'.freeze
3
3
  end
@@ -4,47 +4,42 @@ require 'tmpdir'
4
4
  require 'fileutils'
5
5
 
6
6
  describe "puppetry" do
7
+ let(:module_dir) { "test_module" }
8
+ let(:out) { StringIO.new }
9
+ let(:working_dir) { Dir.mktmpdir }
10
+ let(:cli) { Puppetry::CLI.new }
11
+
7
12
  before do
8
- @orig_stdout = $stdout
9
- $stdout = StringIO.new
13
+ cli.output = out
10
14
  end
11
15
 
12
16
  after do
13
- $stdout = @orig_stdout
17
+ FileUtils.remove_entry_secure working_dir
14
18
  end
15
19
 
16
20
  describe "version" do
17
21
  it "shows the application's version" do
18
- Puppetry::CLI.start(["version"])
19
- $stdout.string.must_match(/#{Puppetry::VERSION}/)
22
+ cli.version
23
+ out.string.must_match(/#{Puppetry::VERSION}/)
20
24
  end
21
25
  end
22
26
 
23
27
  describe "new" do
24
- it "creates a new module starting from a scaffolded one" do
25
- Dir.mktmpdir do |dir|
26
- FileUtils.cd(dir) do
27
- Puppetry::CLI.start(["new", "test_module"])
28
-
29
- # test_module should exist and not be empty
30
- assert Dir.exists?("test_module"), "Module folder test_module wasn't created"
31
- Dir.entries("test_module").wont_be_empty
32
- # test_module should contain at least the manifests folder
33
- Dir.entries("test_module").must_include "manifests"
34
- # test_module should not be a git repo (for the moment)
35
- Dir.entries("test_module").wont_include ".git"
36
- end
37
- end
28
+ before do
29
+ @old_pwd = FileUtils.pwd
30
+ FileUtils.cd(working_dir)
31
+
32
+ cli.new module_dir
38
33
  end
39
34
 
40
- it "runs bundler to install deps after folder initialization" do
41
- Dir.mktmpdir do |dir|
42
- FileUtils.cd(dir) do
43
- Puppetry::CLI.start(["new", "test_module_setup"])
35
+ after do
36
+ FileUtils.cd @old_pwd
37
+ end
44
38
 
45
- assert Dir.entries("test_module_setup").must_include ".bundle"
46
- end
47
- end
39
+ it "creates a new module starting from a scaffolded one" do
40
+ module_dir.must_contain_a_puppet_module
41
+ module_dir.wont_be_a_git_repository
42
+ assert_bundler_is_initialized_in module_dir
48
43
  end
49
44
  end
50
45
  end
@@ -0,0 +1 @@
1
+ require 'puppetry/test/custom_assertions'
@@ -0,0 +1,20 @@
1
+ module MiniTest::Assertions
2
+ def assert_contains_a_puppet_module(dir)
3
+ assert Dir.exists?(dir), "Module folder #{dir} wasn't created"
4
+ Dir.entries(dir).wont_be_empty
5
+ Dir.entries(dir).must_include "manifests"
6
+ end
7
+
8
+ def refute_git_repository(dir)
9
+ Dir.entries(dir).wont_include ".git"
10
+ end
11
+
12
+ def assert_bundler_is_initialized_in(dir)
13
+ assert Dir.entries(dir).include?(".bundle"), "Bundler hasn't been initialized in folder #{dir}"
14
+ end
15
+ end
16
+
17
+ module MiniTest::Expectations
18
+ infect_an_assertion :assert_contains_a_puppet_module, :must_contain_a_puppet_module, :only_one_argument
19
+ infect_an_assertion :refute_git_repository, :wont_be_a_git_repository, :only_one_argument
20
+ end
@@ -1,3 +1,5 @@
1
+ $: << File.join(File.dirname(__FILE__), 'lib')
2
+
1
3
  require 'coveralls'
2
4
  Coveralls.wear!
3
5
 
@@ -5,4 +7,5 @@ require 'minitest/autorun'
5
7
  require 'minitest/pride'
6
8
  require 'minitest/spec'
7
9
 
10
+ require 'puppetry/test'
8
11
  require 'puppetry'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppetry_toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Zanella
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-21 00:00:00.000000000 Z
11
+ date: 2013-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -104,6 +104,8 @@ files:
104
104
  - lib/puppetry/version.rb
105
105
  - puppetry.gemspec
106
106
  - test/end_to_end/puppetry_test.rb
107
+ - test/lib/puppetry/test.rb
108
+ - test/lib/puppetry/test/custom_assertions.rb
107
109
  - test/test_helper.rb
108
110
  homepage: https://github.com/stefanozanella/puppetry
109
111
  licenses: []
@@ -131,4 +133,6 @@ specification_version: 4
131
133
  summary: Puppetry is a CLI tool to aid Puppet modules development.
132
134
  test_files:
133
135
  - test/end_to_end/puppetry_test.rb
136
+ - test/lib/puppetry/test.rb
137
+ - test/lib/puppetry/test/custom_assertions.rb
134
138
  - test/test_helper.rb