...Our first implementation might look like this: def group(content) " #{content} " end We run tests and realize that our helper escapes too much. Content appears like this:
baz: "example" We can now load it as usual, but pass freeze: true. >> test = YAML.safe_load_file('example.yml', freeze: true) => {"message"=>["hello", "universe"], "foo"=>{"bar"=>{"baz"=>"example"}}}
...itself is frozen: >> test.frozen? => true And no matter how deep you dig, everything inside that Hash is also frozen. >> test['message'].frozen? => true >> test['foo']['bar']['baz'].frozen? => true
...single feature/spec: Just paste the reference into your terminal (you need to "unmark" the test directories "as test sources root" to get a path relative to the project root).
...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...
...default for building is production. Activate an environment with -e staging or --environment=staging. Test for environments like this: environment? :staging Testing Complex "static" pages might need some integration testing...
...To employ Cucumber with Spreewald and Selenium, add these gems to the Gemfile: group :test do gem 'cucumber' gem 'spreewald' gem 'capybara' gem 'selenium-webdriver' # Only for running tests in...
Sometimes you just want to have a small web server that serves files to test something. Serve the current directory On Ruby 1.9.2+ you can do the following ("." for current...
Suggestion: Upgrade to a newer version before doing the Bootstrap upgrade and test if everything still works as expected. Here is a migration guide for Select2
...navigation on your own. Tip: Add a feature for your navigation bar beforehand and test links and their highlighting (don't forget dropdown submenus!). After upgrading to Bootstrap 4 you...
When an AJAX request raises an exception on the server, Rails will show a minimal error page with only basic...
There are a few tools to combat the dreaded n+1 queries. The bullet gem notifies you of missing eager...
...at least 2.2.0. Set a cookie with options secure: true, samesite: 'strict|lax|none'. Testing in advance To test the effect of the new Chrome behavior on your site or...
In this article, we’ll look at what side effects are, why they are problematic despite being necessary, and how...
...app such as PHP, Perl, Java / JEE, etc. I like using cucumber for functional testing so I put together this project structure to use as a starting point for testing...
jqueryElement.is(':checked')
...this article we’ve listed 7 fresh and simple tools for cross-browser compatibility testing, tools that actually make this stuff pretty easy. Not only that, but every single one...
Celerity is a JRuby wrapper around HtmlUnit – a headless Java browser with JavaScript support. It provides a simple API for...
What do we expect from the custom finder? We expect that it should find assets A, B, C and should...
...Just increase the last index when proceeding to the next example. Handy when the test file frequently changes, e.g. because before blocks are modified. The line number approach would easily...
...search results for example to the /app/ directory can be helpful to exclude all test files. The probably easiest way to start this kind of search is from the project...
from /usr/bin/puppet:5:in ` ' Configure a different environment in hiera For some longer testing of feature branches the environment setting can be set in hiera. All changes from the...
# At this point we want to stop in the debugger for all following tests, when the :lock call runs into the after_save $debug = true expect { user.lock }.to change...
...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...