Sha256: c5ed393c9f4f29cab8e8b3a164e7b00a78b5b6b41125299b36024f9cf0dce80b
Contents?: true
Size: 1.57 KB
Versions: 4
Compression:
Stored size: 1.57 KB
Contents
require File.dirname(__FILE__) + '/base' describe YamlDb::Dump do before do 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!(:tables).and_return([ 'mytable', 'schema_info', 'schema_migrations' ]) ActiveRecord::Base.connection.stub!(:columns).with('mytable').and_return([ mock('a',:name => 'a', :type => :string), mock('b', :name => 'b', :type => :string) ]) ActiveRecord::Base.connection.stub!(:select_one).and_return({"count"=>"2"}) ActiveRecord::Base.connection.stub!(:select_all).and_return([ { 'a' => 1, 'b' => 2 }, { 'a' => 3, 'b' => 4 } ]) YamlDb::Utils.stub!(:quote_table).with('mytable').and_return('mytable') end before(:each) do File.stub!(:new).with('dump.yml', 'w').and_return(StringIO.new) @io = StringIO.new end it "should return a formatted string" do YamlDb::Dump.table_record_header(@io) @io.rewind @io.read.should == " records: \n" end it "should return a yaml string that contains a table header and column names" do YamlDb::Dump.stub!(:table_column_names).with('mytable').and_return([ 'a', 'b' ]) YamlDb::Dump.dump_table_columns(@io, 'mytable') @io.rewind @io.read.should == <<EOYAML --- mytable: columns: - a - b EOYAML end it "should return dump the records for a table in yaml to a given io stream" do YamlDb::Dump.dump_table_records(@io, 'mytable') @io.rewind @io.read.should == <<EOYAML records: - - 1 - 2 - - 3 - 4 EOYAML end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
yaml_db-0.2.3 | spec/yaml_dump_spec.rb |
yaml_db_arel-0.2.2 | spec/yaml_dump_spec.rb |
yaml_db-0.2.2 | spec/yaml_dump_spec.rb |
yaml_db-0.2.1 | spec/yaml_dump_spec.rb |