Sha256: 1cbcc69e3bae9811a94d609c248d16b8dc5f6e29cf76ef434f67ad57d1557758

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

require "assert"
require "osheet/column"

require 'osheet/format/general'

class Osheet::Column

  class UnitTests < Assert::Context
    desc "Osheet::Column"
    before{ @c = Osheet::Column.new }
    subject{ @c }

    should be_a_styled_element
    should be_a_meta_element

    should have_reader :format
    should have_instance_methods :width
    should have_instance_methods :autofit, :autofit?
    should have_instance_methods :hidden, :hidden?

    should "set it's defaults" do
      assert_equal nil, subject.width
      assert_equal false, subject.autofit
      assert !subject.autofit?
      assert_equal false, subject.hidden
      assert !subject.hidden?
      assert_kind_of Osheet::Format::General, subject.format
    end

    should "set it's width" do
      subject.width(false)
      assert_equal false, subject.width

      subject.width(180)
      assert_equal 180, subject.width

      subject.width(nil)
      assert_equal 180, subject.width

      assert_equal 200, Osheet::Column.new(200).width
    end

    should "cast autofit and hidden to bool" do
      col = Osheet::Column.new
      col.autofit :true
      col.hidden 'false'

      assert_equal true, col.autofit
      assert_equal true, col.hidden
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
osheet-1.1.1 test/unit/column_tests.rb
osheet-1.1.0 test/unit/column_tests.rb
osheet-1.0.0 test/unit/column_tests.rb