module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
module Scalaxy module Matchers class CallbackPresenceMatcher < Remarkable::Base arguments :chain , :callback assertion :is_valid ? protected def is_valid? instance = @subject . kind_of ? ( Class ) ? @subject . new : @subject chain_name = "#{@chain}_callback_chain" . to_sym return false unless instance. kind_of ? ( ActiveSupport::Callbacks ) return false unless instance. class . respond_to ? ( @chain ) return false unless instance. class . respond_to ? ( chain_name ) return false if instance. class . send ( chain_name ) . select { | c | c. method == @callback } . empty ? true end end # Matches for presence of specified callback inside specified callback chain. # should_callback_presence :after_run, :notify_people def callback_presence ( * args ) CallbackPresenceMatcher. new ( * args ) . spec ( self ) end end end Remarkable. include_matchers ! ( Scalaxy, ActiveSupport::TestCase )
- en:
- scalaxy:
- callback_presence:
- description: 'Checks for presence of {{callback}} in specified callback chain {{chain}}.'
- expectations:
- is_valid: "to be valid when {{callback}} in {{chain}}"
- class Thing < ActiveRecord :: Base
- ## Callbacks
- define_callbacks : after_run
- after_run : notify_people
- end
- describe Thing do
- should_callback_presence : after_run ,: notify_people
- end
Source: https://habr.com/ru/post/73862/
All Articles