Skip to content

Commit

Permalink
Fix webui installation spec test
Browse files Browse the repository at this point in the history
Since the ConsulInstallationWebui provider relies on non-core chef resources, we can't use an inline recipe.

```
1) ConsulCookbook::Provider::ConsulInstallationWebui webui installation
 Failure/Error:
   it do is_expected.to unzip_zipfile('consul_0.6.4_web_ui.zip')
     .with(source: 'https://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_web_ui.zip',
           path: '/opt/consul-webui/0.6.4')
   end

 NoMethodError:
   consul_installation[0.6.4] (/Users/user/github/chef-consul/test/spec/libraries/consul_installation_webui_spec.rb line 12) had an error: NoMethodError: No resource or method named `zipfile' for `ConsulCookbook::Provider::ConsulInstallationWebui ""'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/dsl/recipe.rb:102:in `rescue in method_missing'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/dsl/recipe.rb:99:in `method_missing'
 # ./libraries/consul_installation_webui.rb:50:in `block in action_create'
 # ./libraries/consul_installation_webui.rb:45:in `action_create'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/provider.rb:144:in `run_action'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/resource.rb:596:in `run_action'
 # ./.bundle/ruby/2.2.0/gems/chefspec-4.6.0/lib/chefspec/extensions/chef/resource.rb:22:in `run_action'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/runner.rb:73:in `run_action'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/runner.rb:105:in `block (2 levels) in converge'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/runner.rb:105:in `each'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/runner.rb:105:in `block in converge'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/resource_collection/resource_list.rb:84:in `block in execute_each_resource'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/resource_collection/resource_list.rb:82:in `execute_each_resource'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/runner.rb:104:in `converge'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/client.rb:668:in `block in converge'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/client.rb:663:in `catch'
 # ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/client.rb:663:in `converge'
 # ./.bundle/ruby/2.2.0/gems/chefspec-4.6.0/lib/chefspec/solo_runner.rb:126:in `converge'
 # ./test/spec/libraries/consul_installation_webui_spec.rb:17:in `block (3 levels) in <top (required)>'
 # ------------------
 # --- Caused by: ---
 # NoMethodError:
 #   undefined method `zipfile' for #<ConsulCookbook::Provider::ConsulInstallationWebui:0x007fc246a8ee80>
 #   ./.bundle/ruby/2.2.0/gems/chef-12.8.1/lib/chef/dsl/recipe.rb:100:in `method_missing'
```
  • Loading branch information
shortdudey123 committed Apr 16, 2016
1 parent 6579f25 commit 547d139
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
consul_installation '0.6.4' do
provider :webui
end
17 changes: 11 additions & 6 deletions test/spec/libraries/consul_installation_webui_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@
let(:chefspec_options) { {platform: 'ubuntu', version: '14.04'} }

context 'webui installation' do
recipe do
consul_installation '0.6.4' do
provider :webui
end
recipe 'consul_spec::consul_installation_webui'

it do is_expected.to create_directory('/opt/consul-webui/0.6.4')
.with(
recursive: true
)
end

it do is_expected.to unzip_zipfile('consul_0.6.4_web_ui.zip')
.with(source: 'https://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_web_ui.zip',
path: '/opt/consul-webui/0.6.4')
.with(
checksum: '5f8841b51e0e3e2eb1f1dc66a47310ae42b0448e77df14c83bb49e0e0d5fa4b7',
path: '/opt/consul-webui/0.6.4',
source: 'https://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_web_ui.zip'
)
end
end
end

0 comments on commit 547d139

Please sign in to comment.