When ending a Selenium test Capybara resets the browser state by closing the tab, clearing cookies, localStorage, etc. It may be a good idea to wait for all in-flight...

...AJAX requests to finish before ending a scenario: You may have client-side JavaScript that freaks out when the tab closure kills their pending requests. If that JavaScript opens an...

makandra dev

min-width is known as a CSS property that can be set to define a least width for an element. Surprisingly, it can also be used to set something that...

...it is more like "auto". This can make block elements take up much more space than desired, even stretching their container beyond the screen edge on small screens.

...in licensing, we cannot provide Elasticsearch versions >= 8.0. Version 7.17.x will reach EOL status with the release of Elasticsearch version 9. We have decided to use OpenSearch as a...

...replacement, since it is a fork of Elasticsearch version 7.10.2, still running under the previous licensing model and wire-compatible. A more detailed reasoning can be found on their website...

...always is to prevent long-running queries in the first place, automatic timeouts can serve as a safety net to terminate problematic queries automatically if a set time limit is...

...statement due to statement timeout (PG::QueryCanceled)). If multiple SQL statements appear in a single simple-query message, the timeout is applied to each statement separately. Set the timeout globally...

When you find similar groups of expect calls in your tests, you can improve readability by extracting the group into its own matcher. RSpec makes this easy by allowing matchers...

We can extract the repeated matcher chains into a custom matcher called be_shouting: expect(foo).to be_shouting expect(bar).to be_shouting Instead of re-implementing the...

makandra dev

When you're using feature branches, they will stack up if you don't delete them after the merge to master. Here's how to tidy them up. Delete feature...

...Find already-merged branches by running # On branch master git branch --merged You may safely delete each of the listed branches, because they point to commits that are contained in...

When a user shares your content, a snippet with title, image, link and description appears in her timeline. By default social networks will use the window title, the first image...

...the current URL and some random text snippet for this purpose. This is often not what you want. Luckily Facebook, Twitter, etc. lets you control how your content appears in...

Applications often show or hide elements based on viewport dimensions, or may have components that behave differently (like mobile vs desktop navigation menus). Since you want your integration tests to...

...behave consistently, you want to set a specific size for your tests' browser windows. Using WebDriver options / Chrome device metrics For Google Chrome, the preferred way is setting "device metrics...

chrisboakes.com

Debouncing a method call delays its execution until after a specified time has passed. If it's called again before that time has passed, its execution is delayed again.

...would be run more often than it needs to. One example for that are scroll event handlers in JavaScript: You want to react to a user scrolling, but it's...

When you create a temporary file (e.g. to store a generated Excel sheet) and try to send it to the browser from a controller, it won't work by default...

...this controller action: class FoosController < ApplicationController def download file = Tempfile.new('foo') file.puts 'foo' file.close send_file file.path end end Accessing this controller action will usually raise a 404 not found...

...for file uploads. CarrierWave has an integrated processing mechanism for different file versions with support for ImageMagick through CarrierWave::MiniMagick (which requires the mini_magick gem). In case your processing...

...runs into an error, CarrierWave will just swallow it and rethrow an error with a very generic message like Processing failed. Maybe it is not an image? which does not...

...upgrade tasks according to its actual value. Consider to create and periodically maintain a summary, which helps you and your team in the decision which refactoring task should be taken...

Estimated Efforts Visible customer value Customer value explained Developer value Developer value explained Short title for the task Score from 0-5 Score from 0-5 Explanation

makandra dev

Follow the installation guidelines at https://mise.jdx.dev/getting-started.html. Remove rbenv configuration Search for rbenv config in .bashrc and .profile and remove it: eval "$(rbenv init - bash)"

...rbenv config in .profile and remove it: source /home/$user/.rbenvrc Remove nvm configuration Search for nvm config in .bashrc and remove it: export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM...

...posts; if you use pagination the queries will be more complicated, but the point still stands. Looks harmless enough? It is not. The problem ActiveRecord will rewrite this into a...

...query using LEFT JOINs which looks something like this: SELECT "blog_posts".*, "comments".*, "attachments".* FROM "blog_posts" LEFT OUTER JOIN "comments" ON "comments"."blog_post_id" = "blog_posts"."id"

Because your examples should not change global state, you should not need to care about the order in which RSpec processes your .rb files. However, in some cases you might...

...rb files in alphabetical order of their file paths by default (or when you specify --order defined). You run tests in random order by using --order random on the command...

...with two matchers that test for equality. The first is toBe: expect(first).toBe(second) toBe passes when first === second. Unfortunately this is useless for non-primitive values because JavaScript...

...is a horrible language. However, Jasmine comes with another matcher toEqual: expect(first).toEqual(second) This matcher behaves as a human would expect for types like the following: Arrays

This card is a short summary on different ways of assigning multiple attributes to an instance of a class. Using positional parameters Using parameters is the default when assigning attributes...

...It works good for a small number of attributes, but becomes more difficult to read when using multiple attributes. Example: class User def initialize(salutation, first_name, last_name, street...

...block evaluates to true. first_post_with_image = posts.find do |post| post.image end However, sometimes it's not the item you're interested in, but some value depening on it...

...image).find(&:present?).url If the mapping is a costly operation or has undesirable side effects, you need to do it in a single iteration instead. Single iteration solution with...

...pretty_print method As an example, consider the following class. class MyClass # ... def inspect "#<#{self.class} attr1: #{attr1.inspect}, attr2: #{attr2.inspect}>" end end Instances of that class will inspect like #<MyClass attr1...

...Alice", attr2: "Bob">, but IRB will apply a single color (green) for everything. That is because MyClass implements only inspect. If it were to implement pretty_print, IRB would use...

...notice that the records you create are not deleted and will bleed into your specs the next time you run them. You probably have DatabaseCleaner configured to take care of...

...not bloating your test database with old records: RSpec.configure do |config| config.before(:suite) do DatabaseCleaner.clean_with(:deletion) end config.before(:each) do DatabaseCleaner.strategy = :transaction end config.before(:each, transaction: false) do DatabaseCleaner.strategy...

...can use ETags to allow clients to use cached responses, if your application would send the same contents as before. Besides what "actually" defines your response's contents, your application...

...probably also considers "global" conditions, like which user is signed in: class ApplicationController < ActionController::Base etag { current_user&.id } etag { current_user&.updated_at } end Under the hood, Rails generates...

Here are a few common patterns that will probably lead to flaky specs. If you notice them in your specs, please make sure that you have not introduced a flaky...

Using RSpec matchers One rule of thumb I try to follow in capybara tests is using capybara matchers and not plain rspec matchers. One example: visit(some_page)

...with a nice way to grep through your project's files: The finder (ctrl + shift + f). Don't be discouraged about the notice 100+ matches in n+ files if your...

...searched keyword is too general or widely used in your project. RubyMine comes with a few ways to narrow down the resulting list, don't hesitate to apply those filters...

github.com

...Mocking the time zone You can't really change the local time zone of the Selenium-controlled browser. What you can do is change the time zone of the process...

...setting this from an individual test, since you don't know whether or not the Selenium-controlled browser has already launched. Note that we have only tested this with a...