Sha256: abb6f6921b29ae46acae8766330bd4c1abb917a53fe4fdd9658261d2d56f52da

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

require 'test_helper'

class YamlTest < ActiveSupport::TestCase

  setup do
    # Setup a hash with random values
    @hash = {}
    (1..4).each do |i|
      @hash["key#{i}".to_sym] = Faker::Lorem.word
    end
    @hash_as_yaml = @hash.to_yaml
    # Setup an array of random words
    @array = []
    (rand(5) + 4).times { @array << Faker::Lorem.word }
    @array_as_yaml = @array.to_yaml
  end

  context '`load` class method' do
    should 'exist' do
      assert PaperTrail::Serializers::Yaml.respond_to?(:load)
    end

    should '`deserialize` YAML to Ruby' do
      assert_equal @hash, PaperTrail::Serializers::Yaml.load(@hash_as_yaml)
      assert_equal @array, PaperTrail::Serializers::Yaml.load(@array_as_yaml)
    end
  end

  context '`dump` class method' do
    should 'exist' do
      assert PaperTrail::Serializers::Yaml.respond_to?(:dump)
    end

    should '`serialize` Ruby to YAML' do
      assert_equal @hash_as_yaml, PaperTrail::Serializers::Yaml.dump(@hash)
      assert_equal @array_as_yaml, PaperTrail::Serializers::Yaml.dump(@array)
    end
  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
paper_trail_without_deprecated-3.0.0.beta1 test/unit/serializers/yaml_test.rb
paper_trail-3.0.0.beta1 test/unit/serializers/yaml_test.rb
paper_trail-2.7.2 test/unit/serializers/yaml_test.rb
paper_trail-2.7.1 test/unit/serializers/yaml_test.rb