Sha256: 84fa17898ca54a4c74a1c6b58b1054c2b44c9e7c57f080c349658dd3c0e7c820

Contents?: true

Size: 1.07 KB

Versions: 9

Compression:

Stored size: 1.07 KB

Contents

require_relative '../../helper'

Tk.init

describe Tk::Tile::Button do
  Style = Tk::Tile::Style
  Button = Tk::Tile::Button

  it 'sets default to normal, active, or disabled' do
    button = Button.new('.')
    button.cget(:default).should == 'normal'

    %w{normal active disabled}.each do |state|
      button = Button.new('.', default: state )
      button.cget(:default).should == state
    end

    lambda {
      Button.new('.', default: 'unkown-')
    }.should.raise RuntimeError
  end

  it 'sets width and height' do
    button = Button.new('.')
    button.cget(:width).should == 0

    [10, -10, 10.0, -10.0].each do |i|
      button = Button.new('.', width: i.to_i)
      button.cget(:width).should == i.to_i

      button = Button.new('.', width: i.to_f)
      button.cget(:width).should == 0
    end
  end

  # behaves_like Tk::Button -command
  it 'handles -command' do
    ran = false
    Tk.callbacks.size.should == 0

    button = Button.new('.'){
      ran = true
      button.destroy
    }
    button.invoke

    Tk.callbacks.size.should == 0
    ran.should == true
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ffi-tk-2010.08.23 spec/ffi-tk/tile/button.rb
ffi-tk-2010.08 spec/ffi-tk/tile/button.rb
ffi-tk-2010.06 spec/ffi-tk/tile/button.rb
ffi-tk-2010.03 spec/ffi-tk/tile/button.rb
ffi-tk-2010.02 spec/ffi-tk/tile/button.rb
ffi-tk-2010.01 spec/ffi-tk/tile/button.rb
ffi-tk-2010.01.02 spec/ffi-tk/tile/button.rb
ffi-tk-2009.12.14 spec/ffi-tk/tile/button.rb
ffi-tk-2009.11.29 spec/ffi-tk/tile/button.rb