Sha256: 1dbb62c01d3e12b46cbc10ae72b37c73c85897aa2db491523337b4aa6a52d346

Contents?: true

Size: 1021 Bytes

Versions: 2

Compression:

Stored size: 1021 Bytes

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).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
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
directiverecord-0.1.1 test/unit/gem_ext/active_record/test_base.rb
directiverecord-0.1.0 test/unit/gem_ext/active_record/test_base.rb