Sha256: 694a8059f03114a481ae901eaf4ae80e5feda323ec9c5536424b4bcb1e07e542
Contents?: true
Size: 1.9 KB
Versions: 4
Compression:
Stored size: 1.9 KB
Contents
require 'test_helper' class MumWidget < MouseWidget; end class MouseTabsWidget;end class WidgetShortcutsTest < Test::Unit::TestCase context "FactoryProxy" do setup do @factory = Apotomo::WidgetShortcuts::FactoryProxy end context "#constant_for" do setup do @dsl = @factory.new(:class, :id) end should "constantize symbols" do assert_equal MouseWidget, @dsl.send(:constant_for, :mouse) end should "not try to singularize the widget class" do assert_equal MouseTabsWidget, @dsl.send(:constant_for, :mouse_tabs) end end context "#widget and #<<" do setup do @root = Apotomo::Widget.new(nil, :root) end context "with all arguments" do should "create a MumWidget instance with options" do proxy = widget(:mum, :mummy, :eating, :color => 'grey', :type => :hungry) @root << proxy assert_kind_of MumWidget, @root[:mummy] assert_equal :mummy, @root[:mummy].name assert_equal({:color => "grey", :type => :hungry}, @root[:mummy].options) end end should "not set options with 2 arguments" do @root << widget(:mum, :mummy) @mum = @root[:mummy] assert_kind_of MumWidget, @mum assert_equal :mummy, @mum.widget_id assert_equal({}, @mum.options) end should "set defaults with prefix, only" do @root << widget(:mum) @mum = @root[:mum] assert_kind_of MumWidget, @mum assert_equal :mum, @mum.name assert_equal({}, @mum.options) end should "yield itself" do ficken = widget(:mum) do |mum| mum << widget(:mouse, :kid) end @root << ficken assert_equal 2, @root[:mum].size assert_kind_of MouseWidget, @root[:mum][:kid] end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
apotomo-1.2.3 | test/widget_shortcuts_test.rb |
apotomo-1.2.2 | test/widget_shortcuts_test.rb |
apotomo-1.2.1 | test/widget_shortcuts_test.rb |
apotomo-1.2.0 | test/widget_shortcuts_test.rb |