Sha256: 2f42b182878aecbbe73709d31c523a75c93cd3156e4880a081c08d567b9afd11

Contents?: true

Size: 1.11 KB

Versions: 18

Compression:

Stored size: 1.11 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/../spec_helper_tables' unless metaclass.class_variable_defined? :@@set_up_demo_tables

describe "Sequel::Serializer" do

  describe "to_fos_json method" do

    it "adds :only=>[] to the options hash" do
      data = Trip.new
      mock(data).to_json({:only=>[], :methods=>[]})
      data.to_fos_json(:methods=>[])
    end

    it "handles single sequel model" do
      add_test_table_data({:id=>1, :'goofy name col' => 123})
      data = TestTable.first
      data.to_fos_json(:methods=>[:'goofy name col']).should == "{\"goofy name col\":123}"
    end

    it "handles an array of sequel models" do
      add_test_table_data({:id=>1, :'goofy name col' => 123})
      array = [TestTable.first]
      array.to_fos_json(:methods=>[:'goofy name col']).should=="[{\"goofy name col\":123}]"
    end

    it "shows methods which are dynamically delegated" do
      add_test_table_data({:id=>1, :'date_col' => 123})
      data = TestTable.first
      data.to_fos_json(:methods=>[:date_col__round]).should == "{\"date_col__round\":123}"
    end

  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
fossil-0.4.26 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.25 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.24 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.23 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.22 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.20 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.19 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.18 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.17 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.16 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.15 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.14 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.13 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.12 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.10 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.9 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.8 spec/sequel/serializer/json_serializer_spec.rb
fossil-0.4.7 spec/sequel/serializer/json_serializer_spec.rb