Skip to content

Instantly share code, notes, and snippets.

@UshF
Created October 29, 2013 18:18
Show Gist options
  • Save UshF/7219872 to your computer and use it in GitHub Desktop.
Save UshF/7219872 to your computer and use it in GitHub Desktop.
chefspec failure with sync_git
There should be a matcher following the pattern ACTION_RESOURCE(NAME) for sync_git(repo)
http://rubydoc.info/github/acrmp/chefspec/ChefSpec/API/GitMatchers:sync_git
I'm trying to run rspec for the following recipe
case node["swift"]["swauth-source"]
when "package"
package platform_options["swauth_packages"] do
action :install
only_if { node["swift"]["authmode"] == "swauth" }
end
when "git"
git "#{Chef::Config[:file_cache_path]}/swauth" do
repository node["swift"]["swauth_repository"]
revision node["swift"]["swauth_version"]
action :sync
only_if { node["swift"]["authmode"] == "swauth" }
end
bash "install_swauth" do
cwd "#{Chef::Config[:file_cache_path]}/swauth"
user "root"
group "root"
code <<-EOH
python setup.py install
EOH
environment 'PREFIX' => "/usr/local"
only_if { node["swift"]["authmode"] == "swauth" }
end
end
here's the spec
it "installs swauth from git if swauth is selected" do
@node.set['swift']['swauth-source'] = 'git'
expect(@chef_run).to sync_git("#{Chef::Config[:file_cache_path]}/swauth").with(repository: "https://github.com/gholt/swauth.git")
expect(@chef_run).to run_bash "install_swauth"
end
Here's the error
chefspec | 1) openstack-object-storage::proxy-server ubuntu installs swauth from git if swauth is selected
chefspec | Failure/Error: expect(@chef_run).to sync_git("#{Chef::Config[:file_cache_path]}/swauth").with(repository: "https://github.com/gholt/swauth.git")
chefspec | NoMethodError:
chefspec | undefined method `sync_git' for #<RSpec::Core::ExampleGroup::Nested_7::Nested_1:0x000000058c9bc8>
chefspec | # ./spec/proxy_spec.rb:39:in `block (3 levels) in <top (required)>'
chefspec | Finished in 8.87 seconds
chefspec | 52 examples, 1 failure, 11 pending
chefspec | Failed examples:
chefspec | rspec ./spec/proxy_spec.rb:37 # openstack-object-storage::proxy-server ubuntu installs swauth from git if swauth is selected
chefspec | Terminated with a non-zero exit status. Strainer assumes this is a failure.
chefspec | FAILURE!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment