When you repeat complex assertions in your tests multiple times, it might be a good idea to extract a custom...
Resources RubyGuides: Mastering Ruby Regular Expressions Using regular expressions in JavaScript Testing regular expressions visually Regular Expressions: Quantifier modes...
This cards describes an example with a Github Client on how to keep your Rails application more maintainable by extracting...
Spammers have started abusing other application to send their spam. This works like this: The application has some form that...
The nokogiri gem provides different packages for several platforms. Each platform-specific variant ships pre-built binaries of libxml2, e.g...
...t raise an error. Instead, rescue the exception type that you are expecting: @user = begin User.power_find(something) rescue ActiveRecord::RecordNotFound User.new end This also applies to the quite popular...
...nil" and "full" rescue blocks that don't explicitly rescue away an error class: begin # do stuff rescue # rescues any StandardError end Note that there may be cases where you...
When you use Sentry to monitor exceptions, an important feature is Sentry's error grouping mechanism. It will aggregate similar...
...change the rendered html, some variation of @message.content.body.to_rendered_html_with_layout Changing the behavior of the editor You may want to add some functionality to the editor or remove...
...addEventListener("trix-action-invoke", event => { const { editor } = event.target if (event.actionName === "x-horizontal-rule") { // ... } // Add behavior for the other buttons // ... }) Check the Trix README to check what you can do.
...John Doe <user@example.com> Date: Thu Dec 23 13:37:00 2010 +0100 make everything better Once you are done bisecting you can go back with git bisect reset
...t have control of. Solutions Don't log SQL queries. This is the default behavior of rails but can be changed in the config/environment/production.rb file: config.log_level should not be...
...would allow to detect the end of windows size changing process. Capybara provides a better way to manipulate the browser window which you should use instead: page.current_window.resize_to. Good: Capybara...
...as isolated (more unit like) tests, one might want to test some cookie dependent behavior as a request, helper or model spec too. Since the rspec documentation on testing cookies...
...that into a class to DRY up your code and write solid unit tests. Beware that your class will not be able to read the cookies, since they are only...
...Rails docs, e.g. Array#to_sentence String#dasherize Hash#slice Object#presence Libraries The best way to learn about a Ruby gem, Javascript libary, etc. is often to find the...
http://unpoly.com https://lodash.com/ https://fontawesome.com/icons Web Platform (HTML, JavaScript, CSS) The best reference to look up information on HTML tags, JavaScript features or CSS properties is the...
Some tasks in a web application are better not done live when a user request a page, but in the background. Examples are longer running tasks tasks that are not...
...been accepted for 7 days. Learn about Sidekiq Read Sidekiq's Readme Read Sidekiq best practices Read Sidekiq Error Handling Understand how to schedule jobs, and work them off
When ending a Selenium test Capybara resets the browser state by closing the tab, clearing cookies, localStorage, etc.
...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...
This card will show you how to use git rebase --onto without confusion. Use case: You've got two feature...
Important wkhtmltopdf is deprecated and shouldn't be used anymore. Please consider switching to another tool We can install wkhtmltopdf...
In a web application you sometimes have tasks that can not be processed during a request but need to go...
I encountered a unlucky behavior of byebug 11.1.3 (the most recent version at time of writing) when using it with Rails 6 and it's new autoloading component, zeitwerk. There...
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...
When changing the glibc version, it's possible that the upgrade also includes changes to how locales work.
...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...
Hint This applies only to distributions based on Debian. Requirement You need to setup the PostgreSQL Apt Repository first.