Sha256: eb0fb5d114090bda807eec22c17de7872de276a3b98b137efbad474961b348fd

Contents?: true

Size: 1.93 KB

Versions: 33

Compression:

Stored size: 1.93 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe RubyPgExtras::TableInfo do
  subject(:result) do
    RubyPgExtras::TableInfo.call
  end

  describe "call" do
    context "stubbed cases" do
      before do
        expect(RubyPgExtras).to receive(:tables) {
          [
            { "schemaname" => "public", "tablename" => "users" },
            { "schemaname" => "public", "tablename" => "teams" }
          ]
        }

        expect(RubyPgExtras).to receive(:table_size) {
          [
            { "name" => "teams", "size" => "25 MB" },
            {"name" => "users", "size" => "250 MB"},
          ]
        }

        expect(RubyPgExtras).to receive(:index_cache_hit) {
          [
            { "name" => "teams", "ratio" => "0.98" },
            { "name" => "users", "ratio" => "0.999" },
          ]
        }

        expect(RubyPgExtras).to receive(:table_cache_hit) {
          [
            { "name" => "teams", "ratio" => "0.88" },
            { "name" => "users", "ratio" => "0.899" },
          ]
        }

        expect(RubyPgExtras).to receive(:records_rank) {
          [
            { "name" => "teams", "estimated_count" => "358" },
            { "name" => "users", "estimated_count" => "8973" },
          ]
        }

        expect(RubyPgExtras).to receive(:seq_scans) {
          [
            { "name" => "teams", "count" => "0" },
            { "name" => "users", "count" => "409328" },
          ]
        }

        expect(RubyPgExtras).to receive(:table_index_scans) {
          [
            { "name" => "teams", "count" => "8579" },
            { "name" => "users", "count" => "0" },
          ]
        }
      end

      it "works" do
        expect {
          RubyPgExtras::TableInfoPrint.call(result)
        }.not_to raise_error
      end
    end

    context "real data" do
      it "works" do
        expect {
          RubyPgExtras::TableInfoPrint.call(result)
        }.not_to raise_error
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
ruby-pg-extras-5.3.1 spec/table_info_spec.rb
ruby-pg-extras-5.3.0 spec/table_info_spec.rb
ruby-pg-extras-5.2.5 spec/table_info_spec.rb
ruby-pg-extras-5.2.4 spec/table_info_spec.rb
ruby-pg-extras-5.2.3 spec/table_info_spec.rb
ruby-pg-extras-5.2.2 spec/table_info_spec.rb
ruby-pg-extras-5.2.1 spec/table_info_spec.rb
ruby-pg-extras-5.2.0 spec/table_info_spec.rb
ruby-pg-extras-5.1.0 spec/table_info_spec.rb
ruby-pg-extras-5.0.0 spec/table_info_spec.rb
ruby-pg-extras-4.13.0 spec/table_info_spec.rb
ruby-pg-extras-4.12.2 spec/table_info_spec.rb
ruby-pg-extras-4.12.1 spec/table_info_spec.rb
ruby-pg-extras-4.12.0 spec/table_info_spec.rb
ruby-pg-extras-4.11.0 spec/table_info_spec.rb
ruby-pg-extras-4.10.0 spec/table_info_spec.rb
ruby-pg-extras-4.9.0 spec/table_info_spec.rb
ruby-pg-extras-4.8.1 spec/table_info_spec.rb
ruby-pg-extras-4.7.2 spec/table_info_spec.rb
ruby-pg-extras-4.7.1 spec/table_info_spec.rb