Sha256: 33bb9de463a2f62b5bcf0befe1575b22ea5cee8dd6642680b0770d954c9ab382

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require File.expand_path("#{File.dirname(__FILE__)}/test_helper")

require 'activerecord-import/value_sets_parser'

describe "ActiveRecord::Import::ValueSetsRecordsParser" do
  context "#parse - computing insert value sets" do
    let(:parser) { ActiveRecord::Import::ValueSetsRecordsParser }
    let(:base_sql) { "INSERT INTO atable (a,b,c)" }
    let(:values) { ["(1,2,3)", "(2,3,4)", "(3,4,5)"] }

    context "when the max number of records is 1" do
      it "should return 3 value sets when given 3 values sets" do
        value_sets = parser.parse values, max_records: 1
        assert_equal 3, value_sets.size
      end
    end

    context "when the max number of records is 2" do
      it "should return 2 value sets when given 3 values sets" do
        value_sets = parser.parse values, max_records: 2
        assert_equal 2, value_sets.size
      end
    end

    context "when the max number of records is 3" do
      it "should return 1 value sets when given 3 values sets" do
        value_sets = parser.parse values, max_records: 3
        assert_equal 1, value_sets.size
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
activerecord-import-2.1.0 test/value_sets_records_parser_test.rb
activerecord-import-2.0.0 test/value_sets_records_parser_test.rb
activerecord-import-1.8.1 test/value_sets_records_parser_test.rb
activerecord-import-1.8.0 test/value_sets_records_parser_test.rb
activerecord-import-1.6.0 test/value_sets_records_parser_test.rb
activerecord-import-1.5.1 test/value_sets_records_parser_test.rb
activerecord-import-1.5.0 test/value_sets_records_parser_test.rb