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 +4 -4
- data/.gitignore +1 -0
- data/README.md +13 -6
- data/lib/puppetry/cli.rb +20 -1
- data/lib/puppetry/version.rb +1 -1
- data/test/end_to_end/puppetry_test.rb +21 -26
- data/test/lib/puppetry/test.rb +1 -0
- data/test/lib/puppetry/test/custom_assertions.rb +20 -0
- data/test/test_helper.rb +3 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d6648354d4386e03c4d382bac0e88e612e3e3c7
|
4
|
+
data.tar.gz: de74d6251ae3c93d93404649808a6bb7ad9b6d60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 809c7654c522771faa47721c6db158027e7621194877afef2e8549111be6140df70e3188318838f2fade27cd79f9045ee72f2d001689c2b3c662de7795af38c7
|
7
|
+
data.tar.gz: 3a507a31ed1bc4f12b48a71ddf540dd9748abee3e8b83526f098bca09f45554ac75bad6435db2e23b598e52f1c29397310d2a0c3d7a922330a3e46597b63e560
|
data/.gitignore
CHANGED
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
|
+
```
|
data/lib/puppetry/cli.rb
CHANGED
@@ -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
|
data/lib/puppetry/version.rb
CHANGED
@@ -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
|
-
|
9
|
-
$stdout = StringIO.new
|
13
|
+
cli.output = out
|
10
14
|
end
|
11
15
|
|
12
16
|
after do
|
13
|
-
|
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
|
-
|
19
|
-
|
22
|
+
cli.version
|
23
|
+
out.string.must_match(/#{Puppetry::VERSION}/)
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
23
27
|
describe "new" do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
Puppetry::CLI.start(["new", "test_module_setup"])
|
35
|
+
after do
|
36
|
+
FileUtils.cd @old_pwd
|
37
|
+
end
|
44
38
|
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
data/test/test_helper.rb
CHANGED
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.
|
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-
|
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
|