require 'Context/Gtk/Widget.rb' module Context::Gtk describe Widget do before(:each) do @widget = Context::Gtk::Widget.new(mock("Gtk::Widget")) @newWidget = Context::Gtk::Widget.new(mock("Gtk::Widget")) @oldWidget = Context::Gtk::Widget.new(mock("Gtk::Widget")) end it "should add and show the widget when add is called." do @widget.delegate.should_receive(:add).with(@newWidget.delegate) @widget.delegate.should_receive(:show_all) @widget.add(@newWidget) end it "should remove the widget, reshow the container and grab focus when removed is called." do @widget.delegate.should_receive(:remove).with(@oldWidget.delegate) @widget.delegate.should_receive(:show_all) @widget.delegate.should_receive(:grab_focus) @widget.remove(@oldWidget) end it "should keep track of the main Window" do @widget.mainWindow.should be_nil @widget.isAMainWindow @widget.mainWindow.should be_eql(@widget.delegate) @widget.delegate.should_receive(:add).with(@newWidget.delegate) @widget.delegate.should_receive(:show_all).exactly(2).times @widget.add(@newWidget) @newWidget.mainWindow.should be_eql(@widget.delegate) @widget.delegate.should_receive(:remove).with(@newWidget.delegate) @widget.delegate.should_receive(:grab_focus) @widget.remove(@newWidget) @newWidget.mainWindow.should be_nil end end end