Module: Dockerspec::Helper::RSpecExampleHelpers
- Defined in:
- lib/dockerspec/helper/rspec_example_helpers.rb
Overview
Some Helper methods to work with RSpec Examples.
Class Method Summary collapse
-
.metadata_has_parent?(metadata) ⇒ Boolean
private
Checks if the parent RSpec example information exists in the metadata.
-
.metadata_parent(metadata) ⇒ Hash
private
Get the parent RSpec example metadata if available.
-
.restore_rspec_context(metadata) ⇒ Object
Restores the Docker running container instance in the Specinfra internal reference.
-
.search_objects_with(metadata, meth) ⇒ Array<Object>
Searches for an object in the description of the parent RSpec examples that implements a specific method.
Class Method Details
.metadata_has_parent?(metadata) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Checks if the parent RSpec example information exists in the metadata.
35 36 37 |
# File 'lib/dockerspec/helper/rspec_example_helpers.rb', line 35 def self.() .key?(:parent_example_group) || .key?(:example_group) end |
.metadata_parent(metadata) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get the parent RSpec example metadata if available.
48 49 50 51 52 53 54 |
# File 'lib/dockerspec/helper/rspec_example_helpers.rb', line 48 def self.() if .key?(:parent_example_group) [:parent_example_group] elsif .key?(:example_group) [:example_group] end end |
.restore_rspec_context(metadata) ⇒ Object
Restores the Docker running container instance in the Specinfra internal reference.
Gets the correct Runner::Base reference from the RSpec metadata.
100 101 102 103 104 105 |
# File 'lib/dockerspec/helper/rspec_example_helpers.rb', line 100 def self.restore_rspec_context() o_ary = Helper::RSpecExampleHelpers .search_objects_with(, :restore_rspec_context) o_ary.each(&:restore_rspec_context) end |
.search_objects_with(metadata, meth) ⇒ Array<Object>
Searches for an object in the description of the parent RSpec examples that implements a specific method.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/dockerspec/helper/rspec_example_helpers.rb', line 67 def self.search_objects_with(, meth) o_ary = [] return o_ary if .nil? if [:described_class].respond_to?(meth) && [:described_class] != self o_ary << [:described_class] end return o_ary unless () (search_objects_with((), meth) + o_ary).uniq end |