Sha256: 207fefc6439a9a9806d0893e9f33cbf406565382737a225641750a1c2551464a
Contents?: true
Size: 1.57 KB
Versions: 3
Compression:
Stored size: 1.57 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 "default 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 "format pretty" do it "works" do result = User.all.analyze(format: :pretty_json) expect(JSON.parse(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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
activerecord-analyze-0.10.2 | spec/main_spec.rb |
activerecord-analyze-0.10.1 | spec/main_spec.rb |
activerecord-analyze-0.10.0 | spec/main_spec.rb |