Sha256: dfe6f55e2b358b6bdd80b5df2e03a30952d894bf70a2aaee0f143a08a4849812

Contents?: true

Size: 612 Bytes

Versions: 109

Compression:

Stored size: 612 Bytes

Contents

require 'spec_helper'

class Klass1
  include FbGraph::Serialization
  attr_accessor :att1, :att2
end

class Klass2 < Klass1
  def to_hash(options = {})
    {:att1 => self.att1, :att2 => self.att2}
  end
end

describe FbGraph::Serialization do
  before do
    @node1 = Klass1.new
    @node2 = Klass2.new
    @node1.att1 = "hello"
    @node2.att1 = "hello"
  end

  it 'should require to_hash' do
    lambda do
      @node1.to_json
    end.should raise_error(StandardError, 'Define Klass1#to_hash!')
    @node2.to_hash == {:att1 => 'hello', :att2 => nil}
    @node2.to_json == {:att1 => 'hello'}.to_json
  end
end

Version data entries

109 entries across 109 versions & 1 rubygems

Version Path
fb_graph-2.7.17 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.16 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.15 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.14 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.13 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.12 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.11 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.10 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.9 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.8 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.7 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.6 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.5 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.4 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.3 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.2 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.1 spec/fb_graph/seriarization_spec.rb
fb_graph-2.7.0 spec/fb_graph/seriarization_spec.rb
fb_graph-2.6.7 spec/fb_graph/seriarization_spec.rb
fb_graph-2.6.6 spec/fb_graph/seriarization_spec.rb