...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...
...If you are unsure if you applied this technique correctly, here is a simple test: Delete all files from app/models/* and run your migration. If it completes successfully, you are...
If you need to test interaction with a remote API, check out the VCR gem as an alternative to Webmock or stubbing hell. The idea behind VCR is that is...
...HTTP requests and logs the interaction in a .yml file. When you run the test again, requests and responses are stubbed from the log and the test can run offline...
...setInterval and setTimeout calls from tabs that are currently in the background. You can test it yourself by running the test below and change to a different...
...tab during its runtime. The expected runtime drastically increases in Chrome, Firefox and Safari: https://testbed.nicon.nl/timeouttest/ See also: Stop animations and network polling when the document tab isn't...
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...
...k] + (f * (values_sorted[k + 1] - values_sorted[k])) end benchmarks = [ %(User.where('name ILIKE ?', '%test%').first), %(User.where('email ILIKE ?', '%test%').first), ] measurements = benchmarks.index_with do |_benchmark| [] end benchmarks.each do |benchmark...
...error), the CI job will pass MINOR: With our current setup, we lose the test coverage of the main run A fix for the passing CI despite syntax error could...
- 'if [[ $main_cucumber_run_passed =~ false ]]; then (echo -e "\033[0;33mRerunning failed tests:\033[0m"; bundle exec cucumber @tmp/failing_features.txt --strict --tags "not @real-stripe-requests" -f pretty -f...
...change this attribute to hold a list of URLs, and need to adjust all tests. Our goal is to convert the url "..." to the urls ["..."] here. Open find and replace...
...on VCR and WebMock to prevent any real network connection when running our unit tests. This is not entirely true: They are both limited to a set of HTTP libraries...
...OpenURI#open_uri are not mocked and will trigger real network requests even in tests. This might bite you e.g. in older versions of CarrierWave with remote file URLs.
Sidekiq.configure_client do |config| if ENV['RAILS_ENV'] == 'development' || ENV['RAILS_ENV'] == 'test' stdout_logger = ActiveSupport::Logger.new(STDOUT) file_logger = ActiveSupport::Logger.new("log/sidekiq_#{ENV['RAILS_ENV']}.log")
end Sidekiq.configure_server do |config| if ENV['RAILS_ENV'] == 'development' || ENV['RAILS_ENV'] == 'test' stdout_logger = ActiveSupport::Logger.new(STDOUT) file_logger = ActiveSupport::Logger.new("log/sidekiq_#{ENV['RAILS_ENV']}.log")
Whenever you have to deal with randomness in a jasmine test there are some spy strategies to help you out! Let's say we have a method Random.shuffle(array) to...
...shuffles the array', () => { spyOn(Random, 'shuffle').and.returnValue([3, 2, 1]) array = [1, 2, 3] testedClass = new testedClass(array) expect(Random.shuffle).toHaveBeenCalled() expect(testedClass.array).toEqual([3, 2, 1]) })
...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...
...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...
...a commit between the given good and bad commits. You could then run a test (*) revealing the problem or inspect the issue manually. Keep in mind that you may need...
...you are done bisecting you can go back with git bisect reset (*) Such a test would need to live outside the repository as you are constantly switching your working directory...
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...
...supports a few helpers for development. In case you notice errors in your Cucumber tests, you might want to use one of them to better understand the underlying background of...
...s README, but is duplicated to this card to allow repeating. Then console Pauses test execution and opens an IRB shell with current context. Does not halt the application-under...
When an AJAX request raises an exception on the server, Rails will show a minimal error page with only basic...
...might look as follows: shared: &shared email: info@example.com google_analytics: container: UA-123456-12 test: <<: *shared development: <<: *shared production: <<: *shared email: production@example.com Keys under the shared namespace are shared between...
...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.
...behaviors of the built-in controls, as well as necessary accessibility requirements, and provide test suites to ensure compatibility. We’ll also implement polyfills for our extensible web UI controls...
...we expect that these design systems will benefit from Open UI’s specifications and test suites. Long term, we hope that Open UI will establish a standard process for developing...
...options to disable password leak detection and suppress the warning. Problem When running Selenium tests with recent versions of Chrome and Chromedriver (e.g., version 136+), entering “unsafe” (weak or reused...
"This password has appeared in a data breach…" This alert can break automated test runs, especially in CI/CD pipelines. Solution You can disable Chrome’s password leak detection to...
Using RSpec matchers One rule of thumb I try to follow in capybara tests is using capybara matchers and not plain rspec matchers. One example: visit(some_page)
...current JavaScript VM: window.addEventListener('error', function(event) { console.log("Got an uncaught error: ", event.error) }) Tip Testing tools like Jasmine might also listen to the error event and fail your test if...