Remove most docs for ignoring_interference_by_writer
Since `ignoring_interference_by_writer` is on by default now, we don't need to explicitly document it (unless someone wants to turn it off, but that's unlikely). [ci skip]
This commit is contained in:
parent
5aa15098bb
commit
663c2f2c4d
|
@ -70,39 +70,6 @@ module Shoulda
|
||||||
# with_message("there shall be peace on Earth")
|
# with_message("there shall be peace on Earth")
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# ##### ignoring_interference_by_writer
|
|
||||||
#
|
|
||||||
# Use `ignoring_interference_by_writer` when the attribute you're testing
|
|
||||||
# changes incoming values. This qualifier will instruct the matcher to
|
|
||||||
# suppress raising an AttributeValueChangedError, as long as changing the
|
|
||||||
# doesn't also change the outcome of the test and causes it to fail. See
|
|
||||||
# the documentation for `allow_value` for more information on this.
|
|
||||||
#
|
|
||||||
# class PowerHungryCountry
|
|
||||||
# include ActiveModel::Model
|
|
||||||
# attr_accessor :nuclear_weapons
|
|
||||||
#
|
|
||||||
# validates_absence_of :nuclear_weapons
|
|
||||||
#
|
|
||||||
# def nuclear_weapons=(value)
|
|
||||||
# @nuclear_weapons = value + [:hidden_weapon]
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # RSpec
|
|
||||||
# describe PowerHungryCountry do
|
|
||||||
# it do
|
|
||||||
# should validate_absence_of(:nuclear_weapons).
|
|
||||||
# ignoring_interference_by_writer
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # Minitest (Shoulda)
|
|
||||||
# class PowerHungryCountryTest < ActiveSupport::TestCase
|
|
||||||
# should validate_absence_of(:nuclear_weapons).
|
|
||||||
# ignoring_interference_by_writer
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# @return [ValidateAbsenceOfMatcher}
|
# @return [ValidateAbsenceOfMatcher}
|
||||||
#
|
#
|
||||||
def validate_absence_of(attr)
|
def validate_absence_of(attr)
|
||||||
|
|
|
@ -73,39 +73,6 @@ module Shoulda
|
||||||
# with_message('You must accept the terms of service')
|
# with_message('You must accept the terms of service')
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# ##### ignoring_interference_by_writer
|
|
||||||
#
|
|
||||||
# Use `ignoring_interference_by_writer` when the attribute you're testing
|
|
||||||
# changes incoming values. This qualifier will instruct the matcher to
|
|
||||||
# suppress raising an AttributeValueChangedError, as long as changing the
|
|
||||||
# doesn't also change the outcome of the test and cause it to fail. See
|
|
||||||
# the documentation for `allow_value` for more information on this.
|
|
||||||
#
|
|
||||||
# class Registration
|
|
||||||
# include ActiveModel::Model
|
|
||||||
# attr_accessor :terms_of_service
|
|
||||||
#
|
|
||||||
# validates_acceptance_of :terms_of_service
|
|
||||||
#
|
|
||||||
# def terms_of_service=(value)
|
|
||||||
# @terms_of_service = value || 'something else'
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # RSpec
|
|
||||||
# describe Registration do
|
|
||||||
# it do
|
|
||||||
# should validate_acceptance_of(:terms_of_service).
|
|
||||||
# ignoring_interference_by_writer
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # Minitest (Shoulda)
|
|
||||||
# class RegistrationTest < ActiveSupport::TestCase
|
|
||||||
# should validate_acceptance_of(:terms_of_service).
|
|
||||||
# ignoring_interference_by_writer
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# @return [ValidateAcceptanceOfMatcher]
|
# @return [ValidateAcceptanceOfMatcher]
|
||||||
#
|
#
|
||||||
def validate_acceptance_of(attr)
|
def validate_acceptance_of(attr)
|
||||||
|
|
|
@ -112,41 +112,6 @@ module Shoulda
|
||||||
# with_message('You chose a puny weapon')
|
# with_message('You chose a puny weapon')
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# ##### ignoring_interference_by_writer
|
|
||||||
#
|
|
||||||
# Use `ignoring_interference_by_writer` when the attribute you're testing
|
|
||||||
# changes incoming values. This qualifier will instruct the matcher to
|
|
||||||
# suppress raising an AttributeValueChangedError, as long as changing the
|
|
||||||
# doesn't also change the outcome of the test and cause it to fail. See
|
|
||||||
# the documentation for `allow_value` for more information on this.
|
|
||||||
#
|
|
||||||
# class Game < ActiveRecord::Base
|
|
||||||
# include ActiveModel::Model
|
|
||||||
# attr_accessor :weapon
|
|
||||||
#
|
|
||||||
# validates_exclusion_of :weapon
|
|
||||||
#
|
|
||||||
# def weapon=(value)
|
|
||||||
# @weapon = value.gsub(' ', '')
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # RSpec
|
|
||||||
# describe Game do
|
|
||||||
# it do
|
|
||||||
# should validate_exclusion_of(:weapon).
|
|
||||||
# in_array(['pistol', 'paintball gun', 'stick']).
|
|
||||||
# ignoring_interference_by_writer
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # Minitest (Shoulda)
|
|
||||||
# class GameTest < ActiveSupport::TestCase
|
|
||||||
# should validate_exclusion_of(:weapon).
|
|
||||||
# in_array(['pistol', 'paintball gun', 'stick']).
|
|
||||||
# ignoring_interference_by_writer
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# @return [ValidateExclusionOfMatcher]
|
# @return [ValidateExclusionOfMatcher]
|
||||||
#
|
#
|
||||||
def validate_exclusion_of(attr)
|
def validate_exclusion_of(attr)
|
||||||
|
|
|
@ -259,42 +259,6 @@ module Shoulda
|
||||||
# allow_blank
|
# allow_blank
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# ##### ignoring_interference_by_writer
|
|
||||||
#
|
|
||||||
# Use `ignoring_interference_by_writer` when the attribute you're testing
|
|
||||||
# changes incoming values. This qualifier will instruct the matcher to
|
|
||||||
# suppress raising an AttributeValueChangedError, as long as changing the
|
|
||||||
# doesn't also change the outcome of the test and cause it to fail. See
|
|
||||||
# the documentation for `allow_value` for more information on this.
|
|
||||||
#
|
|
||||||
# class Issue
|
|
||||||
# include ActiveModel::Model
|
|
||||||
# attr_accessor :state
|
|
||||||
#
|
|
||||||
# validates_inclusion_of :state,
|
|
||||||
# in: ['open', 'resolved', 'unresolved']
|
|
||||||
#
|
|
||||||
# def state=(value)
|
|
||||||
# @state = 'open'
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # RSpec
|
|
||||||
# describe Issue do
|
|
||||||
# it do
|
|
||||||
# should validate_inclusion_of(:state).
|
|
||||||
# in_array(['open', 'resolved', 'unresolved']).
|
|
||||||
# ignoring_interference_by_writer
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # Minitest (Shoulda)
|
|
||||||
# class IssueTest < ActiveSupport::TestCase
|
|
||||||
# should validate_inclusion_of(:state).
|
|
||||||
# in_array(['open', 'resolved', 'unresolved']).
|
|
||||||
# ignoring_interference_by_writer
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# @return [ValidateInclusionOfMatcher]
|
# @return [ValidateInclusionOfMatcher]
|
||||||
#
|
#
|
||||||
def validate_inclusion_of(attr)
|
def validate_inclusion_of(attr)
|
||||||
|
|
|
@ -216,41 +216,6 @@ module Shoulda
|
||||||
# with_long_message('Secret key must be less than 100 characters')
|
# with_long_message('Secret key must be less than 100 characters')
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# ##### ignoring_interference_by_writer
|
|
||||||
#
|
|
||||||
# Use `ignoring_interference_by_writer` when the attribute you're testing
|
|
||||||
# changes incoming values. This qualifier will instruct the matcher to
|
|
||||||
# suppress raising an AttributeValueChangedError, as long as changing the
|
|
||||||
# doesn't also change the outcome of the test and cause it to fail. See
|
|
||||||
# the documentation for `allow_value` for more information on this.
|
|
||||||
#
|
|
||||||
# class User
|
|
||||||
# include ActiveModel::Model
|
|
||||||
# attr_accessor :password
|
|
||||||
#
|
|
||||||
# validates_length_of :password, minimum: 10
|
|
||||||
#
|
|
||||||
# def password=(value)
|
|
||||||
# @password = value.upcase
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # RSpec
|
|
||||||
# describe User do
|
|
||||||
# it do
|
|
||||||
# should validate_length_of(:password).
|
|
||||||
# is_at_least(10).
|
|
||||||
# ignoring_interference_by_writer
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # Minitest (Shoulda)
|
|
||||||
# class UserTest < ActiveSupport::TestCase
|
|
||||||
# should validate_length_of(:password).
|
|
||||||
# is_at_least(10).
|
|
||||||
# ignoring_interference_by_writer
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# @return [ValidateLengthOfMatcher]
|
# @return [ValidateLengthOfMatcher]
|
||||||
#
|
#
|
||||||
def validate_length_of(attr)
|
def validate_length_of(attr)
|
||||||
|
|
|
@ -296,39 +296,6 @@ module Shoulda
|
||||||
# should validate_numericality_of(:age).allow_nil
|
# should validate_numericality_of(:age).allow_nil
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# ##### ignoring_interference_by_writer
|
|
||||||
#
|
|
||||||
# Use `ignoring_interference_by_writer` when the attribute you're testing
|
|
||||||
# changes incoming values. This qualifier will instruct the matcher to
|
|
||||||
# suppress raising an AttributeValueChangedError, as long as changing the
|
|
||||||
# doesn't also change the outcome of the test and cause it to fail. See
|
|
||||||
# the documentation for `allow_value` for more information on this.
|
|
||||||
#
|
|
||||||
# Here, `gpa` is an integer column, so it will typecast all values to
|
|
||||||
# integers. We need to use `ignoring_interference_by_writer` because the
|
|
||||||
# `only_integer` qualifier will attempt to set `gpa` to a float and assert
|
|
||||||
# that it makes the record invalid.
|
|
||||||
#
|
|
||||||
# class Person < ActiveRecord::Base
|
|
||||||
# validates_numericality_of :gpa, only_integer: true
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # RSpec
|
|
||||||
# describe Person do
|
|
||||||
# it do
|
|
||||||
# should validate_numericality_of(:gpa).
|
|
||||||
# only_integer.
|
|
||||||
# ignoring_interference_by_writer
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # Minitest (Shoulda)
|
|
||||||
# class PersonTest < ActiveSupport::TestCase
|
|
||||||
# should validate_numericality_of(:gpa).
|
|
||||||
# only_integer.
|
|
||||||
# ignoring_interference_by_writer
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# @return [ValidateNumericalityOfMatcher]
|
# @return [ValidateNumericalityOfMatcher]
|
||||||
#
|
#
|
||||||
def validate_numericality_of(attr)
|
def validate_numericality_of(attr)
|
||||||
|
|
|
@ -103,39 +103,6 @@ module Shoulda
|
||||||
# with_message('Robot has no legs')
|
# with_message('Robot has no legs')
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# ##### ignoring_interference_by_writer
|
|
||||||
#
|
|
||||||
# Use `ignoring_interference_by_writer` when the attribute you're testing
|
|
||||||
# changes incoming values. This qualifier will instruct the matcher to
|
|
||||||
# suppress raising an AttributeValueChangedError, as long as changing the
|
|
||||||
# doesn't also change the outcome of the test and cause it to fail. See
|
|
||||||
# the documentation for `allow_value` for more information on this.
|
|
||||||
#
|
|
||||||
# class Robot
|
|
||||||
# include ActiveModel::Model
|
|
||||||
# attr_accessor :name
|
|
||||||
#
|
|
||||||
# validates_presence_of :name
|
|
||||||
#
|
|
||||||
# def name=(name)
|
|
||||||
# @name = name.to_s
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # RSpec
|
|
||||||
# describe Robot do
|
|
||||||
# it do
|
|
||||||
# should validate_presence_of(:name).
|
|
||||||
# ignoring_interference_by_writer
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # Minitest (Shoulda)
|
|
||||||
# class RobotTest < ActiveSupport::TestCase
|
|
||||||
# should validate_presence_of(:name).
|
|
||||||
# ignoring_interference_by_writer
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# @return [ValidatePresenceOfMatcher]
|
# @return [ValidatePresenceOfMatcher]
|
||||||
#
|
#
|
||||||
def validate_presence_of(attr)
|
def validate_presence_of(attr)
|
||||||
|
|
Loading…
Reference in New Issue