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.4.16 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.15 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.14 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.13 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.12 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.11 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.10 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.9 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.8 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.7 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.6 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.4 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.3 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.2 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.1 spec/fb_graph/seriarization_spec.rb
fb_graph-2.4.0 spec/fb_graph/seriarization_spec.rb
fb_graph-2.3.2 spec/fb_graph/seriarization_spec.rb
fb_graph-2.3.1 spec/fb_graph/seriarization_spec.rb
fb_graph-2.3.0 spec/fb_graph/seriarization_spec.rb
fb_graph-2.2.6 spec/fb_graph/seriarization_spec.rb