Example of mocking out a library in Chef so you can test the provider in isolation.
If you want to test the library itself you can do more normal Ruby things.
require 'nokogiri' | |
xml = %q{ | |
<foo> | |
<foo/> | |
</foo> | |
} | |
doc = Nokogiri::XML.parse(xml) | |
puts doc.xpath('//foo[bool_function(bar/baz)]', Class.new { |
require 'minitest/spec' | |
module MiniTest::Chef::Resources | |
include Chef::Mixin::ConvertToClassName | |
def self.register_resource(resource) | |
define_method(resource) do |name| | |
clazz = Chef::Resource.const_get(convert_to_class_name(resource.to_s)) | |
res = clazz.new(name, run_context) |
project_name: example-tmux-guard | |
project_root: . | |
rvm: 1.9.3@example-project | |
tabs: | |
- 'minitest-chef-example': | |
layout: 3937,104x35,0,0[104x27,0,0{52x27,0,0,51x27,53,0},104x7,0,28] | |
panes: | |
- vim example-project/cookbooks/example/files/default/tests/minitest/default_test.rb | |
- vim example-project/cookbooks/example/recipes/default.rb | |
- 'cd example-project && bundle exec guard' |
Chef::Log.info node[:kernel][:machine] | |
Chef::Log.info node[:kernel][:machine] | |
Chef::Log.info node.kernel.machine |
require "chefspec" | |
require 'mixlib/shellout' | |
require "ostruct" | |
require ::File.join ::File.dirname(__FILE__), "..", "files", "default", "reboot" | |
describe Reboot do | |
::Chef::ShellOut.class_eval do | |
def run_command | |
true | |
end |
Example of mocking out a library in Chef so you can test the provider in isolation.
If you want to test the library itself you can do more normal Ruby things.
# Use vi keybindings in copy and choice modes | |
setw -g mode-keys vi | |
# Vim-style copy/paste | |
unbind [ | |
bind ` copy-mode | |
unbind p | |
bind p paste-buffer | |
bind -t vi-copy H start-of-line | |
bind -t vi-copy L end-of-line |