...lazy, i.e. page 2 is only requested after page 1 is done processing in tests, I could write video_service.each_video.to_a.should == [video_1,...] Lazy enumerators It is possible to chain methods on...
...processing library. See here for a list of supported queueing adapters. For development and test it also brings its own queue adapters (async, inline and test). Note: For production use...
...have different adapters for different environments): config.active_job.queue_adapter = :sidekiq To set specific adapters in tests, you can create a spec/support/active_job.rb with: RSpec.configure do |config| config.before(:suite) do ActiveJob::Base.queue_adapter...
to add the Ruby, Rails and RSpec cops to include the unit test 2. Report all existing offenses and exclude them initially To start your Rubocop integration it...
...rubocop --auto-gen-config to create a file that excludes all current violations. Your tests (including the Rubocop spec) should now all be green. Commit theses changes and consider whether...
...is because Redis defaults to at most 16 databases (0 to 15) and running tests in parallel might exceed that (your tests might run on databases 1..n or...
RubyMine has a HTTP Client that can be useful to test web APIs. Just create a .http scratch file an write your request in it. The request can then be...
...it becomes more difficult to optimize this query when joining other records (for my tests PostgreSQL was not able to use the GIN index on the joined table within a...
In tests, it is sometimes useful to create records with specific ids. On PostgreSQL this can cause problems: Usually, PostgreSQL uses an "autoincrement" sequences to provide sequential ids for new...
...cause an SQL error 'duplicate key value violates unique constraint "records_pkey"' Workaround In tests, one workaround would be to simply initialize all sequences with a large value, so that...
...false e.g. to not cancel deploys by accident). Consider setting the interruptible flag for test jobs to reduce the load on your runners like in the following example .gitlab-ci.yml:
...See our libvips with CarrierWave card for: Converting colors to sRGB Stripping color profiles Testing ImageMagick provides a compare utility which can be used to measure color differences between two...
...compare writes it's result to STDERR. A lower score is better, I'd test for a threshold like <= 5. There are different comparison metrics available Link to the profile...
...is very important to double-check results to be avoid unexpected consequences. Can I Test Things Locally With a Database Dump? Unfortunately not. Restoring from a logical database backup, i.e...
...an SQL dump, will not reproduce the error and is not suitable for testing changes, since importing dumps will re-create indexes in the first place.
class Client class_attribute :config def self.configure self.config ||= Configuration.new yield(config) end def test uri = URI.parse(FooClient::Client.config.endpoint) Net::HTTP.get_response(uri) end end end module FooClient class Configuration...
...only see their own user as an option in the same . Remember to add tests for your authorization code. Tip If you have existing dropdowns that accept a restrict list...
Discussion Discuss with your mentor: We don't want to duplicate our integration tests for every screen and user role. Why? Where to put authorization scenarios? In an authorization.feature...
...sharing was completed. Note that this will only work on https pages, so to test it in development, you will have to start your development server with SSL...
...serve requests with the HOST header hacker.xyz You need to take care in your tests, that you reset ActionMailer::Base.default_url_options after e.g. request specs, e.g. spec/support/action_mailer.rb: RSpec.configure do...
...get Jasmine specs running in a Rails project using Webpacker, with the browser based test runner. Should be easily adaptable to a pure Webpack setup. Step 1: Install Jasmine
...Javascript, we will create two additional packs. The first only contains Jasmine and the test runner. The second will contain our normal application code and the specs themselves.
...format before you can use it for plotting: Numo.gnuplot do .. # more plot settings plot "'test.csv'", u: "(hist($#{column_to_plot},width)):(1.0)" s: true, f: true, ...
output "hist.jpg" end
...write any array files into a temporary csv file before passing it Numo.gnuplot: CSV.open('test.csv', 'w') do |csv| random_values.zip(additional_values, absolute_values, other_values).each_with_index do |zipped...
...updating the corresponding mailer preview can be forgotten very easily. Mailer previews can be tested like other code as well and I sometimes add the following tests to test suites...
...want to define a global matcher since you need it only for your specific test, there are two ways to do it: Custom matcher for a single group
...and not_change { Video.count } The above example will call playlist.destroy only once, but test both assertions. Note When you chain multiple Capybara matchers using and, Capybara will retry all matchers...
...to use Edge Rider for new projects, which is being actively maintained and has test coverage for all versions of Rails...
...so that only this will be run. This is very useful when using a test runner like guard. Add the following config to spec/spec_helper.rb: RSpec.configure do |config| # These two settings...
In Paperclip you can use the validates_attachment_file_name macro to test the suffix of a filename: class User < ActiveRecord::Base has_attached_file :avatar validates_attachment...
...this prior art when implementing yours? Checklist: I confirm my design implementation has been tested manually by me adheres to the code style of the project (e.g. BEM) avoids "magic...
...navigates through elements in order (or in an order that makes sense). You can test that by clicking into the page, top/left of the new design, and repeatedly pressing the...
...method to (un)check checkboxes. But there's one problem, if you want to test a custom styled checkbox, which hides its -Tag: The methods cannot (un)check checkboxes without...
...Some label', allow_label_click: true). Solution 2 Make hidden inputs visible in integration tests via data-environment. Depending on your CSS framework you also need to adjust the z...