Sha256: b7d1f42b0ec7879f193080abc99155b8258c28c61736f78132c67fddd49ffdb8

Contents?: true

Size: 846 Bytes

Versions: 3

Compression:

Stored size: 846 Bytes

Contents

require 'spec_helper'

describe SonJay::ValueArray do
  it "is array-like" do
    expect( subject.to_ary ).to eq( subject )
    expect( subject << 1 << 2 ).to eq( [1, 2] )
  end

  describe '#model_content' do
    it "returns the instance itself" do
      expect( subject.model_content ).to eq( subject )
    end
  end

  describe '#load_data' do
    it "replaces content with given array" do
      subject << 1
      expect( subject.length ).to eq( 1 )

      subject.load_data( [7, 8, 9] )

      expect( subject.entries ).to eq( [7, 8, 9] )
    end
  end

  describe '#to_json' do
    it "returns a JSON representation of the array w/ values" do
      subject.replace( [1, 2, 'three'] )

      actual_json = subject.to_json

      parsed_json = JSON.parse( actual_json )
      expect( parsed_json ).to eq( [1, 2, 'three'] )
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
son_jay-0.5.2 spec/value_array_spec.rb
son_jay-0.5.1 spec/value_array_spec.rb
son_jay-0.5.0 spec/value_array_spec.rb