Class: Nitrous::TestBlock
- Inherits:
-
Object
- Object
- Nitrous::TestBlock
- Defined in:
- lib/nitrous/test_block.rb
Instance Method Summary collapse
- #filename ⇒ Object
- #first_line ⇒ Object
-
#initialize(name, block, skip = false) ⇒ TestBlock
constructor
A new instance of TestBlock.
- #line ⇒ Object
- #run(test) ⇒ Object
- #skip? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(name, block, skip = false) ⇒ TestBlock
Returns a new instance of TestBlock.
3 4 5 |
# File 'lib/nitrous/test_block.rb', line 3 def initialize(name, block, skip=false) @name, @block, @skip = name, block, skip end |
Instance Method Details
#filename ⇒ Object
13 14 15 16 |
# File 'lib/nitrous/test_block.rb', line 13 def filename parse_location @filename end |
#first_line ⇒ Object
31 32 33 |
# File 'lib/nitrous/test_block.rb', line 31 def first_line "[ #{File.readlines(filename)[line].strip} ]" end |
#line ⇒ Object
18 19 20 21 |
# File 'lib/nitrous/test_block.rb', line 18 def line parse_location @line end |
#run(test) ⇒ Object
7 8 9 10 11 |
# File 'lib/nitrous/test_block.rb', line 7 def run(test) test.collect_errors do test.instance_eval(&@block) unless self.skip? end end |
#skip? ⇒ Boolean
23 24 25 |
# File 'lib/nitrous/test_block.rb', line 23 def skip? @skip end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/nitrous/test_block.rb', line 27 def to_s @name || first_line end |