Sha256: 7f1fd7606b63ff9c525a3dfff7d0e2be1aabf10bc8152e907edc415195207252

Contents?: true

Size: 1.69 KB

Versions: 20

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'
require 'models/active_record/api.rb'

describe "reading the current state" do
  it "uses the AASM default" do
    expect(DefaultState.new.aasm.current_state).to eql :alpha
  end

  it "uses the provided method" do
    expect(ProvidedState.new.aasm.current_state).to eql :beta
  end

  it "uses the persistence storage" do
    expect(PersistedState.new.aasm.current_state).to eql :alpha
  end

  it "uses the provided method even if persisted" do
    expect(ProvidedAndPersistedState.new.aasm.current_state).to eql :gamma
  end
end

describe "writing and persisting the current state" do
  it "uses the AASM default" do
    o = DefaultState.new
    o.release!
    expect(o.persisted_store).to be_nil
  end

  it "uses the provided method" do
    o = ProvidedState.new
    o.release!
    expect(o.persisted_store).to eql :beta
  end

  it "uses the persistence storage" do
    o = PersistedState.new
    o.release!
    expect(o.persisted_store).to be_nil
  end

  it "uses the provided method even if persisted" do
    o = ProvidedAndPersistedState.new
    o.release!
    expect(o.persisted_store).to eql :beta
  end
end

describe "writing the current state without persisting it" do
  it "uses the AASM default" do
    o = DefaultState.new
    o.release
    expect(o.transient_store).to be_nil
  end

  it "uses the provided method" do
    o = ProvidedState.new
    o.release
    expect(o.transient_store).to eql :beta
  end

  it "uses the persistence storage" do
    o = PersistedState.new
    o.release
    expect(o.transient_store).to be_nil
  end

  it "uses the provided method even if persisted" do
    o = ProvidedAndPersistedState.new
    o.release
    expect(o.transient_store).to eql :beta
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
aasm-4.1.1 spec/unit/api_spec.rb
aasm-4.1.0 spec/unit/api_spec.rb
aasm-4.0.8 spec/unit/api_spec.rb
aasm-4.0.7 spec/unit/api_spec.rb
aasm-4.0.6 spec/unit/api_spec.rb
aasm-4.0.5 spec/unit/api_spec.rb
aasm-4.0.4 spec/unit/api_spec.rb
aasm-4.0.3 spec/unit/api_spec.rb
aasm-4.0.2 spec/unit/api_spec.rb
aasm-4.0.1 spec/unit/api_spec.rb
aasm-4.0.0 spec/unit/api_spec.rb
aasm-3.4.0 spec/unit/api_spec.rb
aasm-3.3.3 spec/unit/api_spec.rb
aasm-3.3.2 spec/unit/api_spec.rb
aasm-3.3.1 spec/unit/api_spec.rb
aasm-3.3.0 spec/unit/api_spec.rb
aasm-3.2.1 spec/unit/api_spec.rb
aasm-3.2.0 spec/unit/api_spec.rb
aasm-3.1.1 spec/unit/api_spec.rb
aasm-3.1.0 spec/unit/api_spec.rb