Sha256: 1462c7d27db2606e1daa9a6223c6b0e0b45fb9589fa9d91ecf687e2970792738
Contents?: true
Size: 1.82 KB
Versions: 1
Compression:
Stored size: 1.82 KB
Contents
require "spec_helper" module WebsocketRails describe ControllerFactory do class TestController < BaseController attr_reader :_dispatcher, :_event def initialize_session true end end let(:dispatcher) { double('dispatcher') } let(:connection) { double('connection') } let(:event) { double('event') } subject { ControllerFactory.new(dispatcher) } before do connection.stub(:id).and_return(1) event.stub(:connection).and_return(connection) end it "stores a reference to the dispatcher" do subject.dispatcher.should == dispatcher end it "maintains a hash of controller data stores" do subject.controller_stores.should be_a Hash end describe "#new_for_event" do it "creates and returns a new controller instance" do controller = subject.new_for_event(event, TestController) controller.class.should == TestController end it "initializes the controller with the correct data_store" do store = double('data_store') subject.controller_stores[TestController] = store controller = subject.new_for_event(event, TestController) controller.controller_store.should == store end it "initializes the controller with the correct event" do controller = subject.new_for_event(event, TestController) controller.event.should == event end it "initializes the controller with the correct dispatcher" do controller = subject.new_for_event(event, TestController) controller._dispatcher.should == dispatcher end it "calls #initialize_session on the controller only once" do TestController.any_instance.should_receive(:initialize_session).once 3.times { subject.new_for_event(event, TestController) } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
websocket-rails-0.4.0 | spec/unit/controller_factory_spec.rb |