Class: ChefSpec::Librarian
- Inherits:
-
Object
- Object
- ChefSpec::Librarian
- Extended by:
- Forwardable
- Includes:
- Singleton
- Defined in:
- lib/chefspec/librarian.rb
Instance Method Summary collapse
-
#initialize ⇒ Librarian
constructor
A new instance of Librarian.
-
#setup! ⇒ Object
Setup and install the necessary dependencies in the temporary directory.
-
#teardown! ⇒ Object
Remove the temporary directory.
Constructor Details
#initialize ⇒ Librarian
Returns a new instance of Librarian.
19 20 21 |
# File 'lib/chefspec/librarian.rb', line 19 def initialize @tmpdir = Dir.mktmpdir end |
Instance Method Details
#setup! ⇒ Object
Setup and install the necessary dependencies in the temporary directory.
26 27 28 29 30 31 32 33 |
# File 'lib/chefspec/librarian.rb', line 26 def setup! env = ::Librarian::Chef::Environment.new(project_path: Dir.pwd) env.config_db.local['path'] = @tmpdir ::Librarian::Action::Resolve.new(env).run ::Librarian::Action::Install.new(env).run ::RSpec.configure { |config| config.cookbook_path = @tmpdir } end |
#teardown! ⇒ Object
Remove the temporary directory.
38 39 40 |
# File 'lib/chefspec/librarian.rb', line 38 def teardown! FileUtils.rm_rf(@tmpdir) if File.exists?(@tmpdir) end |