Sha256: f4e2f53fcea4ca3538bd385f57438309c0ce6ca4f83cf7f1d82ef1354a897b57

Contents?: true

Size: 1.73 KB

Versions: 31

Compression:

Stored size: 1.73 KB

Contents

require_relative "../../../test_helper"

module Unit
  module GemExt
    module ActiveRecord
      class TestBase < MiniTest::Test

        describe ::ActiveRecord::Base do
          describe ".to_qry" do
            it "initiates a DirectiveRecord::Query instance and returns the query SQL" do
              query = mock
              query.expects(:to_sql).with(:select => "city").returns("SELECT city FROM offices")
              DirectiveRecord::Query.expects(:new).with(Office, Office.connection).returns(query)
              assert_equal "SELECT city FROM offices", Office.to_qry(:select => "city")
            end
          end

          describe ".qry" do
            it "selects rows with the generated query" do
              Office.expects(:to_qry).with("city").returns("SELECT city FROM offices")
              Office.connection.expects(:select_rows).with("SELECT city FROM offices").returns(%w(NYC))
              assert_equal %w(NYC), Office.qry("city")
            end
          end

          describe ".extract_connection" do
            describe "when specified" do
              it "returns the connection" do
                assert_equal "connection", Office.send(:extract_connection, ["id", "name", {:connection => "connection"}])
                assert_equal "connection", Office.send(:extract_connection, [{:connection => "connection"}])
              end
            end
            describe "when not specified" do
              it "returns the connection of the class" do
                Office.expects(:connection).returns(class_connection = "class_connection")
                assert_equal class_connection, Office.send(:extract_connection, ["id", "name"])
              end
            end
          end
        end

      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
directiverecord-0.1.32 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.31 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.30 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.29 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.28 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.27 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.26 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.25 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.24 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.23 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.22 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.21 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.20 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.19 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.18 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.17 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.16 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.15 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.14 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.13 test/unit/gem_ext/active_record/test_base.rb