Class: VagrantSpec::SpecHelper
- Inherits:
-
Object
- Object
- VagrantSpec::SpecHelper
- Includes:
- Utils
- Defined in:
- lib/vagrant_spec/spec_helper.rb
Overview
Generates a spec_helper.rb for integration testing
env [Vagrant::Environment]
Instance Method Summary collapse
-
#create_directory ⇒ Object
return [String].
-
#generate ⇒ Object
Generate the spec_helper.rb.
-
#initialize(env) ⇒ SpecHelper
constructor
A new instance of SpecHelper.
-
#spec_helper_path ⇒ Object
return [String].
-
#spec_helper_template ⇒ Object
return [String].
Methods included from Utils
#lib_root, #project_root, #template_dir
Constructor Details
#initialize(env) ⇒ SpecHelper
14 15 16 17 |
# File 'lib/vagrant_spec/spec_helper.rb', line 14 def initialize(env) @env = env @directory = VagrantSpec::Config.load(env).spec.directory end |
Instance Method Details
#create_directory ⇒ Object
return [String]
28 29 30 |
# File 'lib/vagrant_spec/spec_helper.rb', line 28 def create_directory Dir.mkdir @directory unless Dir.exist? @directory end |
#generate ⇒ Object
Generate the spec_helper.rb
20 21 22 23 24 25 |
# File 'lib/vagrant_spec/spec_helper.rb', line 20 def generate create_directory return if File.exist? spec_helper_path sh = ERB.new(IO.read(spec_helper_template), 0, '<>').result binding IO.write(spec_helper_path, sh) end |
#spec_helper_path ⇒ Object
return [String]
33 34 35 |
# File 'lib/vagrant_spec/spec_helper.rb', line 33 def spec_helper_path File.join(@directory, 'spec_helper.rb') end |
#spec_helper_template ⇒ Object
return [String]
38 39 40 |
# File 'lib/vagrant_spec/spec_helper.rb', line 38 def spec_helper_template File.join(template_dir, 'spec_helper.erb') end |