Sha256: 16650fd1f325b0647419867da7e4c65377a29d8a05ff18d9d14aab8039c336fe

Contents?: true

Size: 1.26 KB

Versions: 55

Compression:

Stored size: 1.26 KB

Contents

require 'volt/models'

describe ReactiveValue do
  it "should concat reactive strings" do
    a = ReactiveValue.new('cool')
    b = ReactiveValue.new('beans')
    
    c = a + b
    expect(c.cur).to eq('coolbeans')
    expect(c.reactive?).to eq(true)
  end
  
  it "should concat reactive and non-reactive" do
    a = ReactiveValue.new('cool')
    b = 'beans'
    
    c = a + b
    expect(c.cur).to eq('coolbeans')
    expect(c.reactive?).to eq(true)    
  end
  
  it "should concat non-reactive and reactive" do
    a = 'cool'
    b = ReactiveValue.new('beans')
    
    c = a + b
    expect(c.cur).to eq('coolbeans')
    expect(c.reactive?).to eq(true)    
  end
  
  if RUBY_PLATFORM != 'opal'
    it "should append reactive to reactive" do
      a = ReactiveValue.new('cool')
      b = ReactiveValue.new('beans')
    
      a << b
      expect(a.cur).to eq('coolbeans')
      expect(a.reactive?).to eq(true)
    end
  end
  
  it "should raise an exception when appending  non-reactive and reactive" do
    a = 'cool'
    b = ReactiveValue.new('beans')
    
    exception_count = 0
    begin
      a << b
    rescue => e
      expect(e.message[/Cannot append a reactive/].cur.true?).to eq(true)
      exception_count += 1
    end
    
    expect(exception_count).to eq(1)
  end

end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
volt-0.3.9 spec/models/string_extensions_spec.rb
volt-0.3.8 spec/models/string_extensions_spec.rb
volt-0.3.7 spec/models/string_extensions_spec.rb
volt-0.3.6 spec/models/string_extensions_spec.rb
volt-0.3.5 spec/models/string_extensions_spec.rb
volt-0.3.4 spec/models/string_extensions_spec.rb
volt-0.3.3 spec/models/string_extensions_spec.rb
volt-0.3.2 spec/models/string_extensions_spec.rb
volt-0.3.1 spec/models/string_extensions_spec.rb
volt-0.3.0 spec/models/string_extensions_spec.rb
volt-0.2.9 spec/models/string_extensions_spec.rb
volt-0.2.7 spec/models/string_extensions_spec.rb
volt-0.2.5 spec/models/string_extensions_spec.rb
volt-0.2.4 spec/models/string_extensions_spec.rb
volt-0.2.3 spec/models/string_extensions_spec.rb