Sha256: 4ce808c0d1ae0103f284ff754fe133210137cd271e33ea09f7b06eb7e02b440b

Contents?: true

Size: 1.4 KB

Versions: 11

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

describe TablePrint::Printable do
  before(:each) do
    Sandbox.cleanup!
  end

  describe "#default_display_methods" do
    it "returns attribute getters" do
      Sandbox.add_class("Hat")
      Sandbox.add_attributes("Hat", "brand")

      p = Sandbox::Hat.new
      TablePrint::Printable.default_display_methods(p).should == %W(brand)
    end

    it "ignores dangerous methods" do
      Sandbox.add_class("Hat")
      Sandbox.add_method("Hat", "brand!") {}

      p = Sandbox::Hat.new
      TablePrint::Printable.default_display_methods(p).should == []
    end

    it "ignores methods defined in a superclass" do
      Sandbox.add_class("Hat::Bowler")
      Sandbox.add_attributes("Hat", "brand")
      Sandbox.add_attributes("Hat::Bowler", "brim_width")

      p = Sandbox::Hat::Bowler.new
      TablePrint::Printable.default_display_methods(p).should == %W(brim_width)
    end

    it "ignores methods that require arguments" do
      Sandbox.add_class("Hat")
      Sandbox.add_attributes("Hat", "brand")
      Sandbox.add_method("Hat", "tip?") { |person| person.rapscallion? }

      p = Sandbox::Hat.new
      TablePrint::Printable.default_display_methods(p).should == %W(brand)
    end

    it "ignores methods from an included module" do
      pending "waiting for Cat to support module manipulation"
    end

    it "uses column information when available (eg, from ActiveRecord objects)"
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
table_print-1.3.3 spec/printable_spec.rb
table_print-1.3.2 spec/printable_spec.rb
table_print-1.3.1 spec/printable_spec.rb
table_print-1.3.0 spec/printable_spec.rb
table_print-1.2.0 spec/printable_spec.rb
table_print-1.1.5 spec/printable_spec.rb
table_print-1.1.4 spec/printable_spec.rb
table_print-1.1.3 spec/printable_spec.rb
table_print-1.1.2 spec/printable_spec.rb
table_print-1.1.1 spec/printable_spec.rb
table_print-1.1.0 spec/printable_spec.rb