Sha256: bada84d09b9b9216bb98805d42c01b23d4a1c7cf365c3a60a1f442a088e6bf0a

Contents?: true

Size: 1.12 KB

Versions: 18

Compression:

Stored size: 1.12 KB

Contents

require File.dirname(__FILE__) + '/base'
require 'active_support/core_ext/kernel/debugger'

describe YamlDb::Load do
	before do
		SerializationHelper::Utils.stub!(:quote_table).with('mytable').and_return('mytable')

		silence_warnings { ActiveRecord::Base = mock('ActiveRecord::Base', :null_object => true) }
		ActiveRecord::Base.stub(:connection).and_return(stub('connection').as_null_object)
		ActiveRecord::Base.connection.stub!(:transaction).and_yield
	end

	before(:each) do
		@io = StringIO.new
    end
    

	it "should call load structure for each document in the file" do
		YAML.should_receive(:load_documents).with(@io).and_yield({ 'mytable' => { 
					'columns' => [ 'a', 'b' ], 
					'records' => [[1, 2], [3, 4]] 
				} } )
		YamlDb::Load.should_receive(:load_table).with('mytable', { 'columns' => [ 'a', 'b' ], 'records' => [[1, 2], [3, 4]] },true)
		YamlDb::Load.load(@io)
	end

	it "should not call load structure when the document in the file contains no records" do
		YAML.should_receive(:load_documents).with(@io).and_yield({ 'mytable' => nil })
		YamlDb::Load.should_not_receive(:load_table)
		YamlDb::Load.load(@io)
	end

end

Version data entries

18 entries across 18 versions & 9 rubygems

Version Path
yaml_db_with_schema_tables-0.3.4 spec/yaml_load_spec.rb
yaml_db_with_schema_tables-0.3.3 spec/yaml_load_spec.rb
yaml_db_with_schema_tables-0.3.2 spec/yaml_load_spec.rb
mfpiccolo_yaml_db-0.2.3 spec/yaml_load_spec.rb
yaml_db_with_schema_tables-0.2.4 spec/yaml_load_spec.rb
irm_yaml_db-0.0.4 spec/yaml_load_spec.rb
irm_yaml_db-0.0.3 spec/yaml_load_spec.rb
irm_yaml_db-0.0.2 spec/yaml_load_spec.rb
irm_yaml_db-0.0.1 spec/yaml_load_spec.rb
mtwtfss_yaml_db-0.5 spec/yaml_load_spec.rb
keeguon-yaml_db-0.2.4 spec/yaml_load_spec.rb
gitlab_yaml_db-1.0.0 spec/yaml_load_spec.rb
fm_yaml_db-0.2.5 spec/yaml_load_spec.rb
fm_yaml_db-0.2.4 spec/yaml_load_spec.rb
yaml_db-0.2.3 spec/yaml_load_spec.rb
yaml_db_arel-0.2.2 spec/yaml_load_spec.rb
yaml_db-0.2.2 spec/yaml_load_spec.rb
yaml_db-0.2.1 spec/yaml_load_spec.rb