Sha256: 2e60ed471698826f22f118d96c798399ea15390a3dcab3704f365f436708192d

Contents?: true

Size: 870 Bytes

Versions: 2

Compression:

Stored size: 870 Bytes

Contents

require 'spec_helper'

module WebsocketRails
  describe DataStore do
    let(:attribute) {"example_attribute"}
    let(:value)     {1}

    before(:each) do
      @base = double('base_controller')
      @base.stub(:client_id).and_return(1)
      @data_store = DataStore.new(@base)
    end
    
    it "loads up" do
      @data_store.present?.should be_true
    end

    describe "#[]" do
      context "with an undefined attribute" do
        it "returns nil" do
          @data_store[attribute].should be_nil
        end
      end

      context "with a defined attribute" do
        it "returns its value" do
          @data_store[attribute] = value
          @data_store[attribute].should == value
        end
      end
    end

    describe "#[]=" do
      it "returns the value" do
        (@data_store[attribute]=value).should == value
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
websocket-rails-0.3.0 spec/unit/data_store_spec.rb
websocket-rails-0.2.1 spec/unit/data_store_spec.rb