Sha256: dccc33d087fb240ec203fa9af073e2766026ff115307656db2297d224fbf5bca

Contents?: true

Size: 813 Bytes

Versions: 1

Compression:

Stored size: 813 Bytes

Contents

require "spec_helper"

describe Timber::Patterns::ToJSON do
  class TestJSON
    include Timber::Patterns::ToJSON

    attr_reader :json_payload

    def initialize(json_payload)
      @json_payload = json_payload
    end
  end

  describe ".as_json" do
    let(:hash) { {} }
    let(:target) { TestJSON.new(hash) }
    subject { target.as_json }
    it { should eq({}) }

    context "with a value" do
      let(:hash) { {:test => 1} }
      it { should eq({:test => 1}) }
    end

    context "with a nil value" do
      let(:hash) { {:test => nil} }
      it { should eq({}) }
    end

    context "with an empty array" do
      let(:hash) { {:test => []} }
      it { should eq({}) }
    end

    context "with an empty hash" do
      let(:hash) { {:test => {}} }
      it { should eq({}) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timberio-1.0.0.beta1 spec/timber/patterns/to_json_spec.rb