github.com

...default it allows only accessing visible elements -- when you are using a driver that supports it (e.g. Selenium, not the default Rack::Test driver). Consider the following HTML: One

...true) or find(..., visible: :visible). Note that you could change the default behavior by setting the ignore_hidden_elements config option. However, ignoring invisible elements is a useful default.

...just barely wider than the container it should fit into, and it wraps a single word to a new line and it's not really pretty? Cry no more, for...

...in some browsers. When browsers encounter a text-wrapping element with text-wrap: balance style, they will try breaking to a new line sooner, if it balances out the width...

...you have too many inotify instances you may run into limits of your operating system. To find out which process is using them all up you can run:

makandracards.com

...bug) and want to use git bisect to find out when it was introduced? Smart kid. If you have a shell command ready to reveal if your current state is...

...other hand will use the return value of that call to decide if the state is good or bad. First, start bisecting git bisect start Then tell git which revisions...

To query for identical arrays independent of their order you have to either: Sort both the query and database content. If you're on Rails 7.1 you can use...

...the new normalizes macro for this. This solution would still use any indexes on the column. Check for inclusion in both directions, as implemented by the where_array_matches method...

developer.mozilla.org

You can do so much more than console.log(...)! See the attached link for a great breakdown of what the developer console can give you. Some of my favorites: console.log takes...

E.g. console.log("Current string:", string, "Current number:", 12) Your output can have hyperlinks to Javascript objects E.g. console.log("Check out the current %o, it's great", location)

Orca is a Linux screen reader. Since it is part of the GNOME project it should come preinstalled with Ubuntu installations. To turn on the screen reader you can either...

...go to Settings > Accessibility and then activate Screen Reader in the "Seeing" section or you can simply type orca in your terminal. Note It may feel quite strange in the...

makandra dev

Geordi provides a pretty neat way to generate beautiful commit messages according to your stories in Linear: geordi commit Geordi reads from a .geordi.yml file inside your repo and connects...

...to Linear to list started and finished stories with their title. Choosing one of them generates a commit message including id and title from Linear app and a link to...

...is defined incorrectly. Raise the attributes hash given to your :reject_if lambda to see if it looks like you expect. If you are nesting forms into nested forms, each...

...a new parent record together with a new child record and will need to save the parent before you can save the child. You can opt to only show the...

ImageMagick can convert SVGs to raster image formats. Example for PNG: convert input.svg output.png If the SVG has a size of 24x24 (viewBox="0 0 24 24"), the resulting...

...PNG will also have a size of 24x24. Resizing An SVG's viewBox specifies the intended size, but vector image formats can be scaled freely. Resize flag (poor results)

makandra dev

...is just awesome. Install via apt-get or brew. Handy commands t ("tree"): Directory-structure based access. You'll see the current directory annotated with the latest change date and...

...date and author. d ("diff"): Like ENTER on a commit, but arrow keys will scroll the diff! /: Search current view (e.g. commit list, diff). Jump to next hit with n...

...For ages, CSS transforms had to be defined using the transform property. For a single transformation, this was something like transform: scale(1.5), and multiple transformations could be applied by...

.example { transform: scale(1.5) rotate(45deg) translateY(-50%); } All modern browsers (Chrome & Edge 104+, Firefox 72+, Safari 14.1+, Samsung Internet 20+) also support individual properties for transforms.

Sometimes you need to remove high Unicode characters from a string, so all characters have a code point between 0 and 127. The remaining 7-bit-encoded characters ("Low-ASCII...

...can be transported in most strings where escaping is impossible or would be visually jarrring. Note that transliteration this will change the string. If you need to preserve the exact...

Let's say you have a gem which has the following module: module SuperClient def self.foo 'Foo' end def bar 'Bar' end end For reasons you need to override foo...

...library extensions). Try to avoid it if possible. Add a lib/ext/super_client.rb to your project (see How to organize monkey patches in Ruby on Rails projects) Add the extension, which overrides...

Our preferred way of testing ActiveRecord is to simply create/update/destroy the record and then check if the expected behavior has happened. We used to bend over backwards to avoid touching...

...the database for this. For this we used a lot of stubbing and tricks like it_should_run_callbacks. Today we would rather make a few database queries than have...

bibwild.wordpress.com

...is much more than a lightweight wrapper around Ruby's net/http. In particular: A single HTTPClient instance can re-use persistent connections across threads in a thread-safe way.

...a custom and configurable SSL certificate store (which you probably want to disable by default) Manages cookies Can make asynchronous requests (spins off a thread internally) Allow to set a...

When your Rails application server raises error, Capybara will fail your test when it clears the session after the last step. The effect is a test that passes all steps...

...behavior will help you to detect and fix errors in your application code. However, sometimes your application will explode with an error outside your control. Two examples: A JavaScript library...

makandra dev

Or: How to avoid and refactor spaghetti code Please note that I tried to keep the examples small. The effects of the methods in this card are of course much...

...more significant with real / more complex code. What are the benefits of more modular code? Code is written once but read often (by your future self and other developers who...

makandra dev
rubydoc.info

CarrierWave comes with some RSpec matchers which will make testing more comfortable. Let's say you have an Uploader like this: class MyUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick

...different versions of your uploaded files: version :small do process resize_to_fill: [100, 100] end version :medium do process resize_to_fit: [200, nil] end version :large do

This is a small example on how you can check if your Postgres index can be used by a specific query in you Rails application. For more complex execution plans...

...it might still be a good idea to use the same path of proof. 1. Identify the query your application produces query = User.order(:last_name, :created_at).to_sql

makandra dev

git shortlog -s -n [commit-range] -n, --numbered Sort output according to the number of commits per author -s, --summary Suppress commit descriptions, only provide commit count [commit-range]

...tagname.. for "everything after that tag" Example output for spreewald: 60 Tobias Kraze 12 Henning Koch 7 Dominik Schöler 6 Thomas Eisenbarth 5 Martin Straub 3 Minh Hemmer...

...in development. Note that there are services like badssl.com to test against weird SSL behavior. Self-signed certificates Talking to a host using a self-signed certificate will fail because...

...the certificate can not be verified. >> RestClient.get('https://self-signed.badssl.com/') RestClient::SSLCertificateNotVerified: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed Self-signed certificates...

relishapp.com

In RSpec you can tag examples or example groups with any tags you like simply by saying describe ReportCreator, slow: true do # .. end describe ReportCreator do it 'generates reports', slow...

# ... end end You can then only run examples with these tags. rspec --tag slow rspec -t slow # Using the parallel_tests gem rake "parallel:spec[,,--tag slow]"

relishapp.com

In most projects I know, Cucumber test suite speed is not an issue. Of course, running 350 features takes its time, but still each test for itself is reasonably fast...

...There is nothing you can do to fundamentally speed up such a test (of course, you should be using parallel_tests). However, in projects that go beyond clicking around in...