job_id: job.job_id, executions: job.executions, queue_name: job.queue_name, url: url, }, ) end Rails.application.configure do # Also capture errors not handled by Active Job config.good_job.on_thread_error = ExceptionNotifier.method(:notify_exception...

The goal is to 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.

...is still true', () => { expect(true).toBe(true) }) }) Step 3: Add a /jasmine page in Rails # config/routes.rb Rails.application.routes.draw do # ... if Rails.env.development? || Rails.env.test? get 'jasmine', to: 'jasmine#index' end end # app/controllers/jasmine_controller.rb

makandra dev
relishapp.com

...are verified. Note that this is enabled by default when you are using rspec-rails along with verifying doubles. So if you really need to verify some dynamically defined methods...

...at self.class.ancestors. For example: config.before do # stuff that_fancy_method if is_a? Spec::Rails::Example::ControllerExampleGroup # more stuff end Find out if you are in a spec that knows...

...s request and response, like helper specs or controller specs: if is_a? Spec::Rails::Example::FunctionalExampleGroup that_fancy_request_thing end Note that you should not check via something...

When your Rails application offers downloading a bunch of files as ZIP archive, you basically have two options: Write a ZIP file to disk and send it as a download...

...Add zip_tricks to your Gemfile and bundle install. In your controller, include ZipTricks::RailsStreaming. You can then use the zip_tricks_stream method in controller actions to generated your...

...a lib/ext/super_client.rb to your project (see How to organize monkey patches in Ruby on Rails projects) Add the extension, which overrides both methods (prepend is available since Ruby >=2)

When your Rails application server raises error, Capybara will fail your test when it clears the session after the last step. The effect is a test that passes all steps...

Learn about Method#source_location. Look up a method like save! in the Rails API docs. The result should have a link to the source location on GitHub.

...monkey patches. When you add or change an initializer you need to restart your Rails server or console for the changes to be picked up. Only changes in app are...

...does not apply to your "Background" steps How to set up database_cleaner for Rails with Cucumber and RSpec Before all in database transactions will fail

...is to to require all files in a specific diretory, using something like Dir.glob(Rails.root.join('lib/ext/**/*.rb')).each do |filename| require filename end However, this causes files to be required...

...behavior on different machines which are hard to debug. Simply add a .sort: Dir.glob(Rails.root.join('lib/ext/**/*.rb')).sort.each do |filename| require filename end Ruby 3 Ruby 3 Dir class sorts...

...resources. The spec looks very similar to how one would build an API with Rails and uses similar patterns. Even if you don't plan on supporting the whole spec...

relishapp.com

...for example could be sped up more than 4 times by reusing a cached Rails application, and the tests for a video player we built could also be sped up...

github.com

...This is arguably a good idea. As a workaround, use stub_const in your Rails specs like this: stub_const "#{SomeClass}::CONST", 'test' This will invoke Rails' autoloading and fix...

...not rendered in controller specs. If you need it to happen, use: RSpec 1 (Rails 2): integrate_views RSpec 2 (Rails 3): render_views Note that you can't use...

...a command on all servers. bundle exec cap production app:run cmd='zgrep -P "..." RAILS_ROOT/log/production.log' Code # lib/capistrano/tasks/app.rake namespace :app do # Use e.g. to grep logs on all servers:

...cap production app:run_cmd cmd='zgrep -P "..." RAILS_ROOT/log/production.log' # # * Use RAILS_ROOT as a placeholder for the remote Rails root directory. # * Append ` || test $? =1;` to grep calls in order...

makandra Curriculum

Read (or re-read) the following chapters from our book Growing Rails Applications in Practice (it’s in our library): New rules for Rails Beautiful controllers Relearning ActiveRecord

...your jQuery version if desired. Here is an example how this might look: { "dependencies": { "@rails/webpacker": "4.x", "bootstrap-datepicker": "1.8.0", "bootstrap-sass": "3.4.1", "font-awesome": "4.7.x", "jquery": "2.2.4",

...be done by compiling the packs for production and search for a working example: RAILS_ENV=production bundle exec rake assets:precompile. Remember to remove the folder public/packs afterwards...

...prevent this, you need to add ->{ uniq } as second argument to has_many (below Rails 4 it is a simple option: has_many :xyz, :uniq => true). Example

When deleting a record in your Rails app, Carrierwave automatically takes care of removing all associated files. However, the file's container directory will not be removed automatically. If you...

...will see less noise in your test output: if RSpec.configuration.files_to_run.count > 5 require "simplecov" SimpleCov.start 'rails' end See also How to use Simplecov to find untested code in a Rails project...

There is a way to use multiple databases in Rails. You may have asked yourself how you're able to keep your test databases clean, if you're running multiple...

...records to check if the migration works properly with those. after_initialize :readonly!, unless: -> { Rails.env.test? } end When defining multiple adapters in your database.yml, Rails needs to decide which one to...

...have to either: Sort both the query and database content. If you're on Rails 7.1 you can use the new normalizes macro for this. This solution would still use...

...model. Prefer to use a form model like User::RegistrationForm. Read our book Growing Rails Applications in Practice for details. Here is a test for the User model that automatically...

...load the dump successfully, i.e. restore data for all the tables it contained (including Rails' schema_migrations). However, it would not remove any extra tables that were not part of...