Sha256: dc6109c829d0d641749694cb657c3aabdaa095ee859be873eef99abe17da750e

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

# coding: utf-8
require "spec_helper"

describe Dech::Dena::CSV do
  let(:valid_products){
    [
      {id: "ABC-001", price: 12800},
      {id: "xyz-123", price: 9800}
    ]
  }

  let(:invalid_products){ [ {price: 12800}, {price: 9800} ] }

  describe "initialize" do
    subject{ Dech::Dena::CSV.new(valid_products) }
    it { is_expected.to be_an_instance_of(Dech::Dena::CSV) }
    it { is_expected.to be_a(Dech::CSV) }
    it { is_expected.to be_a(StringIO) }
  end

  describe "#valid?" do
    context "with valid columns" do
      subject{ Dech::Dena::CSV.new(valid_products) }
      it { is_expected.to be_valid }
    end

    context "with invalid columns" do
      subject{ Dech::Dena::CSV.new(invalid_products) }
      it { is_expected.not_to be_valid }
    end
  end

  describe "#validate!" do
    context "valid columns" do
      subject{ lambda{ Dech::Dena::CSV.new(valid_products).validate! } }
      it { is_expected.not_to raise_error }
    end

    context "invalid columns" do
      subject{ lambda{ Dech::Dena::CSV.new(invalid_products).validate! } }
      it { is_expected.to raise_error }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dech-0.1.1 spec/dech/dena/csv_spec.rb
dech-0.1.0 spec/dech/dena/csv_spec.rb
dech-0.0.7 spec/dech/dena/csv_spec.rb
dech-0.0.6 spec/dech/dena/csv_spec.rb