Sha256: af6d7c1c464900ed29ea1492f75fedfa8075cbbd6f5dcf975fe76af54d0487be

Contents?: true

Size: 944 Bytes

Versions: 3

Compression:

Stored size: 944 Bytes

Contents

require 'spec_helper'
require 'volt/controllers/reactive_accessors'

class TestReactiveAccessors
  include ReactiveAccessors

  reactive_accessor :_name
end

describe ReactiveAccessors do
  it "should return the same reactive value after each read" do
    inst = TestReactiveAccessors.new

    expect(inst._name.reactive_manager.object_id).to eq(inst._name.reactive_manager.object_id)
  end

  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.cur).to eq(nil)
  end

  it "should keep the same reactive value when reassigning" do
    inst = TestReactiveAccessors.new

    inst._name = 'Ryan'
    rv1_id = inst._name.reactive_manager.object_id

    inst._name = 'Jim'
    rv2_id = inst._name.reactive_manager.object_id

    expect(rv1_id).to eq(rv2_id)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
volt-0.7.23 spec/controllers/reactive_accessors_spec.rb
volt-0.7.22 spec/controllers/reactive_accessors_spec.rb
volt-0.7.21 spec/controllers/reactive_accessors_spec.rb