Class: Umami::Test
- Inherits:
-
Object
- Object
- Umami::Test
- Defined in:
- lib/chef-umami/test.rb,
lib/chef-umami/test/unit.rb,
lib/chef-umami/test/integration.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Integration, Unit
Instance Attribute Summary collapse
-
#root_dir ⇒ Object
readonly
Returns the value of attribute root_dir.
Instance Method Summary collapse
-
#framework ⇒ Object
#framework should return a string describing the framework it’s expected to write tests for.
-
#generate ⇒ Object
Performs the necessary steps to generate one or more tests within a test file.
-
#initialize(root_dir) ⇒ Test
constructor
A new instance of Test.
-
#preamble(recipe = '') ⇒ Object
#preamble should return a string (with newlines) that will appear at the top of a test file.
-
#write_test(resource = nil) ⇒ Object
#write_test should write a single, discreet test for a given resource.
Constructor Details
#initialize(root_dir) ⇒ Test
Returns a new instance of Test.
18 19 20 |
# File 'lib/chef-umami/test.rb', line 18 def initialize(root_dir) @root_dir = root_dir end |
Instance Attribute Details
#root_dir ⇒ Object (readonly)
Returns the value of attribute root_dir.
17 18 19 |
# File 'lib/chef-umami/test.rb', line 17 def root_dir @root_dir end |
Instance Method Details
#framework ⇒ Object
#framework should return a string describing the framework it’s expected to write tests for. Examples:
"chefspec"
"serverspec"
"inspec"
30 31 32 |
# File 'lib/chef-umami/test.rb', line 30 def framework raise NoMethodError, "#{self.class} needs to implement the ##{__method__} method! Refer to Umami::Test." end |
#generate ⇒ Object
Performs the necessary steps to generate one or more tests within a test file.
57 58 59 |
# File 'lib/chef-umami/test.rb', line 57 def generate raise NoMethodError, "#{self.class} needs to implement the ##{__method__} method! Refer to Umami::Test." end |
#preamble(recipe = '') ⇒ Object
#preamble should return a string (with newlines) that will appear at the top of a test file. Expects a string representing the recipe name, at least. Example: “# #test_root/#recipe_spec.rbn” \ “n” \ “require ‘##framework’n” \ “n” \ “describe ‘#recipe’ don” \ “ let(:chef_run) { ChefSpec::ServerRunner.converge(described_recipe) }”
44 45 46 |
# File 'lib/chef-umami/test.rb', line 44 def preamble(recipe = '') raise NoMethodError, "#{self.class} needs to implement the ##{__method__} method! Refer to Umami::Test." end |
#write_test(resource = nil) ⇒ Object
#write_test should write a single, discreet test for a given resource. Return as a string with newlines. Expects a Chef::Resource object.
51 52 53 |
# File 'lib/chef-umami/test.rb', line 51 def write_test(resource = nil) raise NoMethodError, "#{self.class} needs to implement the ##{__method__} method! Refer to Umami::Test." end |