Use NameError#name to assert raised error.

This makes the test compatible with other Ruby implementations, which
may implement error messages differently.
If a counter_cache exists, use it for #empty?
[ci skip] Add return values to examples
[ci skip] Consolidate docs for `first`

Add docs for `first` when provided a numerical argument. 

Since `first!` behaves exactly the same way but can raise an argument we can consolidate it in the `first` section.
[ci skip] Consolidate docs for `find_by`

Since `find_by!` behaves exactly the same way but can raise an argument we can consolidate it in the `find_by` section.
[ci skip] Consolidate docs for `take`

Add docs on what happens when a numerical argument is provided to take.

Since `take!` behaves exactly the same way but can raise an argument we can consolidate it in the `take` section.
[ci skip] Consolidate docs for `last`

Add docs on what happens when a numerical argument is provided to last.

Since `last!` behaves exactly the same way but can raise an argument we can consolidate it in the `last` section.
[ci skip] Consolidate docs for `find`

Put all options for overloading `find` in one section
[ci skip] Doc ability to chain in `find_each`

Also use appropriate mailer syntax in the `find_each` block.
[ci skip] Fix doc for except

The example showed is `except`, however the method "documented" is `unstop`. Fix to align the docs to the example.
[ci skip] remove invalid code from docs
Prefer find_by over where.first for record
Begin refactoring ThroughReflection

This allows us to decouple AssociationReflection and
ThroughReflection making ThroughReflection it's own Reflection
bucket in a way. The benefit of this is to be able to remove
checks against the macro's symbol for exmaple `macro == :belongs_to`.

Get all tests passing again

Some of the methods that used to be inherited from MacroReflection
through AssociationReflection were no longer getting passed through.
They needed to be duplicated into the ThroughReflection. I will
extract these out into a separate class.

Refactor shared methods into strategy object

Now that we've separated ThroughReflection and AssociationReflection
we can combine shared methods into one class to avoid duplication.

Break out class for each type of reflection

This creates a class for each reflection type (has_many, has_one,
belongs_to and habtm). We then can remove the need to set the macro
symbol in each initialization.

Tests were updated to reflect these changes because creation of
these reflections is now different.

Remove need for @collection instance var

We now define `collection?` as `false` by default and set it to
`true` in `has_and_belongs_to_many` and `has_many` reflections.
This removes the need for the `@collection` instance variable.

Raise exception on unknown macro types

We shouldn't accept just any macro when creating reflections. An
unrecongnized AssociationReflection raises an error. Tests in
`reflection_test` were updated to reflect these new changes.
`:has_and_belongs_to_many` macro tests were removed because we no
longer internally return HABTM.
Dump PostgreSQL primary key with custom function as a default.

For example, if use pgcrypto extension in PostgreSQL 9.4 beta 1, where
uuid-ossp extension isn't available for moment of writing, and thus to
use a gen_random_uuid() method as a primary key default.

In this case schema dumper wasn't able to correctly reconstruct
create_table statement and lost primary key constraint on schema load.

Fixes #16111.
Use a type object for type casting behavior on SQLite3
Don't rely on the column SQL type for bit string quoting
AttributeSet#include? -> AttributeSet#key?

https://github.com/rails/rails/pull/15868/files#r14135210
Merge pull request #16055 from sgrif/sg-refactor-sqlite3-strings

Use a type object for type casting behavior on SQLite3
Merge pull request #16136 from sgrif/sg-pg-bit-string

Don't rely on the column SQL type for bit string quoting
Add ability to extend `rails server` command options parser

With this change it will be possible to add additional options to the `option_parser` like this:

    require 'rails/commands/server'
    module Rails
      class Server < ::Rack::Server
        class Options
          def option_parser_with_open(options)
            parser = option_parser_without_open options
            parser.on('-o', '--open', 'Open in default browser') { options[:open] = true }
            parser
          end
          alias_method_chain :option_parser, :open
        end

        def start_with_open
          start_without_open do
            `open http://localhost:3000` if options[:open]
          end
        end
        alias_method_chain :start, :open
      end
    end