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.1.2 spec/fb_graph/seriarization_spec.rb
fb_graph-2.1.1 spec/fb_graph/seriarization_spec.rb
fb_graph-2.1.0 spec/fb_graph/seriarization_spec.rb
fb_graph-2.1.0.alpha spec/fb_graph/seriarization_spec.rb
fb_graph-2.0.2 spec/fb_graph/seriarization_spec.rb
fb_graph-2.0.1 spec/fb_graph/seriarization_spec.rb
fb_graph-2.0.0 spec/fb_graph/seriarization_spec.rb
fb_graph-2.0.0.beta spec/fb_graph/seriarization_spec.rb
fb_graph-2.0.0.alpha spec/fb_graph/seriarization_spec.rb
fb_graph-1.9.5 spec/fb_graph/seriarization_spec.rb
fb_graph-1.9.4 spec/fb_graph/seriarization_spec.rb
fb_graph-1.9.3 spec/fb_graph/seriarization_spec.rb
fb_graph-1.9.2 spec/fb_graph/seriarization_spec.rb
fb_graph-1.9.1 spec/fb_graph/seriarization_spec.rb
fb_graph-1.9.0 spec/fb_graph/seriarization_spec.rb
fb_graph-1.8.6 spec/fb_graph/seriarization_spec.rb
fb_graph-1.8.5 spec/fb_graph/seriarization_spec.rb
fb_graph-1.8.4 spec/fb_graph/seriarization_spec.rb
fb_graph-1.8.3 spec/fb_graph/seriarization_spec.rb
fb_graph-1.8.2 spec/fb_graph/seriarization_spec.rb