...this requires the PP class from the pp gem. It is loaded in any Rails app already, but for plain Ruby you may need to require it.
...issues in specific scenarios. Why does this matter? Mocked time in tests Consider a Rails application where you use the remember_me feature of Clearance for authentication. The cookie for...
This is quite an edge case, and appears like a bug in Rails (4.2.6) to me. Update: This is now documented on Edgeguides Ruby on Rails: If you set the...
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...
position: relative left: -50% float: left .clear clear: both Together with this helper: # Rails 3 def center_float(&block) concat( content_tag(:div, :class => 'center_float_outer_container') do...
...tag(:div, :class => 'center_float', &block) end end + content_tag(:div, :class => 'clear') ) end # Rails 2 def center_float(&block) html = "".html_safe html << content_tag(:div, :class => 'center_float...
We recently migrated a Rails application from yarn to npm. We decided to go this step instead of upgrading to > Yarn 2.0 to reduce the number of dependencies in our...
...your yarn.lock (after the first npm install you can relax the constraints again). jsbundling-rails supports NPM since v1.2.2. geordi supports package managers other than yarn since v11.1.0...
...are libraries like morphdom (as used by Phoenix Liveviews) or idiomorph (as used by Rails' Turbo). It lets you write morphdom(node, newHtml) or Idiomorph.morph(node, newHtml) which will try...
...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...
...some cases, a viable workaround is to turn your images into inline attachments. Note Rails provides a simple mechanism to achieve this: https://guides.rubyonrails.org/action_mailer_basics.html#making-inline-attachments This documentation makes it look...
...It is recommended to watch for a feature flag, see below. return version unless Rails.config.feature_inline_email_images # `attachments` is provided by Rails, see the linked documentation above # URLs should...
...If you trigger a COUNT query for an association of an an unsaved record, Rails will try to load all children where the foreign key IS NULL. This is not...
...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...
The linked article suggests an interesting way to speed up tests of Rails + Postgres apps: PostgreSQL allows the creation of “unlogged” tables, which do not record data in the PostgreSQL...
...the project might need to re-recreate their test databases like so: bundle exec rails parallel:drop && bundle exec rails parallel:prepare
...they won't change their mind. [1] We are not talking about the the Rails session hash here, although it is by default backed by a cookie without expiration...
...end-to-end test for every small requirement. After we integrated Jasmine into a Rails app we often add an E2E test that opens that Jasmine runner and expects all...
...posts"."user_id" = "users"."id" WHERE (posts.id > 10) Using includes usually works nicely, but Rails will apply some magic, as mentioned at the beginning of this card. This is subject...
...building it yourself Also see the chapter "Owning your Stack" in the book Growing Rails Applications in Practice. Services Open-Source Maturity & Maintenance Certification Rubygems
...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...
RSpec Rails can automatically mix in different behaviors to your tests based on their type tag, for example enabling you to call get and post in specs with the tag...
...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...
...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...
...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...
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
...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...