Skip to content

Commit

Permalink
Merge pull request #199 from tas50/master
Browse files Browse the repository at this point in the history
Add test Rake task and Travis config
  • Loading branch information
tas50 committed Jan 19, 2016
2 parents 57a7ef1 + 20360b2 commit 7c81219
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: ruby
cache: bundler
sudo: false

rvm:
- 2.2.0

branches:
only:
- master
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Fauxhai
=======
# Fauxhai
[![Build Status Master](https://travis-ci.org/customink/fauxhai.svg?branch=master)](https://travis-ci.org/customink/fauxhai)
[![Gem Version](https://badge.fury.io/rb/fauxhai.svg)](https://badge.fury.io/rb/fauxhai)

Fauxhai is a gem for mocking out [ohai](https://github.com/chef/ohai) data in your chef testing. Fauxhai is community supported, so we need **your help** to populate our dataset. Here's an example for testing my "awesome_cookbook" on Ubuntu:

```ruby
Expand Down Expand Up @@ -36,19 +38,16 @@ end

Fauxhai supports [ChefSpec](https://github.com/sethvargo/chefspec) and [rspec-chef](https://github.com/calavera/rspec-chef). In order to prevent polluting the README, only ChefSpec examples will be provided. However, there is an extensive README for each testing framework in the [examples](https://github.com/customink/fauxhai/tree/master/examples) directory.

Important Note
--------------
## Important Note
Fauxhai ships with a command line tool - `fauxhai`. This is **not** the same as Fauxhai.mock. Running `fauxhai` on a machine effectively runs `ohai`, but then sanitizes the data, removing/replacing things like:

- users
- ssh keys
- usernames in paths
- sensitive system information

`fauxhai` should only be used by developers wishing to submit a new json file.

Usage
-----
## Usage
Fauxhai provides a bunch of default attributes so that you don't need to mock out your entire infastructure to write a simple test. That being said, not all configurations will suit your needs. Because of that, Fauxhai provides two ways to configure your mocks:

### Overriding
Expand Down Expand Up @@ -145,8 +144,7 @@ describe 'awesome_cookbook::default' do
end
```

Testing Multiple Versions
-------------------------
## Testing Multiple Versions
It's a common use case to test multiple version of the same operating system. Here's a simple example to get your started. This is more rspec-related that fauxhai related, but here ya go:

```ruby
Expand All @@ -168,6 +166,5 @@ describe 'awesome_cookbook::default' do
end
```

Contributing
------------
## Contributing
See [CONTRIBUTING.md](https://github.com/customink/fauxhai/blob/master/CONTRIBUTING.md).
9 changes: 6 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
require 'bundler/gem_tasks'
require 'json'

namespace :validate do
desc "Validate mock platform data is valid JSON"
task :default => ['validate:json']

namespace :validate do
desc 'Validate mock platform data is valid JSON'
task :json do
Dir.glob("./lib/fauxhai/platforms/**/*.json") do |file|
Dir.glob('./lib/fauxhai/platforms/**/*.json') do |file|
begin
JSON.parse(File.read(file))
rescue JSON::ParserError => e
puts "Failed to parse #{file}."
end
end
puts 'JSON files validated'
end
end

0 comments on commit 7c81219

Please sign in to comment.