Sha256: c304b7f96b8b0dcbcd68820bfee8cc58bc6fb068c6f4d967abe62bde6c1aa1c7

Contents?: true

Size: 816 Bytes

Versions: 14

Compression:

Stored size: 816 Bytes

Contents

require 'spec_helper'
require 'volt/reactive/reactive_accessors'

class TestReactiveAccessors
  include ReactiveAccessors

  reactive_accessor :_name
end

describe ReactiveAccessors do
  it "should assign a reactive value" do
    inst = TestReactiveAccessors.new

    inst._name = 'Ryan'
    expect(inst._name).to eq('Ryan')
  end

  it "should start nil" do
    inst = TestReactiveAccessors.new

    expect(inst._name).to eq(nil)
  end

  it 'should trigger changed when assigning a new value' do
    inst = TestReactiveAccessors.new
    values = []

    -> { values << inst._name }.watch!

    expect(values).to eq([nil])

    inst._name = 'Ryan'
    Computation.flush!
    expect(values).to eq([nil,'Ryan'])

    inst._name = 'Stout'
    Computation.flush!
    expect(values).to eq([nil,'Ryan','Stout'])
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
volt-0.8.14 spec/controllers/reactive_accessors_spec.rb
volt-0.8.13 spec/controllers/reactive_accessors_spec.rb
volt-0.8.11 spec/controllers/reactive_accessors_spec.rb
volt-0.8.10 spec/controllers/reactive_accessors_spec.rb
volt-0.8.9 spec/controllers/reactive_accessors_spec.rb
volt-0.8.8 spec/controllers/reactive_accessors_spec.rb
volt-0.8.7 spec/controllers/reactive_accessors_spec.rb
volt-0.8.6 spec/controllers/reactive_accessors_spec.rb
volt-0.8.5 spec/controllers/reactive_accessors_spec.rb
volt-0.8.4 spec/controllers/reactive_accessors_spec.rb
volt-0.8.3 spec/controllers/reactive_accessors_spec.rb
volt-0.8.2 spec/controllers/reactive_accessors_spec.rb
volt-0.8.1 spec/controllers/reactive_accessors_spec.rb
volt-0.8.0 spec/controllers/reactive_accessors_spec.rb