Sha256: a67db16e1a3324cc9de941bd3e1ce5de4bfdd52c005301a60498875c24448d59

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

require 'jldrill/contexts/ShowStatisticsContext'
require 'Context/Bridge'
require 'jldrill/model/Quiz/Quiz'
require 'jldrill/views/test/MainWindowView'
require 'jldrill/views/test/VocabularyView'
require 'jldrill/views/test/ProblemView'
require 'jldrill/views/test/QuizStatusView'
require 'jldrill/views/test/ItemHintView'

module JLDrill

	describe ShowStatisticsContext do

		before(:each) do
			@main = MainContext.new(Context::Bridge.new(JLDrill::Test))
            @main.inTests = true
			@main.createViews
			@main.quiz = Quiz.new
			@context = @main.showStatisticsContext
			@context.createViews
			@view = @context.mainView
			
    		def @context.createViews
	    	    # Use the previously set View
    		end
		end
		
        it "should be created by the main context" do
            @main.showStatisticsContext.should_not be_nil
        end
        
        it "should have a view" do
            @view.should_not be_nil
        end
        
        it "should not be able to create the context twice at once" do
            @main.mainView.should_receive("addView").exactly(1).times
            @main.showStatistics
            @main.showStatistics
        end
        
        it "should not show statistics if there is no quiz" do
            @main.mainView.should_not_receive(:addView)
            # 3 cases: No parent context, parent doesn't have quiz, parent's quiz is nil
            @context.enter(nil)
            @context.enter(Context::Context.new(mock("ViewBridge")))
            @main.quiz = nil
            @context.enter(@main)
        end
        
        it "should update the view with the parent's quiz statistics on entry" do
            @view.should_receive(:update).with(@main.quiz)
            @context.enter(@main)
        end


	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jldrill-0.5.1.7 spec/jldrill/contexts/ShowStatisticsContext_spec.rb