require 'Context/Gtk/Widget.rb' module Context::Gtk describe Widget do class FakeWidget include Widget end before(:each) do @widget = FakeWidget.new() @newWidget = FakeWidget.new() @oldWidget = FakeWidget.new() end it "should add and show the widget when add is called." do @widget.should_receive(:gtkAddWidget).with(@newWidget) @widget.should_receive(:show_all) @widget.addToThisWidget(@newWidget) end it "should remove the widget, reshow the container when removed is called." do @widget.should_receive(:gtkRemoveWidget).with(@oldWidget) @widget.should_receive(:show_all) @widget.removeFromThisWidget(@oldWidget) end it "should keep track of the main Window" do @widget.gtkWidgetMainWindow.should be_nil @widget.isAMainWindow @widget.gtkWidgetMainWindow.should be_eql(@widget) @widget.should_receive(:gtkAddWidget).with(@newWidget) @widget.should_receive(:show_all).exactly(2).times @widget.addToThisWidget(@newWidget) @newWidget.gtkWidgetMainWindow.should be_eql(@widget) @widget.should_receive(:gtkRemoveWidget).with(@newWidget) @widget.removeFromThisWidget(@newWidget) @newWidget.gtkWidgetMainWindow.should be_nil end end end