This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "rubocop-rspec" | |
module Cops | |
# This cop ensures that sidekiq gets exercised even in places where we care | |
# about testing message expectations. The reason for this is sidekiq already | |
# doesn't queue up jobs in test mode and stubbing them out entirely masks | |
# issues with passing incorrect variables to sidekiq. Some example of incorrect | |
# variables are ones that don't cleanly serialize and deserialize as JSON, for example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
extension XCTestCase { | |
// swiftlint:disable unavailable_function | |
/// A helper function for failing and stoping tests. Marked | |
/// | |
/// Usage: | |
/// ~~~ | |
/// guard let value = valueOptional else { | |
/// failAndStopTests("didn't expect nil") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if DEBUG | |
import CoreData | |
import SwiftUI | |
/// A protocol for allowing easy use of CoreData | |
/// with preview provider. | |
/// | |
/// NOTE: you must still | |
/// make preview comply with PreviewProvider: | |
/// ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.module_eval do | |
def self.void(method_name) | |
old_method_name = :"old_#{method_name}" | |
alias_method old_method_name, method_name | |
private old_method_name | |
define_method method_name do | |
send(old_method_name) | |
nil | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gemfile | |
gem 'active_model_serializers', require: false | |
# config/initializers/active_model_serializers.rb | |
require "active_model" | |
require "active_model/serializer/version" | |
require "active_model/serializer" | |
require 'action_controller/serialization' | |
# in controller where you want to use active model serializer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defrecord Mutant, pid: nil, _first_name: nil do | |
def init do | |
pid = spawn(Mutant, :run, []) | |
current_state(pid) | |
end | |
def current_state(pid) do | |
pid <- {self, :state } | |
receive do | |
{ :ok, record } -> record |