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

...developer stories. Non-developer stories Non-developer stories should be clearly marked. They usually belong to the PM (or maybe people from the operations team). Those story can take all...

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...

...to add additional fields to keep track of all localized versions, e.g. Article#name becomes Article#name_de and Article#name_en and Article#name returns the variant in the...

...at the requests's IP or Accept-Language HTTP header. Note that even the best default never replaces a language switcher. Routes and URLs You might want to localize route...

makandra dev

...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...

...that does net yet exist Sometimes it can be easier to find out the best API of a class by using that code first from the place that will be...

developer.mozilla.org

...up-clickable] attribute to make elements interactive. Elements with this attribute gain the following behavior: The element is given an [role=link] attribute so screen readers announce it as link...

Rails partials have a lot of "hidden" features and this card describes some non-obvious usages of Rails Partials.

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

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...

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...

...Cumulative Layout Shift score should be good' do # Cumulative Layout Shift seems to be better in tests than in reality, so # we use a lower value than the official "good...

...JavaScript every day, even when our backend code uses another language. While we've become quite adept with JavaScript at a basic level, I think many of us lack a...

Every function may use this, even if the function does not belong to the object. The default value of this is the global object (window in browsers...

"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...

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...