Class: Nitrous::TestBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/nitrous/test_block.rb

Instance Method Summary collapse

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

#filenameObject



13
14
15
16
# File 'lib/nitrous/test_block.rb', line 13

def filename
  parse_location
  @filename
end

#first_lineObject



31
32
33
# File 'lib/nitrous/test_block.rb', line 31

def first_line
  "[ #{File.readlines(filename)[line].strip} ]"
end

#lineObject



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

Returns:

  • (Boolean)


23
24
25
# File 'lib/nitrous/test_block.rb', line 23

def skip?
  @skip
end

#to_sObject



27
28
29
# File 'lib/nitrous/test_block.rb', line 27

def to_s
  @name || first_line
end