Class: RSpec::Parameterized::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/parameterized/table.rb

Defined Under Namespace

Classes: Row

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTable

Returns a new instance of Table.



6
7
8
9
# File 'lib/rspec/parameterized/table.rb', line 6

def initialize
  @rows = []
  @last_row = nil
end

Instance Attribute Details

#last_rowObject (readonly)

Returns the value of attribute last_row.



4
5
6
# File 'lib/rspec/parameterized/table.rb', line 4

def last_row
  @last_row
end

Instance Method Details

#add_param_to_last_row(param) ⇒ Object Also known as: |



19
20
21
22
# File 'lib/rspec/parameterized/table.rb', line 19

def add_param_to_last_row(param)
  last_row.add_param(param)
  self
end

#add_row(row) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/rspec/parameterized/table.rb', line 11

def add_row(row)
  unless @rows.find {|r| r.object_id == row.object_id}
    @rows << row
    @last_row = row
  end
  self
end

#to_aObject Also known as: to_params



25
26
27
# File 'lib/rspec/parameterized/table.rb', line 25

def to_a
  @rows.map(&:to_a)
end