Last active
December 23, 2015 02:09
-
-
Save jblaine/6565513 to your computer and use it in GitHub Desktop.
ChefSpec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# line-cookbook/recipes/_tester.rb | |
file "0" do | |
path "/tmp/.line-cookbook-testfile" | |
content "An opening line" | |
owner 'root' | |
group 'root' | |
mode '00644' | |
end | |
----------------------------------------------------------------------------------------------- | |
# line-cookbook/spec/tester_spec.rb | |
require 'chefspec' | |
describe 'line-cookbook::_tester' do | |
chef_run = ChefSpec::ChefRunner.new(platform:'ubuntu', version:'12.04') | |
chef_run.converge('line-cookbook::_tester') | |
# | |
# This syntax gives the same error shown below in this gist. | |
# let(:chef_run) { ChefSpec::ChefRunner.new(platform:'ubuntu', version:'12.04').converge('line-cookbook::_tester') } | |
it "creates /tmp/.line-cookbook-testfile with certain content" do | |
expect(chef_run).to create_file_with_content '/tmp/.line-cookbook-testfile', 'An opening line' | |
end | |
end | |
----------------------------------------------------------------------------------------------- | |
Failures: | |
1) line-cookbook::_tester creates /tmp/.line-cookbook-testfile with certain content | |
Failure/Error: expect(chef_run).to create_file_with_content testerfile, 'An opening line' | |
File content: | |
does not match expected: | |
An opening line | |
# ./spec/tester_spec.rb:12:in `block (2 levels) in <top (required)>' | |
Finished in 0.00098 seconds | |
1 example, 1 failure | |
Failed examples: | |
rspec ./spec/tester_spec.rb:10 # line-cookbook::_tester creates /tmp/.line-cookbook-testfile with certain content | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment