Sha256: e0e49cad39cbc16ce86d9f6a512a1eebe8918ba74d81b06db67c68bb66794b15

Contents?: true

Size: 1.05 KB

Versions: 5

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

5 entries across 5 versions & 1 rubygems

Version Path
paper_trail-3.0.2 test/unit/serializers/yaml_test.rb
paper_trail-3.0.1 test/unit/serializers/yaml_test.rb
paper_trail-3.0.0 test/unit/serializers/yaml_test.rb
paper_trail-3.0.0.rc2 test/unit/serializers/yaml_test.rb
paper_trail-3.0.0.rc1 test/unit/serializers/yaml_test.rb