Class: Moto::Test::Metadata
- Inherits:
-
Object
- Object
- Moto::Test::Metadata
- Defined in:
- lib/test/metadata.rb
Overview
Provides tools for accessing metadata embedded in test files
Instance Attribute Summary collapse
-
#test_path ⇒ Object
readonly
Absolute test path.
-
#test_repeat ⇒ Object
Indicates which repetition of the same test is represented by this metadata.
Instance Method Summary collapse
-
#description ⇒ Array
Of [String] which represent contents of #TICKET_URL.
-
#eql?(other) ⇒ Boolean
Overriden eql? so various comparisons, array substractions etc.
-
#initialize(test_path) ⇒ Metadata
constructor
A new instance of Metadata.
-
#tags ⇒ Array<String>
Which represent contents of #MOTO_TAGS.
-
#ticket_urls ⇒ Array
Of [String] which represent contents of #TICKET_URL.
Constructor Details
#initialize(test_path) ⇒ Metadata
Returns a new instance of Metadata.
13 14 15 16 |
# File 'lib/test/metadata.rb', line 13 def initialize(test_path) @test_path = test_path @test_repeat = 1 end |
Instance Attribute Details
#test_path ⇒ Object (readonly)
Absolute test path
7 8 9 |
# File 'lib/test/metadata.rb', line 7 def test_path @test_path end |
#test_repeat ⇒ Object
Indicates which repetition of the same test is represented by this metadata
10 11 12 |
# File 'lib/test/metadata.rb', line 10 def test_repeat @test_repeat end |
Instance Method Details
#description ⇒ Array
Returns of [String] which represent contents of #TICKET_URL.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/test/metadata.rb', line 70 def description if @description.nil? matches = text.scan(/^#(\s*)DESC:(.*?)$/) @description = '' if !matches.empty? matches.each do |match| @description += match[1] + "\n" end end end @description end |
#eql?(other) ⇒ Boolean
Overriden eql? so various comparisons, array substractions etc. can be perfromed on Metadata objects with them being represented by test’s location
89 90 91 92 93 94 95 |
# File 'lib/test/metadata.rb', line 89 def eql?(other) if self.class == other.class return self.test_path == other.test_path end false end |
#tags ⇒ Array<String>
Returns which represent contents of #MOTO_TAGS.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/test/metadata.rb', line 40 def if @tags.nil? matches = text.match(/^#(\s*)MOTO_TAGS:(.*?)$/) if matches @tags = matches.to_a[2].gsub(/\s*/, '').split(',') else @tags = [] end end @tags end |
#ticket_urls ⇒ Array
Returns of [String] which represent contents of #TICKET_URL.
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/test/metadata.rb', line 55 def ticket_urls if @ticket_urls.nil? matches = text.match(/^#(\s*)TICKET_URLS:(.*?)$/) if matches @ticket_urls = matches.to_a[2].gsub(/\s*/, '').split(',') else @ticket_urls = [] end end @ticket_urls end |