Today I was working on a method that had to take a string, and resolve it to a class. This method needed to perform some validation on the model class, to make sure it was a type we expected. My first iteration of this didn’t work - I expected that I could use Object#kind_of?, however this only works for testing...
There’s some preamble here. Jump to solution Recently, I’ve been working on a client project that needs to function offline. This means that I have a subset of tests where I need to change the connectivity status of the browser driving the tests to simulate being offline to make assertions that the application is behaving correctly. I already knew that...
A very handy API I’ve stumbled across today: page.driver.browser.manage.logs.get(:browser) This returns an array of Selenium::LogEntry instances which have the expected properties - level, timestamp, and message. You can use standard Enumerable methods to filter the log entries down to the information relevant to you. For example, all error messages: page.driver.browser.manage.logs.get(:browser).select { |le| le.level == "SEVERE" }.map(&:message) => ["http://127.0.0.1:40539/madeup - Failed...
I’ve been porting some previously server-rendered Rails templates to instead sit within a React application. This particular application uses Foundation Sites for base styles, and uses some of Foundation’s components which use Javascript to function - mostly basic stuff like data-dropdown, data-accordion, data-tabs. Foundation (still) uses jQuery for setting up these elements, and by default, initializes based on the ready...
This post is written stepping through the most recent stable branch of Rails on Github: 6-1-stable. It may not remain up to date. Reading time: about 20 minutes Skip table of contents How is the ‘db:migrate’ rake task defined? The Rails gem includes ‘activerecord’ as a gem dependency: The activerecord gem adds it’s own ‘lib/` directory to Ruby’s load path:...
I use ActionMailer::Previews whenever I am implementing a transactional email. They’re a super handy way of working with email development, and I’ve even enabled them in UAT environments before so clients and designers can check the email easily. In many apps, nearly all the transactional email is actually sent by Devise, so I wanted to set up a ActionMailer preview...
Ever seen the error “You must use Bundler 2 or greater with this lockfile.” trying to build a Docker image from a Dockerfile that uses an older Ruby version? Even though you are gem installing the correct version of Bundler? It turns out that the Ruby Docker images set an environment variable called BUNDLER_VERSION, which Bundler will always try to...
Every so often I will need to take some kind of key file - like a PGP key, SSH, OpenSSL, that kind of thing, and be able to paste it into a one-line text entry somewhere. Maybe a .env file, or shell script, or some piece of infrastructure that just accepts a text field as the input (like CI configuration)....
If you’ve got a large zipfile, or just a badly named one and you’d like to quickly take a peek at what’s inside it, there’s a handy flag that can be passed to the unzip utility (apt install unzip): unzip -vl path_to_zip.zip This yields an output like: root@224cb547fae0:/usr/src/app# unzip -vl spec/fixtures/example.zip Archive: spec/fixtures/example.zip Length Method Size Cmpr Date Time CRC-32...
gpg --list-only $infile
e.g.
gpg --list-only test.txt.gpg
This command outputs recipient info, including recipient key ID and details if known:
With an empty keyring (no public keys imported):
gpg: encrypted with RSA key, ID 70F28839
With a populated keyring (public key of recipient imported):
gpg: encrypted with 4096-bit RSA key, ID 70F28839, created 2018-05-29
"Josh McArthur <[email protected]>"