Sha256: 5ce0068b71ce875e8e5234fc1e02f42f4245d413b670cd597afa13837d2a950f

Contents?: true

Size: 1.52 KB

Versions: 7

Compression:

Stored size: 1.52 KB

Contents

describe SengiriYaml::Writer do
  let(:writer){ SengiriYaml::Writer.new }

  describe "#divide" do
    subject{ writer.divide(src_file, dst_dir) }

    include_context "uses temp dir"

    let(:fixture_dir){ "#{spec_dir}/fixtures/writer" }
    let(:dst_dir)    { "#{temp_dir}/dst" }

    describe "with hash yaml" do
      let(:src_file){ "#{fixture_dir}/hash.yml" }

      let(:data1_file){ "#{dst_dir}/data1.yml" }
      let(:data1_yml) do
        <<-YAML
---
data1:
  value: 1
        YAML
      end

      let(:data2_file){ "#{dst_dir}/data2.yml" }
      let(:data2_yml) do
        <<-YAML
---
data2:
  value: 2
        YAML
      end

      before do
        # exercise
        subject
      end

      it{ should eq [data1_file, data2_file] }
      it_is_asserted_by{ File.read(data1_file) == data1_yml }
      it_is_asserted_by{ File.read(data2_file) == data2_yml }
    end

    describe "with array yaml" do
      let(:src_file){ "#{fixture_dir}/array.yml" }

      before do
        # exercise
        subject
      end

      let(:data1_file){ "#{dst_dir}/0.yml" }
      let(:data1_yml) do
        <<-YAML
---
- data1: data1
  value: 1
        YAML
      end

      let(:data2_file){ "#{dst_dir}/1.yml" }
      let(:data2_yml) do
        <<-YAML
---
- data2: data2
  value: 2
        YAML
      end

      before do
        # exercise
        subject
      end

      it{ should eq [data1_file, data2_file] }
      it_is_asserted_by{ File.read(data1_file) == data1_yml }
      it_is_asserted_by{ File.read(data2_file) == data2_yml }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sengiri_yaml-1.0.0 spec/sengiri_yaml/writer_spec.rb
sengiri_yaml-1.0.0.rc1 spec/sengiri_yaml/writer_spec.rb
sengiri_yaml-0.0.4 spec/sengiri_yaml/writer_spec.rb
sengiri_yaml-0.0.3 spec/sengiri_yaml/writer_spec.rb
sengiri_yaml-0.0.2 spec/sengiri_yaml/writer_spec.rb
sengiri_yaml-0.0.1 spec/sengiri_yaml/writer_spec.rb
sengiri_yaml-0.0.1.beta1 spec/sengiri_yaml/writer_spec.rb