Sha256: 5998ae3df1fc72fbc4b56f7e37b4b85d31a0ff5a3c443b56063fbe03426cbd6f

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 KB

Contents

require 'spec_helper'

SimpleCov.command_name('Row') unless RUBY_VERSION.to_s < '1.9.0'

describe 'Row, Unit' do

  clazz = CukeModeler::Row

  it_should_behave_like 'a nested element', clazz
  it_should_behave_like 'a bare bones element', clazz
  it_should_behave_like 'a prepopulated element', clazz
  it_should_behave_like 'a sourced element', clazz
  it_should_behave_like 'a raw element', clazz

  it 'can be parsed from stand alone text' do
    source = '| a | row |'

    expect { @element = clazz.new(source) }.to_not raise_error

    # Sanity check in case instantiation failed in a non-explosive manner
    @element.cells.should == ['a', 'row']
  end

  it 'stores the original data generated by the parsing adapter', :gherkin3 => true do
    example_row = clazz.new("| a | row |")
    raw_data = example_row.raw_element

    expect(raw_data.keys).to match_array([:type, :location, :cells])
    expect(raw_data[:type]).to eq('TableRow') # Open bug in the gherkin gem. Should be a symbol like the others.
    # expect(raw_data[:type]).to eq(:TableRow)
  end

  it 'stores the original data generated by the parsing adapter', :gherkin2 => true do
    example_row = clazz.new("| a | row |")
    raw_data = example_row.raw_element

    expect(raw_data.keys).to match_array(['cells', 'line', 'id'])
    expect(raw_data['cells']).to eq(['a', 'row'])
  end


  before(:each) do
    @row = clazz.new
  end

  it 'has cells - #cells' do
    @row.should respond_to(:cells)
  end

  it 'can get and set its cells - #cells, #cells=' do
    @row.cells = :some_cells
    @row.cells.should == :some_cells
    @row.cells = :some_other_cells
    @row.cells.should == :some_other_cells
  end

  it 'starts with no cells' do
    @row.cells.should == []
  end

  context 'row output edge cases' do

    it 'is a String' do
      @row.to_s.should be_a(String)
    end

    it 'can output an empty row' do
      expect { @row.to_s }.to_not raise_error
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cuke_modeler-0.1.0 spec/unit/row_unit_spec.rb