Sha256: ba0b6fae035e3948a47eacf22cafa8b7847faf6253547edf281aa1d4f8ef3b8e

Contents?: true

Size: 1.81 KB

Versions: 4

Compression:

Stored size: 1.81 KB

Contents

require "assert"

require 'osheet/column'
require 'osheet/row'
require 'osheet/worksheet'

module Osheet

  class WorksheetTests < Assert::Context
    desc "a Worksheet"
    before { @wksht = Worksheet.new }
    subject { @wksht }

    should be_a_meta_element

    should have_instance_methods :name
    should have_instance_methods :columns, :column
    should have_instance_methods :rows, :row

    should "set it's defaults" do
      assert_equal nil, subject.name
      assert_equal [],  subject.columns
      assert_equal [],  subject.rows
    end

  end

  class WorksheetColumnTests < WorksheetTests
    desc "with columns"
    before {
      @col = Column.new
      @wksht.column(@col)
    }

    should "know its cols" do
      assert_equal 1, subject.columns.size
      assert_same @col, subject.columns.first
    end

  end

  class WorksheetRowTests < WorksheetTests
    desc "with rows"
    before {
      @row = Row.new
      @wksht.row(@row)
    }

    should "know its rows" do
      assert_equal 1, subject.rows.size
      assert_same @row, subject.rows.first
    end

    should "only keep the latest row" do
      new_row = Row.new(120)
      subject.row(new_row)

      assert_equal 1, subject.rows.size
      assert_same new_row, subject.rows.last
    end

  end

  class WorksheetNameTests < WorksheetTests
    desc "with a name"
    before do
      @wksht = Worksheet.new("fun")
    end

    should "know it's name" do
      assert_equal "fun", subject.name
    end

    should "set it's name" do
      subject.name(false)
      assert_equal 'false', subject.name
      subject.name('la')
      assert_equal 'la', subject.name
      subject.name(nil)
      assert_equal 'la', subject.name
    end

    should "set it's name with an init parameter" do
      assert_equal "more fun", Worksheet.new("more fun").name
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
osheet-1.0.0.rc.4 test/worksheet_test.rb
osheet-1.0.0.rc.3 test/worksheet_test.rb
osheet-1.0.0.rc.2 test/worksheet_test.rb
osheet-1.0.0.rc.1 test/worksheet_test.rb