Sha256: f3732923ca4a659a797f55b9fd1af8592dbe2f79bff6b80383dd3ed456b32611

Contents?: true

Size: 1.55 KB

Versions: 17

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'

if defined?(Redis::Objects)
  describe 'redis' do

    Dir[File.dirname(__FILE__) + "/../../models/redis/*.rb"].sort.each do |f|
      require File.expand_path(f)
    end

    before(:all) do
      @model = RedisSimple
    end

    describe "instance methods" do
      let(:model) {@model.new}

      it "should respond to aasm persistence methods" do
        expect(model).to respond_to(:aasm_read_state)
        expect(model).to respond_to(:aasm_write_state)
        expect(model).to respond_to(:aasm_write_state_without_persistence)
      end

      it "should return the initial state when new and the aasm field is nil" do
        expect(model.aasm.current_state).to eq(:alpha)
      end

      it "should return the aasm column when new and the aasm field is not nil" do
        model.status = "beta"
        expect(model.aasm.current_state).to eq(:beta)
      end

      it "should allow a nil state" do
        model.status = nil
        expect(model.aasm.current_state).to be_nil
        end
    end

    describe 'subclasses' do
      it "should have the same states as its parent class" do
        expect(Class.new(@model).aasm.states).to eq(@model.aasm.states)
      end

      it "should have the same events as its parent class" do
        expect(Class.new(@model).aasm.events).to eq(@model.aasm.events)
      end

      it "should have the same column as its parent even for the new dsl" do
        expect(@model.aasm.attribute_name).to eq(:status)
        expect(Class.new(@model).aasm.attribute_name).to eq(:status)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
aasm-5.3.1 spec/unit/persistence/redis_persistence_spec.rb
aasm-5.3.0 spec/unit/persistence/redis_persistence_spec.rb
aasm-5.2.0 spec/unit/persistence/redis_persistence_spec.rb
aasm-5.1.1 spec/unit/persistence/redis_persistence_spec.rb
aasm-5.1.0 spec/unit/persistence/redis_persistence_spec.rb
aasm-5.0.8 spec/unit/persistence/redis_persistence_spec.rb
aasm-5.0.7 spec/unit/persistence/redis_persistence_spec.rb
aasm-5.0.6 spec/unit/persistence/redis_persistence_spec.rb
aasm-5.0.5 spec/unit/persistence/redis_persistence_spec.rb
aasm-5.0.4 spec/unit/persistence/redis_persistence_spec.rb
aasm-5.0.3 spec/unit/persistence/redis_persistence_spec.rb
aasm-5.0.2 spec/unit/persistence/redis_persistence_spec.rb
aasm-5.0.1 spec/unit/persistence/redis_persistence_spec.rb
aasm-5.0.0 spec/unit/persistence/redis_persistence_spec.rb
aasm-4.12.3 spec/unit/persistence/redis_persistence_spec.rb
aasm-4.12.2 spec/unit/persistence/redis_persistence_spec.rb
aasm-4.12.1 spec/unit/persistence/redis_persistence_spec.rb