You can use RSpec::Matchers.define_negated_matcher to define a negated version of an existing matcher. This is particularly useful...

...intensive for large files Other ways to solve this problem Other solutions might work better and make more sense depending on what you are trying to achieve. These alternatives could...

In a web application you sometimes have tasks that can not be processed during a request but need to go...

When changing the glibc version, it's possible that the upgrade also includes changes to how locales work.

The nokogiri gem provides different packages for several platforms. Each platform-specific variant ships pre-built binaries of libxml2, e.g...

For Rails models where only one of multiple attributes may be filled out at the same time, there is no...

When you use Sentry to monitor exceptions, an important feature is Sentry's error grouping mechanism. It will aggregate similar...

Building application assets with esbuild is the new way to do it, and it's great, especially in combination with...

When you repeat complex assertions in your tests multiple times, it might be a good idea to extract a custom...

I recently enjoyed debugging a Cucumber step that tried to be retryable using a patiently block: Then /^"([^"]*)" should( not)? be...

makandra Curriculum

...diverge from remote code. These exercises emulate such situations. You are free to apply better naming conventions to the requested commit messages, they are only kept short here to fit...

docs.gitlab.com

The owner of a scheduled CI/CD pipeline in GitLab will always be notified if the pipeline fails. Follow these steps...

IRB 1.2 (shipped with Ruby 2.7, but works on 2.5+) brings pretty syntax highlighting and multiline cursor navigation. However, pasting...

Rails' url_for is useful for generating routes from a Hash, but can lead to an open redirect vulnerability.

...shared_examples_for can have parameters. You can simply hand over arguments from it_behaves_like: shared_examples_for 'string equaling another string' do |expected_string| it 'is equal to...

...subject).to eq(expected_string) end end describe 'some string' do subject { 'foo' } it_behaves_like 'string equaling another string', 'foo' end RSpec 1 Use it_should_act_like from...

Learn to store attachments in a way that is accessible by authorized users only Learn to prevent users from...

...between added? and of_kind? While added? might feel more natural to use, it behaves differently than of_kind? because it also compares options from the validation error. of_kind...

While it might be tempting to set it per project (other devs might benefit from it), you need to do it each time for every project "pollute" a project...

When two classes implement the same behavior (methods, callbacks, etc.), you should extract that behavior into a trait or module. This card describes how to test that extracted behavior without...

...repeating yourself. Note that the examples below use Modularity traits to extract shared behavior. This is simply because we like to do it that way at makandra. The same techniques...

makandra dev

...changes you make to the database will be rolled back on exit. Warning Changes beyond the database (deleting files, sending emails, etc) cannot be rolled back...

When ending a Selenium test Capybara resets the browser state by closing the tab, clearing cookies, localStorage, etc.

...Middleman brings Haml, Sass, helpers etc. However, it can be configured to do even better. This card is a list of improvement hints for a Rails developer. Gemfile

...helpers in a helpers {...

...} block. However, this does not scale very well. You're best off creating a /helpers directory and putting helper files there just like you know it...

Important wkhtmltopdf is deprecated and shouldn't be used anymore. Please consider switching to another tool We can install wkhtmltopdf...

class Post < ActiveRecord::Base has_one :attachment end # attachment.rb class Attachment < ActiveRecord::Base belongs_to :post validates :title, presence: true end Issue When creating a post with an invalid...