Sha256: 3dbfd3587f4bad20f0d4dfc1dd5f34b6149e72f4169ecdd26d43f96fee835bdb

Contents?: true

Size: 659 Bytes

Versions: 7

Compression:

Stored size: 659 Bytes

Contents

require "spec_helper"

class Search < ActiveRecord::Base; end

describe Scenic::SchemaDumper, :db do
  it "dumps a create_view for a view in the database" do
    view_definition = "SELECT 'needle'::text AS haystack"
    Search.connection.create_view :searches, sql_definition: view_definition
    stream = StringIO.new

    ActiveRecord::SchemaDumper.dump(Search.connection, stream)

    output = stream.string
    expect(output).to include "create_view :searches"
    expect(output).to include view_definition

    Search.connection.drop_view :searches

    silence_stream(STDOUT) { eval(output) }

    expect(Search.first.haystack).to eq "needle"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
scenic-1.2.0 spec/scenic/schema_dumper_spec.rb
scenic-1.1.1 spec/scenic/schema_dumper_spec.rb
scenic-1.1.0 spec/scenic/schema_dumper_spec.rb
scenic-1.0.0 spec/scenic/schema_dumper_spec.rb
scenic-0.3.0 spec/scenic/schema_dumper_spec.rb
scenic-0.2.1 spec/scenic/schema_dumper_spec.rb
scenic-0.2.0 spec/scenic/schema_dumper_spec.rb