Resetting NSUserDefaults in UI Testing
- Add "UI-Testing" to
launchArguments
before launching the app under test - On launch, check for the argument in
AppDelegate.swift
- If it exists remove everything for the app's domain from
NSUserDefaults
# AFTER the refactor | |
class ColdMessage | |
class BusinessBlank < StandardError; end | |
class MissingSubscription < StandardError; end | |
class ExistingConversation < StandardError | |
attr_reader :conversation |
. |
group :test do | |
gem 'rspec-rails' | |
gem 'capybara' | |
gem 'pdf-reader' | |
end |
launchArguments
before launching the app under testAppDelegate.swift
NSUserDefaults
class SidekiqPolicy | |
attr_reader :user, :environment | |
def initialize(user, environment: Rails.env) | |
@user = user | |
@environment = environment | |
end | |
def visible? | |
user.admin? || environment.development? |
This gist accompanies a blog post on Masilotti.com, How to manage multiple sheets in SwiftUI.
enum HTTP { | |
struct Response<T> { | |
let value: T | |
let headers: [AnyHashable: Any] | |
} | |
enum HTTPError<T: LocalizedError>: LocalizedError { | |
case failedRequest | |
case invalidResponse | |
case invalidRequest(T) |
These three files show how to handle forms with (legacy) Turbolinks in your Rails app with the new Turbo Native adapters.
:unprocessable_entity
status when encountering a form validation errorlocal: false
or remote: true
depending on your Rails version)ajax:error->form#onError
Stimulus action// Enum with manual parsing. | |
enum ScriptMessage { | |
case registerForRemoteNotifications | |
case showBackButton(url: URL) | |
case signOutCompleted | |
init?(body: [String: Any]) { | |
switch body["name"] as? String { | |
case "registerForRemoteNotifications": | |
self = .registerForRemoteNotifications |
class TestVisitDelegate: VisitDelegate { | |
func visitDidStart() { | |
record(#function) | |
} | |
func visitDidComplete() { | |
record(#function) | |
} | |
// MARK: Testing verification helpers. |