Class: Testspace::Rspec::Metadata
- Inherits:
-
Object
- Object
- Testspace::Rspec::Metadata
- Defined in:
- lib/testspace/rspec/metadata.rb
Instance Method Summary collapse
- #description_arg ⇒ Object
- #description_kind ⇒ Object
- #dir ⇒ Object
- #extend_for_description ⇒ Object
-
#initialize(rspec) ⇒ Metadata
constructor
A new instance of Metadata.
- #parent ⇒ Object
- #root ⇒ Object
Constructor Details
#initialize(rspec) ⇒ Metadata
Returns a new instance of Metadata.
7 8 9 10 |
# File 'lib/testspace/rspec/metadata.rb', line 7 def initialize(rspec) @rspec = rspec extend_for_description end |
Instance Method Details
#description_arg ⇒ Object
27 28 29 |
# File 'lib/testspace/rspec/metadata.rb', line 27 def description_arg @description_arg ||= @rspec[:description_args].first end |
#description_kind ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/testspace/rspec/metadata.rb', line 31 def description_kind @description_kind ||= begin case description_arg when ::Module :module when ::NilClass :anonymous else arg = description_arg.to_s if /^#/ =~ arg :instance_method elsif /^\./ =~ arg :class_method else :general end end end end |
#dir ⇒ Object
23 24 25 |
# File 'lib/testspace/rspec/metadata.rb', line 23 def dir @dir ||= parent ? "#{parent.dir}/#{local_dir}" : "#{root_dir}/#{local_dir}" end |
#extend_for_description ⇒ Object
51 52 53 |
# File 'lib/testspace/rspec/metadata.rb', line 51 def extend_for_description extend Extensions::Description.const_get(description_kind.to_s.pascalize, false) end |
#parent ⇒ Object
12 13 14 15 16 17 |
# File 'lib/testspace/rspec/metadata.rb', line 12 def parent @parent ||= begin @rspec[:parent_example_group] && Metadata.new(@rspec[:parent_example_group]) || @rspec.key?(:example_group) && @rspec[:example_group] && Metadata.new(@rspec[:example_group]) end end |
#root ⇒ Object
19 20 21 |
# File 'lib/testspace/rspec/metadata.rb', line 19 def root @root ||= parent ? parent.root : self end |