Sha256: 575d7578dcaf456572ff8a959fd664591d6d94d6a215bd1c3c7f947cd0f22c71

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require 'Context/Spec'
require 'Context/View'

module Context::Spec::ViewStory

	describe Context::View do

		# Since this is an abstract class, we need to override getWidget with
		# something that does something
        def overrideGetWidget(view)
			def view.getWidget
			    @widget
			end
			def view.setWidget(widget)
			    @widget = widget
			end
        end

		before(:each) do
		    @context = mock("Context")
			@view = Context::View.new(@context)
			@widget = mock("Widget")
			
			# Override the getWidget method
			@view.getWidget.should be_nil
			overrideGetWidget(@view)
			@view.setWidget(@widget)
			@view.getWidget.should be(@widget) 
		end
		
		it "should set the context on creation" do
			@view.context.should be(@context)
		end

		it "should use the widgets to add a view" do
		    newView = Context::View.new(@context)
		    overrideGetWidget(newView)
		    newWidget = mock("Widget")
		    newView.setWidget(newWidget)
		    
		    @widget.should_receive(:addToThisWidget).with(newWidget)
		    newWidget.should_receive(:widgetWasAddedTo).with(@widget)
		    @view.addView(newView)
		end

		it "should use the widgets to remove a view" do
		    oldView = Context::View.new(@context)
		    overrideGetWidget(oldView)
		    oldWidget = mock("Widget")
		    oldView.setWidget(oldWidget)
		    
		    @widget.should_receive(:removeFromThisWidget).with(oldWidget)
		    oldWidget.should_receive(:widgetWasRemovedFrom).with(@widget)
		    @view.removeView(oldView)
		end
		
	end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
jldrill-0.5.1.7 spec/Context/View_spec.rb
context-0.0.22 spec/Context/View_spec.rb