Sha256: 1215b1520699684b3ea0fd3e001027f8f22e35200dc32bd3ef95b3a7c16c2c4b

Contents?: true

Size: 1.58 KB

Versions: 8

Compression:

Stored size: 1.58 KB

Contents

require 'test_helper'

class StatefulWidgetTest < Test::Unit::TestCase
  include Apotomo::TestCaseMethods::TestController
  
  context "The StatefulWidget" do
    setup do
      @mum = Apotomo::StatefulWidget.new(parent_controller, 'mum', :squeak)
    end
    
    should "accept an id as first option" do
      assert_equal 'mum', @mum.name
    end
    
    should "accept a start state as second option" do
      assert_equal :squeak, @mum.instance_variable_get('@start_state')
    end
    
    should "respond to #version" do
      assert_equal 0, mouse_mock.version
    end
    
    should "have a version setter" do
      @mum = mouse_mock
      @mum.version = 1
      assert_equal 1, @mum.version
    end
  end
  
  context "mum having a family" do
    setup do
      mum_and_kid!
      @mum << @berry = mouse_mock('berry')
        @berry << @pet = mouse_mock('pet')
    end
    
    context "responding to #render_children" do
      should "return an OrderedHash for the rendered kids" do
        kids = @mum.render_children
        assert_kind_of ::ActiveSupport::OrderedHash, kids
        assert_equal 2, kids.size
      end
      
      should "return an OrderedHash even if there are no kids" do
        kids = @kid.render_children
        assert_kind_of ::ActiveSupport::OrderedHash, kids
        assert_equal 0, kids.size
      end
      
      should "return an empty OrderedHash when all kids are invisible" do
        @pet.visible = false
        kids = @berry.render_children
        assert_kind_of ::ActiveSupport::OrderedHash, kids
        assert_equal 0, kids.size
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
apotomo-1.0.5 test/unit/stateful_widget_test.rb
apotomo-1.0.4 test/unit/stateful_widget_test.rb
apotomo-1.0.3 test/unit/stateful_widget_test.rb
apotomo-1.0.2 test/unit/stateful_widget_test.rb
apotomo-1.0.1 test/unit/stateful_widget_test.rb
apotomo-1.0.0 test/unit/stateful_widget_test.rb
apotomo-1.0.0.beta2 test/unit/stateful_widget_test.rb
apotomo-1.0.0.beta1 test/unit/stateful_widget_test.rb