Skip to content

Commit

Permalink
A few more fine tunes to the test suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbellone committed Aug 29, 2014
1 parent 7b9fca6 commit b4b1e1f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Adds support to bind to the IP of a named interface.
(thanks [@romesh-mccullough][5])

Test/Quality Coverage
- Expands test coverage to the `consul::ui` recipe.
- Passes [foodcritic][4] lint testing.
- Only test against rubies of future past.
- Expands test coverage to the `consul::ui` and `consul::_service` recipes.
- Passes some more [rubocop][6] and [foodcritic][4] code quality tests.
- Only test in Travis against rubies of future past.

# 0.4.0
Adds [ChefSpec][3] tests and software lint/metrics.
Expand Down Expand Up @@ -42,3 +42,4 @@ Source and binary installation recipes.
[3]: https://github.com/sethvargo/chefspec
[4]: http://acrmp.github.io/foodcritic/
[5]: https://github.com/romesh-mccullough
[6]: https://github.com/bbatsov/rubocop
2 changes: 1 addition & 1 deletion spec/unit/recipes/_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
context %Q(with node['consul']['init_style'] = 'runit') do
let(:chef_run) do
ChefSpec::Runner.new(node_attributes) do |node|
node.override['consul']['init_style'] = 'runit'
node.set['consul']['init_style'] = 'runit'
end.converge(described_recipe)
end

Expand Down
16 changes: 13 additions & 3 deletions spec/unit/recipes/default_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
require 'spec_helper'

describe_recipe 'consul::default' do
it { expect(chef_run).to include_recipe('consul::install_binary') }
it { expect(chef_run).not_to include_recipe('consul::install_source') }
it { expect(chef_run).to include_recipe('consul::_service') }

context 'with default attributes' do
it { expect(chef_run).to include_recipe('consul::install_binary') }
it { expect(chef_run).not_to include_recipe('consul::install_source') }
end

context %Q(sets node['consul']['install_method'] = 'source') do
let(:chef_run) do
ChefSpec::Runner.new(node_attributes) do |node|
node.override['consul']['install_method'] = 'source'
node.set['consul']['install_method'] = 'source'
end.converge(described_recipe)
end

before do
stub_command("/usr/local/go/bin/go version | grep \"go1.2 \"").and_return(false)
end

it { expect(chef_run).not_to include_recipe('consul::install_binary') }
it { expect(chef_run).to include_recipe('consul::install_binary') }
end
end
6 changes: 5 additions & 1 deletion spec/unit/recipes/install_binary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

describe_recipe 'consul::install_binary' do
it { expect(chef_run).to include_recipe('ark::default') }
it { expect(chef_run).to dump_ark('consul').with(version: '0.3.1', path: '/usr/local/bin') }
it do
expect(chef_run).to dump_ark('consul')
.with(version: '0.3.1')
.with(path: '/usr/local/bin')
end
it { expect(chef_run).to touch_file('/usr/local/bin/consul') }
end
6 changes: 5 additions & 1 deletion spec/unit/recipes/ui_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@

describe_recipe 'consul::ui' do
it { expect(chef_run).to include_recipe('ark::default') }
it { expect(chef_run).to put_ark('consul_ui').with(path: '/var/lib/consul/ui', version: '0.3.1') }
it do
expect(chef_run).to put_ark('consul_ui')
.with(path: '/var/lib/consul/ui')
.with(version: '0.3.1')
end
end

0 comments on commit b4b1e1f

Please sign in to comment.