Skip to content

Instantly share code, notes, and snippets.

@petecheslock
Last active December 20, 2015 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petecheslock/999de67d5620e811a20c to your computer and use it in GitHub Desktop.
Save petecheslock/999de67d5620e811a20c to your computer and use it in GitHub Desktop.
chefspec | (cd recipe && bundle exec rspec --color --format documentation)
chefspec | recipe::default
chefspec | creates file
chefspec | has proper modes
chefspec | should include correct content
chefspec | Failures:
chefspec | 1) recipe::default should include correct content
chefspec | Failure/Error: @chef_run.should create_file_with_content @file,
chefspec | NameError:
chefspec | undefined local variable or method `node' for #<Erubis::Context:0x007fccc30b9bf8>
chefspec | # (erubis):3:in `block in evaluate'
chefspec | # ./spec/default_spec.rb:20:in `block (2 levels) in <top (required)>'
chefspec | Finished in 0.02112 seconds
chefspec | 3 examples, 1 failure
chefspec | Failed examples:
chefspec | rspec ./spec/default_spec.rb:19 # recipe::default should include correct key
chefspec | Terminated with a non-zero exit status. Strainer assumes this is a failure.
chefspec | FAILURE!
template node["foo"]["bar"] do
source "script.sh.erb"
mode 00775
end
require 'spec_helper'
describe 'recipe::default' do
before do
@file = '/path/to/my/file'
@chef_run = ChefSpec::ChefRunner.new(platform: 'ubuntu', version: '12.04').converge('recipe::default')
end
it 'creates file' do
@chef_run.template create_file(@file)
end
it 'has proper modes' do
m = @chef_run.template(@file).mode
sprintf("%o", m).should == "775"
end
it 'should include correct content' do
@chef_run.should create_file_with_content @file,
"stuff_that_should_be_in_file"
end
end
Static content in my file
Below is something driven by a node attribute
<%= node["foo"]["bar"]["baz"] %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment