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

makandra dev
rubydoc.info

CarrierWave comes with some RSpec matchers which will make testing more comfortable. Let's say you have an Uploader like...

...timing in your tests, this requires a lot of work and sustained diligence. A better approach is to use feature flags to only enable these features for the one test...

...is something that we fixed in the code, not the test. The code is better now. However, it took a day to find a bug that no user has seen...

...this issue for PATCH/DELETE. If you make requests yourself, watch out for the following behavior. When you make an AJAX request PATCH /foo and the /foo action redirects to /bar...

SVG files often contain redundant information, like editor metadata or hidden elements. When esbuild handles your static assets, you can...

To do so, call clear_active_connections! before your thread terminates: Thread.new do begin User.first # first database access makes a new connection ensure ActiveRecord::Base.connection_handler.clear_active_connections! # or, in...

With the the Ruby Tempfile class you can create temporary files. Those files only stick around as long as you...

github.com

...that you can also make your matcher chainable, so a test can modifier its behavior. Using chaining you can write a matcher like this: expect(x).to be_a_multiple...

github.com

...even the worst method had time average saving of 00:54 minutes and the best 01:11 minutes. For 25 commits per day this would be an average time saving...

...have not been normalized to the total execution time of the testsuite. A cost benefit analysis could give greater insight into the amortization of costs and about the actual time...

...not waste your time optimizing code where it does not even matter. However, I believe there are some kinds of optimizations you should do right away, because they are either...

...how a library works. This is especially true for all polyfill that fix browser behaviours with all weird kinds of tricks. In your own scripts, don't add event handles...

RSpec allows you to mark a single Example/ExampleGroup so that only this will be run. This is very useful when...

Both knapsack and parallel_tests have the option to split groups by historic execution time. The required logs for this...

When you allow file uploads in your app, a user might upload content that hurts other users. Our primary concern...

"Special object attributes" like frozen, tainted and singleton methods are ignored (like dup) Behavior depends on implementation Hash: returns a deep copy, i.e. referenced objects/values will be deep_duped...

relishapp.com

...test (of course, you should be using parallel_tests). However, in projects that go beyond clicking around in a web GUI and checking results, there might be various measures to...

...use a library like Lodash or Unpoly's up.util that will hide this inconsistency behind functions like _.isBoolean(x) or _.isObject(x). However, I encourage every JavaScript developer to understand...

...JavaScript has a caveat that typeof null returns 'object'. No developer would consider this behavior useful, since you cannot get or set properties with null. Taking into consideration all of...

...many thousand rows. Once your database tables grows to millions of rows, migration performance becomes an issue. We will talk about this in another card. 1. Use the full power...

...updates with it. As a first example, we have Post has_many :followers. For better performance, we want to cache the number of followers in Post#followers_count.

makandra dev

...should help understanding the basic concepts of Ruby's object model and how things behave. Usage of objects in Ruby When working with objects in Ruby, you might think of...

...declare instance methods. This may seem completely counterintuitive. The reason is that class_eval behaves as if you would open the class manually and then write code into it. The...

An introduction to mangling When you minify ("compress", "optimize") your JavaScript for production, the names of your functions and variables...

Here are some popular mistakes when using nested forms: You are using fields_for instead of form.fields_for.

blog.cloudflare.com

...an attack) will fill up our conntrack tables. Decide which option resolves the situation best with minimal impact on production: $ sudo conntrack -D -s 49.12.3.247 # example: delete all conntrack table...

This guide shows how to create an AngularJS application that consumes more and more memory until, eventually, the browser process...

...application does not need to support time zones. Disable them like this: config.time_zone = 'Berlin' # Your local time zone config.active_record.default_timezone = :local config.active_record.time_zone_aware_attributes = false

...s Time will use that. In the example above, it should be in the Berlin zone. Using time zones If your application should support time zones, the default ActiveRecord configuration...

Your objects are now inspected with pretty colors: Note that if your inspection becomes wider than your terminal, IRB will automatically break it across multiple lines, like you probably...