Sha256: 240bbadf60784fb421a96d91ccc55fd789c079fe7afcda9249c883e31ef07d94

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

module Almanack
  describe SerializedTransformation do
    let(:fact_book) do
      {
        title: "Facts of the World",
        countries: [
          { name: "New Zealand", population: "4 mil" },
          { name: "America", population: "320 mil" }
        ]
      }
    end

    let(:transformation) { described_class.new(fact_book) }

    describe "#apply" do
      it "returns an unmodified structure by default" do
        expect(transformation.apply).to eq fact_book
      end

      it "can apply changes to keys" do
        transformation.key { |key| key.to_s }
        expect(transformation.apply).to eq({
          "title" => "Facts of the World",
          "countries" => [
            { "name" => "New Zealand", "population" => "4 mil" },
            { "name" => "America", "population" => "320 mil" }
          ]
        })
      end

      it "can apply changes to values" do
        transformation.value { |value| value.upcase  }
        expect(transformation.apply).to eq({
          title: "FACTS OF THE WORLD",
          countries: [
            { name: "NEW ZEALAND", population: "4 MIL" },
            { name: "AMERICA", population: "320 MIL" }
          ]
        })
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
almanack-1.1.0 spec/serialized_transformation_spec.rb
almanack-1.1.0.beta6 spec/serialized_transformation_spec.rb
almanack-1.1.0.beta5 spec/serialized_transformation_spec.rb
almanack-1.1.0.beta4 spec/serialized_transformation_spec.rb
almanack-1.1.0.beta3 spec/serialized_transformation_spec.rb
almanack-1.1.0.beta2 spec/serialized_transformation_spec.rb
almanack-1.1.0.beta1 spec/serialized_transformation_spec.rb