Sha256: 361fd29872c812336bd68b03a2c73d9ae55869173a3d01bdf64f5557eb3985fb

Contents?: true

Size: 1.6 KB

Versions: 12

Compression:

Stored size: 1.6 KB

Contents

require File.expand_path('../teststrap', __FILE__)

context 'Rabl::Configuration' do
  context 'defaults' do
    # multi_json compatibility TODO
    helper(:json_engine) { ::Oj }
    setup { Rabl.configuration }

    asserts(:include_json_root).equals true
    asserts(:include_child_root).equals true
    asserts(:include_xml_root).equals false
    asserts(:enable_json_callbacks).equals false
    asserts(:view_paths).equals []
    asserts(:json_engine).equals { json_engine }
    asserts(:cache_engine).is_a?(Rabl::CacheEngine)
    asserts(:replace_nil_values_with_empty_strings).equals false
  end

  context 'custom JSON engine configured as Symbol' do
    setup do
      Rabl.configure do |c|
        c.json_engine = :oj
      end
    end

    asserts('uses a custom JSON engine') { topic.json_engine.to_s =~ /oj/i }
  end # custom json, symbol

  context 'custom JSON engine configured as Class' do
    setup do
      Rabl.configure do |c|
        c.json_engine = ActiveSupport::JSON
      end
    end

    asserts('uses a custom JSON engine') { topic.json_engine.to_s == 'ActiveSupport::JSON' }
  end # custom JSON, class

  context 'raise on missing attributes' do
    setup do
      Rabl.configure do |c|
        c.raise_on_missing_attribute = true
      end
    end

    asserts(:raise_on_missing_attribute).equals true
  end # raise on missing

  context 'replace nil values with empty strings' do
    setup do
      Rabl.configure do |c|
        c.replace_nil_values_with_empty_strings = true
      end
    end

    asserts(:replace_nil_values_with_empty_strings).equals true
  end # replace nil values with empty strings
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rabl-0.9.3 test/configuration_test.rb
rabl-0.9.3.pre1 test/configuration_test.rb
rabl-0.9.2 test/configuration_test.rb
rabl-0.9.1 test/configuration_test.rb
rabl-0.9.0 test/configuration_test.rb
rabl-0.9.0.pre4 test/configuration_test.rb
rabl-0.9.0.pre3 test/configuration_test.rb
rabl-0.9.0.pre2 test/configuration_test.rb
rabl-0.9.0.pre test/configuration_test.rb
rabl-0.8.6 test/configuration_test.rb
rabl-0.8.5 test/configuration_test.rb
rabl-0.8.4 test/configuration_test.rb