Created
July 9, 2015 14:46
-
-
Save ifosch/af0cf9c5b0b4b225f6a4 to your computer and use it in GitHub Desktop.
Chef library helper test and error
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
# spec/opsworks_spec.rb | |
require_relative '../spec_helper.rb' | |
describe OpsWorks::Helper do | |
describe '#local?' do | |
let(:recipe) { Object.new.extend(OpsWorks::Helper) } | |
before do | |
@run = ChefSpec::Runner.new.converge 'common::default' | |
end | |
context 'without opsworks' do | |
it 'returns true' do | |
expect(recipe.local?).to be true | |
end | |
end | |
end | |
end | |
# libraries/opsworks.rb | |
module OpsWorks | |
module Helper | |
def local? | |
node.key? 'opsworks' | |
end | |
end | |
end | |
# Test output | |
1) OpsWorks::Helper#local? without opsworks returns true | |
Failure/Error: expect(recipe.local?).to be true | |
NameError: | |
undefined local variable or method `node' for #<Object:0x007ff99a8689b8> | |
# ./common/libraries/opsworks.rb:4:in `local?' | |
# ./common/spec/libraries/opsworks_spec.rb:13:in `block (4 levels) in <top (required)>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment