Skip to content

Commit

Permalink
Merge branch 'release/v0.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Suszyński Krzysztof committed Jul 3, 2017
2 parents 73d76f7 + 6fc1ce5 commit e204174
Show file tree
Hide file tree
Showing 19 changed files with 504 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/.bundle/
/vendor/
/.yardoc
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/

# rspec failure tracking
.rspec_status
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--format documentation
--color
20 changes: 20 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
inherit_from: .rubocop_todo.yml
AllCops:
TargetRubyVersion: 1.9
Include:
- ./**/*.rb
Exclude:
- vendor/**/*
- .vendor/**/*
Metrics/LineLength:
Max: 140
Style/FileName:
Exclude:
- 'Gemfile'
- 'Rakefile'
- '*.gemspec'
- lib/puppet-examples-helpers.rb
- spec/puppet-examples-helpers_spec.rb
Metrics/BlockLength:
Exclude:
- 'spec/**/*_spec.rb'
7 changes: 7 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-06-14 18:06:57 +0200 using RuboCop version 0.49.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sudo: false
language: ruby
matrix:
fast_finish: true
include:
- rvm: '1.9'
bundler_args: '--no-deployment --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}'
- rvm: '2.1'
- rvm: '2.3'
- rvm: '2.4'
before_install: gem install bundler -v 1.15.1
74 changes: 74 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
21 changes: 21 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'

RVERSION = Gem::Version.new(RUBY_VERSION.dup)

def req(req_s)
Gem::Requirement.new(req_s)
end

group :test do
gem 'rspec', '~> 3', require: false
gem 'rubocop', '~> 0.49', require: false if req('>= 2.0') =~ RVERSION
gem 'simplecov', '~> 0.14.1', require: false
end

group :development do
gem 'pry-byebug', '~> 3.4', '>= 3.4.2', require: false if req('>= 2.0') =~ RVERSION
gem 'rake', '~> 10', require: false
end

# Specify your gem's dependencies in puppet-examples-helpers.gemspec
gemspec
72 changes: 72 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
PATH
remote: .
specs:
puppet-examples-helpers (0.1.0)

GEM
remote: https://rubygems.org/
specs:
ast (2.3.0)
byebug (9.0.6)
coderay (1.1.1)
diff-lcs (1.3)
docile (1.1.5)
json (1.8.6)
method_source (0.8.2)
parallel (1.11.2)
parser (2.4.0.0)
ast (~> 2.2)
powerpack (0.1.1)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-byebug (3.4.2)
byebug (~> 9.0)
pry (~> 0.10)
rainbow (2.2.2)
rake
rake (10.5.0)
rspec (3.6.0)
rspec-core (~> 3.6.0)
rspec-expectations (~> 3.6.0)
rspec-mocks (~> 3.6.0)
rspec-core (3.6.0)
rspec-support (~> 3.6.0)
rspec-expectations (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-mocks (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-support (3.6.0)
rubocop (0.49.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
simplecov (0.14.1)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.1)
slop (3.6.0)
unicode-display_width (1.3.0)

PLATFORMS
ruby

DEPENDENCIES
bundler (~> 1.15)
pry-byebug (~> 3.4, >= 3.4.2)
puppet-examples-helpers!
rake (~> 10)
rspec (~> 3)
rubocop (~> 0.49)
simplecov (~> 0.14.1)

BUNDLED WITH
1.15.1
13 changes: 13 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2017 Center for Information Technology, Poland

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
97 changes: 97 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# PuppetExamplesHelpers

[![Build Status](https://travis-ci.org/coi-gov-pl/puppet-examples-helpers.svg?branch=develop)](https://travis-ci.org/coi-gov-pl/puppet-examples-helpers)

Helpers to utilize puppet example files.

Using new `example` method you can read and execute example file provided in puppet modules in accetance tests.

```ruby
# Sets code to contents of examples/init.pp file
let(:code) { example '::modulename' }
```

## Installation

Add this to your puppet module's Gemfile:

```ruby
group :system_tests do
# [..]
gem 'puppet-examples-helpers'
end
```

And then execute:

$ bundle

Or install it yourself as:

$ gem install puppet-examples-helpers

## Usage

### RSpec Acceptance Helper

```ruby
# file: spec/spec_helper_acceptance.rb
require 'puppet'
require 'beaker-rspec'
require 'beaker/puppet_install_helper'
require 'beaker/module_install_helper'
require 'puppet-examples-helpers'

UNSUPPORTED_PLATFORMS = %w[Suse windows AIX Solaris].freeze

run_puppet_install_helper
install_module
install_module_dependencies

RSpec.configure do |c|
c.include PuppetExamplesHelpers

c.formatter = :documentation
end
```

### Acceptance Test Example

```ruby
# file: spec/acceptance/jboss/internal/service_spec.rb
require 'spec_helper_acceptance'

describe '::jboss::internal::service', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
# Reads examples/internal/service.pp file
let(:code) { example '::jboss::internal::service' }

it 'should work with no errors' do
result = apply_manifest(code, catch_failures: true)
expect(result.exit_code).to be(2)
end
it 'should work idempotently' do
apply_manifest(code, catch_changes: true)
end
describe service('wildfly') do
it { is_expected.to be_running }
end
end
```

## Development

After checking out the repo, run `bundle` to install dependencies. Then, run `bundle exec rake spec` to run the tests. You can also run `bundle exec rake console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/coi-gov-pl/puppet-examples-helpers. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

The gem is available as open source under the terms of the [Apache 2.0](https://opensource.org/licenses/Apache-2.0).

## Code of Conduct

Everyone interacting in the Puppet::Examples::Helper project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/coi-gov-pl/puppet-examples-helpers/blob/master/CODE_OF_CONDUCT.md).
20 changes: 20 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
def gem_present(name)
!Bundler.rubygems.find_name(name).empty?
end

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

test_tasks = [:spec]

if gem_present 'rubocop'
require 'rubocop/rake_task'
RuboCop::RakeTask.new
test_tasks.unshift(:rubocop)
end

task test: test_tasks

task default: :test
1 change: 1 addition & 0 deletions examples/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
debug('an main init.pp')
1 change: 1 addition & 0 deletions examples/sample.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
info('sample file')
1 change: 1 addition & 0 deletions examples/sub/showoff.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
debug('just to show off')
Loading

0 comments on commit e204174

Please sign in to comment.