Sha256: 913000693eabe79825606f9a098dbf8a363e9c927405d3ddb99ece86afae74e2
Contents?: true
Size: 986 Bytes
Versions: 2
Compression:
Stored size: 986 Bytes
Contents
require "rubygems" require "bundler/setup" ENV["RAILS_ENV"] = "test" require File.expand_path("dummy/config/environment", File.dirname(__FILE__)) require File.expand_path("dummy/db/schema", File.dirname(__FILE__)) require "test/unit" ActiveRecord::Base.connection.class.class_eval do def execute_with_query_record(sql, name = nil, &block) ($queries_executed ||= []) << sql execute_without_query_record(sql, name, &block) end alias_method_chain :execute, :query_record end class ActiveSupport::TestCase setup :create_widgets teardown :destroy_widgets def count_queries $queries_executed = [] yield $queries_executed.size end def assert_equal_relation(expected, actual) assert_kind_of ActiveRecord::Relation, actual assert_equal expected.to_a, actual.to_a end def create_widgets 177.times { Widget.connection.insert "INSERT INTO widgets (deleted) VALUES (0)" } end def destroy_widgets Widget.delete_all end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
paginary-0.0.1.pre2 | test/test_helper.rb |
paginary-0.0.1.pre1 | test/test_helper.rb |