Sha256: af1cb95f16ff7e3919c3f7830a20132283212198a748b7e35694d3d7386e58d3
Contents?: true
Size: 1.46 KB
Versions: 4
Compression:
Stored size: 1.46 KB
Contents
require "spec_helper" describe "exceed_query_limit" do context "without restrictions" do it "works when no queries are made" do expect { User.new }.not_to exceed_query_limit(0) end it "works when nil is used as a parameter" do expect { User.create id: nil }.to exceed_query_limit(0) end it "works when array is used as a restriction" do expect { (User.where id: [1, 2, 3]).to_a }.to exceed_query_limit(0) end it "works when actual number of queries is below the limit" do expect { User.create }.not_to exceed_query_limit(3) end it "works when actual number of queries exceeds the limit" do expect { User.create }.to exceed_query_limit(2) end end context "with a restriction" do it "works when no queries are made" do expect { User.new }.not_to exceed_query_limit(0).with(/INSERT/) end it "works when nil is used as a parameter" do expect { User.create id: nil }.to exceed_query_limit(0).with(/INSERT/) end it "works when array is used as a restriction" do expect { (User.where id: [1, 2, 3]).to_a } .to exceed_query_limit(0) .with(/SELECT/) end it "works when actual number of queries is below the limit" do expect { User.create }.not_to exceed_query_limit(1).with(/INSERT/) end it "works when actual number of queries exceeds the limit" do expect { User.create id: 3 }.to exceed_query_limit(0).with(/INSERT/) end end end
Version data entries
4 entries across 4 versions & 1 rubygems