Sha256: d96abf4d3557e517a35c642d345ff6285b8cba54d7932174270ded95f52c929e
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
# frozen_string_literal: true require 'spec_helper' require "migrations/create_users_migration.rb" class User < ActiveRecord::Base; end describe "ActiveRecord analyze" do before(:all) do ActiveRecord::Base.establish_connection( ENV.fetch("DATABASE_URL") ) @schema_migration = ActiveRecord::Base.connection.schema_migration ActiveRecord::Migrator.new(:up, [CreateUsers.new], @schema_migration).migrate end describe "no opts" do it "works" do expect do User.all.analyze end.not_to raise_error end end describe "format json" do it "works" do result = User.all.analyze(format: :json) expect(JSON.parse(result)[0].keys.sort).to eq [ "Execution Time", "Plan", "Planning Time", "Triggers" ] end end describe "format hash" do it "works" do result = User.all.analyze(format: :hash) expect(result[0].keys.sort).to eq [ "Execution Time", "Plan", "Planning Time", "Triggers" ] end end describe "supports options" do it "works" do result = User.all.limit(10).where.not(email: nil).analyze( format: :hash, costs: true, timing: true, summary: true ) expect(result[0].keys.sort).to eq [ "Execution Time", "Plan", "Planning Time", "Triggers" ] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activerecord-analyze-0.7.1 | spec/main_spec.rb |
activerecord-analyze-0.7.0 | spec/main_spec.rb |