thoughtbot--shoulda-matchers/spec
Elliot Winkler 707d87dbd6 Add without_presence_validation q to belong_to
With the new Rails 5 behavior, `belong_to` will check to ensure that the
association has a presence validation on it. In some cases, however,
this is not desirable. For instance, say we have this setup:

    class Employee < ApplicationRecord
      # Assume belongs_to_required_by_default is true
      belongs_to :manager

      before_validation :add_manager

      private

      def add_manager
        self.manager = Manager.create
      end
    end

In this case, even though the association is effectively defined with
`required: true`, the ensuing presence validation never fails, because
`manager` is always set to something before validations kick off. So
this test won't work:

    it { should belong_to(:manager) }

To get around this, this commit allows us to say:

    it { should belong_to(:manager).without_presence_validation }

which instructs the matcher not to test for any presence (or absence,
for that matter) of a presence validation, mimicking the pre-Rails 5
behavior.
2019-02-14 17:48:26 -07:00
..
acceptance Adding support to allow_nil option for delegate_method matcher 2018-01-24 02:22:19 -06:00
support Attempt to address test failures on CI 2019-02-14 04:08:41 -07:00
unit/shoulda/matchers Add without_presence_validation q to belong_to 2019-02-14 17:48:26 -07:00
warnings_spy Be better about looking for warnings on Travis 2014-12-16 20:30:05 -07:00
acceptance_spec_helper.rb Extract a common spec helper 2015-10-07 23:32:51 -06:00
doublespeak_spec_helper.rb Extract a common spec helper 2015-10-07 23:32:51 -06:00
report_warnings.rb
spec_helper.rb Update rspec & rspec-rails to 3.6.x 2017-09-17 17:01:50 -05:00
unit_spec_helper.rb Add failing tests for issue 1146 2019-01-29 23:33:06 -07:00
warnings_spy.rb Fail build if there are warnings 2015-02-09 10:48:49 -07:00