Skip to content

Commit

Permalink
fix markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed May 20, 2017
1 parent 08ca62d commit 3e23dd8
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#beaker-rspec
# beaker-rspec

beaker-rspec is a bridge between the puppet acceptance test harness ([beaker](https://github.com/puppetlabs/beaker)) and [rspec](https://github.com/rspec/rspec). It also integrates [serverspec](http://serverspec.org/).

#Upgrading from beaker-rspec 5 to 6
# Upgrading from beaker-rspec 5 to 6

In beaker-rspec 6, we've picked up the newest beaker, 3.y. In this release, we've
given up support for Ruby 1.9 and moved to 2.2.5 as our lowest tested version,
Expand All @@ -13,25 +13,28 @@ To learn more about those changes, please checkout our
doc. Note that besides the Ruby version & beaker dependency change, nothing else
was changed in beaker-rspec itself.

#Typical Workflow
# Typical Workflow

Beaker does setup and provision all nodes from your nodeset on each test run, and cleans up the VMs after use. During development on a module it can be very handy to keep the VMs available for inspection or reuse. Set `BEAKER_destroy=no` do skip the cleanup and `BEAKER_provision=no` once the VMs are created.

1. Run tests with `BEAKER_destroy=no`, no setting for `BEAKER_provision`
* beaker-rspec will use spec/acceptance/nodesets/default.yml node file
* boxes will be newly provisioned
* boxes will be preserved post-testing
* Run tests with `BEAKER_destroy=no`, no setting for `BEAKER_provision`
* beaker-rspec will use spec/acceptance/nodesets/default.yml node file
* boxes will be newly provisioned
* boxes will be preserved post-testing

* Run tests with `BEAKER_destroy=no` and `BEAKER_provision=no`
* beaker-rspec will use spec/acceptance/nodesets/default.yml node file
* boxes will be re-used from previous run
* boxes will be preserved post-testing
* Nodes become corrupted with too many test runs/bad data and need to be refreshed then set `BEAKER_provision=yes`
* Testing is complete and you want to clean up, run once more with `BEAKER_destroy` unset
* you can also:
* beaker-rspec will use spec/acceptance/nodesets/default.yml node file
* boxes will be re-used from previous run
* boxes will be preserved post-testing
* Nodes become corrupted with too many test runs/bad data and need to be refreshed then set `BEAKER_provision=yes`
* Testing is complete and you want to clean up, run once more with `BEAKER_destroy` unset
* you can also:

cd .vagrant/beaker_vagrant_files/default.yml ; vagrant destroy --force
```
cd .vagrant/beaker_vagrant_files/default.yml ; vagrant destroy --force
```

##Supported ENV variables
## Supported ENV variables

* `BEAKER_color`: set to `no` to disable color output
* `BEAKER_debug`: set to any value to enable beaker debug logging
Expand All @@ -43,16 +46,16 @@ Beaker does setup and provision all nodes from your nodeset on each test run, an

For details on the specific mappings, the [setup code](https://github.com/puppetlabs/beaker-rspec/blob/2771b4b1864692690254a969680a57ff22ac0516/lib/beaker-rspec/spec_helper.rb#L26-L32) and the [beaker docs](https://github.com/puppetlabs/beaker/blob/master/docs/tutorials/the_command_line.md).

#Building your Module Testing Environment
# Building your Module Testing Environment

Using puppetlabs-mysql as an example module.

##Clone the module repository of the module where you want to add tests
## Clone the module repository of the module where you want to add tests

git clone https://github.com/puppetlabs/puppetlabs-mysql
cd puppetlabs-mysql

##Install beaker-rspec
## Install beaker-rspec

In module's top level directory edit the Gemfile. You should see a `:system_tests`
or `:acceptance` group there, but if not, add beaker-rspec there:
Expand All @@ -67,7 +70,7 @@ Then run

bundle install

##Create node files
## Create node files

These files indicate the nodes (or hosts) that the tests will be run on. By default, any node file called `default.yml` will be used. You can override this using the `BEAKER_set` environment variable to indicate an alternate file. Do not provide full path or the '.yml' file extension to `BEAKER_set`, it is assumed to be located in 'spec/acceptance/nodesets/${NAME}.yml' by beaker-rspec. If you wish to use a completely different file location use `BEAKER_setfile` and set it to the full path (including file extension) of your hosts file.

Expand All @@ -83,7 +86,7 @@ Create the nodesets directory. From module's top level directory:

Copy any nodesets that you wish to use into the nodesets directory.

##Create the spec_helper_acceptance.rb
## Create the spec_helper_acceptance.rb

In the `spec` folder, you should see the project's `spec_helper_acceptance.rb`.
This file contains all of the setup logic needed to get your Systems Under Test
Expand Down Expand Up @@ -133,7 +136,7 @@ This method will install the latest puppet-agent from the specified

Update spec_helper_acceptance.rb to reflect the module under test. You will need to set the correct module name and add any module dependencies. Place the file in the `spec` directory (in this case `puppetlabs-mysql/spec`)

##Create spec tests for your module
## Create spec tests for your module

Spec tests are written in [RSpec](http://rspec.info). You can also use [serverspec](http://serverspec.org/) matchers to test [resources](http://serverspec.org/resource_types.html).

Expand Down Expand Up @@ -178,8 +181,10 @@ describe 'mysql::server::account_security class' do
end
```

##Run your spec tests
## Run your spec tests

From module's top level directory

bundle exec rspec spec/acceptance
```
bundle exec rspec spec/acceptance
```

0 comments on commit 3e23dd8

Please sign in to comment.