Sha256: 642b0e679d5cff591bf58c092559bd9f948d7c8c87dc3f6dd3e32a36deb21760

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

require 'rails_helper'

module Pwb
  RSpec.describe "ImportProperties" do
    include ActionDispatch::TestProcess

    # before :each do
    #   @file = fixture_file_upload('../to_import/pwb-properties.csv', 'text/csv')
    # end

    let(:csv_file) do
      fixture_file_upload(
        "/to_import/pwb-properties.csv",
        'text/csv'
      )
      # above uses below config setting
      #   config.fixture_path = "#{Pwb::Engine.root}/spec/fixtures"
    end

    let(:tsv_file) do
      fixture_file_upload(
        "/to_import/mls-listings-1.tsv",
        'text/csv'
      )
    end

    it "imports a valid tab seperated file" do
      parsed_properties = ImportProperties.new(tsv_file).import_mls_tsv
      expect(parsed_properties[0]).to include("reference")
      expect(parsed_properties.count).to eq(3)
    end

    it "imports a valid csv file" do
      # allow(ImportProperties).to_receive(:add_meal_to_order)
      # expect(prop).to receive(:update_attributes).with(status: "served", customer_id: 123)
      # expect { ImportProperties.new(csv_file).import_csv }.to change { Prop.count }.by 4
      parsed_properties = ImportProperties.new(csv_file).import_csv
      expect(parsed_properties[0]).to include("title_en")
      expect(parsed_properties.count).to eq(4)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pwb-1.4.0 spec/services/pwb/import_properties_spec.rb
pwb-1.3.0 spec/services/pwb/import_properties_spec.rb
pwb-1.2.0 spec/services/pwb/import_properties_spec.rb
pwb-1.1.1 spec/services/pwb/import_properties_spec.rb
pwb-1.0.0 spec/services/pwb/import_properties_spec.rb