Sha256: 67ff2f3ff76717e4b1f18485bd5a346c9a81c3a4aa4e3945d089570d36112127
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module ExternalServices module RSpec module Disabler mattr_accessor :external_services module_function def add_external_service(name) self.external_services ||= [] self.external_services << name.to_sym unless self.external_services.include? name.to_sym end def disable_external_services(except: []) except = [except] unless except.is_a?(Array) except = except.map(&:to_sym) external_services.each do |name| next if name.in? except ::ActiveRecord::Base.descendants.each do |klass| set_external_service_disabled_value klass, name, true end end end def enable_external_services external_services.each do |name| ::ActiveRecord::Base.descendants.each do |klass| set_external_service_disabled_value klass, name, false end end end def set_external_service_disabled_value(klass, service, value) klass.send("#{service}_api_disabled=", value) if klass.respond_to?("#{service}_api_disabled") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
external_services-0.5.4 | lib/rspec/disabler.rb |