Back when Steak was first released, Capybara didn’t have any of the nice RSpec helpers it does now. A lot has changed since. Besides the helpers, it got its...
...own RSpec acceptance testing DSL recently, essentially eating Steak’s functionality and turning it into a complete acceptance testing solution (on top of RSpec...
An alternative could be to use the MySQL Docker image which is still updated for 5.6. Ubuntu 16.04 only provides packages for MySQL 5.7 which has a range...
...list of official APT repositories for MySQL 5.6, but those repositories do not yet support Ubuntu 16.04. However, the 15.10 repos will work for 16.04. I would not recommend to...
We recommend configuring Selenium's unhandled prompt behavior to { default: 'ignore' }. When running tests in a real browser, we use Selenium. Each browser is controlled by a specific...
...driver, e.g. Selenium::WebDriver::Chrome for Chrome. There is one quirk to all drivers (at least those following the W3C webdriver spec) that can be impractical: When any user prompt...
...have a README that gives the reader a quick overview of the project. Its size will vary as projects differ in complexity, but there should always be some introductory prose...
...for a developer to read when starting on it. Purpose That's already the main purpose of a project README: Give a new developer a quick overview of the project...
When you do something like this in your code: def var_value @var ||= some_expensive_calculation end Be aware that it will run some_expensive_calculation every time you call...
This illustrates the problem: def some_expensive_calculation puts "i am off shopping bits!" @some_expensive_calculations_result end When you set @some_expensive_calculations_result to nil...
When your Solr seems to be started properly (a process is running with the correct data directory) but never responds properly and replies (via the API or web interface) with...
... check if Solr's log directory is actually writable for the user running it...
Dealing with exceptions in a Rails application is (surprisingly) complex. There are multiple configurations and methods that influence how exceptions are actually handled. This card explains some of the interactions...
...is raised in your app you want the following things to be true: Your server should not crash (your Ruby process should continue to run) Your user should receive an...
...chat messages, and it will load them into its context for analysis. Note For scanned pages that may be sideways or upside down, auto-rotate them first. Autocrop assumes upright...
...px so text remains readable. To convert PDF pages to scaled down images: pdftoppm -png -scale-to 1500 input.pdf output_prefix Convert images to thumbnails: vipsthumbnail input.png --size 1500x1500 -o...
...example, the configuration for SASS files looks like this: { test: /\.(scss|sass)$/i, use: [ { loader: 'style-loader', options: {...
{ loader: 'css-loader', options: {...
{ loader: 'postcss-loader', options: {...
{ loader: 'sass-loader', options...
...loaders (which are usually npm modules) are run on it in reverse order. First, the sass-loader converts SASS to regular CSS. Then, the postcss-loader uses PostCSS to postprocess...
...response includes caching headers like Expires or Cache-Control, their validity depends on the server's Date header if present. Otherwise, the browser uses its local time. This can lead...
...for authentication. The cookie for this feature might include an Expires attribute, specifying its validity: Set-Cookie: remember_me=abc123; Expires=Fri, 15 Dec 2023 12:00:00 GMT
...an error in the User#name method) you will end up with a confusing stacktrace that looks like you have an error in your render call. If this happens to...
...you, temporarily remove the annotation to see the correct error. Niklas opened an issue in rails, a fix is merged and will arrive in Rails >7.2.2.2 and...
...be confused with truemail.io) allows validating email addresses, e.g. when users enter them into a sign-up form. It runs inside your application and does not depend on an external...
...set config.not_rfc_mx_lookup_flow = true. Validation methods explained Regex validation (1) is pretty straight-forward and basically "free" since you're not making and network connections. SMTP validation...
...looking for a functionality in RubyMine but don't know or remember its keyboard shortcut or which menu it is located in?\ Hit Ctrl+Shift+A. This will bring up...
...the result from the list to run it. The list of results will also show you any assigned keyboard shortcuts...
You can use gem list to list all gems available from a remote gem server: gem list -r --clear-sources -s 'https://user:password@gemserver.tld/' This is useful to debug cases...
...where Bundler complains of a gem existing in more than one gem source...
Since Rails 5, domain models inherit from ApplicationRecord by default. This is the place to put code that should be available in all your application's models.
...can explain the difference between unit tests and end-to-end tests, with the strengths and costs of each, and why we rarely test controllers or views in isolation.
...path, unit tests for the edge cases. You can write unit tests with RSpec, structured by the behavior under test. You can write end-to-end tests that drive the...
...method for controllers. The most common way is to pass an ActiveRecord instance or scope, and fresh_when will set fitting E-Tag and Last-Modified headers for you. For...
...scopes, an extra query is sent to the database. fresh_when @users If you do not want that magic to happen, e.g. because your scope is expensive to resolve, you...
...to load fast it's recommended to optimize images. Ideally an image's file size should be as small as possible while still being of decent quality. This card demonstrates...
...tools for image optimization Use identify to fetch information about pictures. convert can change size/quality and strip meta information. Both commands are supplied by ImageMagick. $ identify in.jpg in.jpg JPEG 294x440...
RSpec supports a one-liner syntax for setting an expectation on the subject: describe Array do describe "when first created" do it { should be_empty } end end The example description...
...it should be empty" will be defined automatically. With RSpec 3's expect-based syntax you use it_is_expected instead: describe Array do describe "when first created" do
...errors.add_to_base('failed') if bad_things? end end ^ # app/models/foo.rb require 'user' class Foo # something happens here end Now, when your environment is booted, Rails will automatically load your models...
...our example, when Foo gets loaded, it will require the User class itself again. Since Ruby 1.8 identifies required files by the string you used (as you alread know), this...
The bin/webpack-dev-server command is not as smart as e.g. rails server, where it shows the proper fix within the error message. $ bin/webpack-dev-server yarn run v1.19.1 error Command "webpack-dev-server...
...this matter, as the image rendering depends on multiple factors. At least the operation system, browser or image viewer software and monitor influence the resulting image colors on your screen...
...possibility to upload images, they will most likely contain tons of EXIF metadata and sometimes exotic color profiles like eciRGB. We want to get rid of the metadata, as it...
The link contains a simple shell script to push a cleanup policy for gitlab repositories in a group. Please mind that this will overwrite the configuration for all the repositories...
...with the given settings...
This StackOverflow question about nested function definitions in Ruby imparts a good understanding of Ruby's def...