...data-environment=<%= Rails.env %>> Now you can say in a piece of Javascript: if (document.documentElement.dataset.environment == 'test') { // Code that should happen in Selenium tests } else { // Code that should happen for other environments...

...Or in your CSS / Sass: html[data-environment="test"] { * { text-transform: none !important; } } See also Cucumber: Detect if the current Capybara driver supports Javascript

github.com

The issue: You are using stub_const to change a constant value for your test. stub_const "SomeClass::CONST", 'test' All of a sudden, tests fail with undefined method 'some...

...workaround, use stub_const in your Rails specs like this: stub_const "#{SomeClass}::CONST", 'test' This will invoke Rails' autoloading and fix RSpec's behavior for you...

This rule needs to be adapted to your setup and needs to be tested before it's activated. Activating lifecycle rules can instantly delete images from registries.

"tagStatus": "tagged", "countType": "sinceImagePushed", "countUnit": "days", "countNumber": 10 }, "action": { "type": "expire" } } ] } Careful when testing Testing these rules is a little confusing because of the wording in the AWS console...

...and expected constants are resolved: class_name = params[:type].presence_in(%w[User Post Test]) if class_name class_name.safe_constantize.new # either User, Post or Test else Rails.logger.error "This should not happen...

makandra Curriculum

...should have an overview which kinds of validations are built into Rails. Also read Testing ActiveRecord validations with RSpec. Make the following changes to your MovieDB: Make sure your MovieDB...

...for black and white movies and release_year >= 1917 for color movies. Add tests for your validation. Make sure you have a test for each case...

...follow this workflow. Finishing a feature When you're done with your feature and tests are green, and your changes pass our merge request checklist: Within your feature branch, merge...

...wipes the database just when it is called. The above configurations make sure the test database(s) are emptied up-front. The :transaction strategy does not work with Selenium.

...see Understanding database cleaning strategies in tests...

github.com

...relative 'lib/capistrano/slackistrano' set :slackistrano, { klass: Slackistrano::CustomMessaging, channel: '#your-channel', webhook: 'https://hooks.slack.com/services/your/webhook/url', } Test Slackistrano: cap staging slack:deploy:test When you are satisfied, do a real deploy to...

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

github.com

...Chaining / fluent interfaces Note that you can also make your matcher chainable, so a test can modifier its behavior. Using chaining you can write a matcher like this:

...expected #{given.inspect} not to rhyme with #{expected.inspect}" given.rhymes_with? expected end end end ActiveSupport::TestCase.send :include, RhymeWithMatcher 4) Write a matcher class (for complex matchers) module Aegis module Matchers

...geordi png-optimize Carrierwave Go through our Carrierwave checklist if used. Maintenance Integrate and test the capistrano maintenance task. Accessibility Decide what effort you want to put in improving accessibility...

...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:

github.com

...What you can do is change the time zone of the process running your tests by setting a TZ=CET (or TZ=PDT or TZ=UTC etc.) environment variable.

...way, when the test process spawns another process to run a browser, it will inherit the environment and also believe it lives in that zone. To do so, run the...

makandra dev

...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).

...yourself in Cucumber scenarios. Cucumber Factory We have a very useful gem to create test data in cucumber: cucumber_factory. Read through the README. Integrate it into your MovieDB and...

...you cannot find any opportunities to DRY up a Cucumber scenario, do this exercise (testing the file upload from before): Write a scenario: User can upload a movie poster in...

github.com

matches. Example Let the following setup: # my_model_spec.rb describe MyModel do it 'perfoms a test' it_behaves_like 'something shared' end # something_shared.rb shared_examples_for 'something shared' do

...MyModel is spec/models/my_model_spec.rb[1]. The ID of the ExampleGroup created by it 'performs a test' is spec/models/my_model_spec.rb[1:1]. The ID of the ExampleGroup created by it_behaves_like 'something...

...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...

getbootstrap.com

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...

...verification") added without_partial_double_verification. This might be handy in case you are testing helpers in Rails, where you sometimes rely on methods defined in the application controller (e.g...

...module UsersHelper def user_display_name [current_user.first_name, current_user.last_name].join(' ') end end Unit test with error describe UsersHelper do describe '#user_display_name' do it 'returns the first and...

makandra dev

...do not need a code review, but use the merge request to run a test pipeline: # Push branch, create a merge request, set the branch to be removed on merge...

...and set to merge when all tests are green ptm = push -u origin HEAD -o merge_request.create -o merge_request.merge_when_pipeline_succeeds -o merge_request.remove_source_branch Miscellaneous [core] editor = vim # Set...

makandra dev

Delete the static error pages 404.html, 422.html and 500.html from public/. Add some tests, for example a cucumber feature: @allow-rescue Scenario: 404 page When I go to the...

...navigate to Settings -> Editor -> File and Code Templates. Example You can navigate to the test file of the currently open file with the shortcut Ctrl + T. If no test file...

...exists, you can generate a new test file. If you are not pleased with the output, you can adjust the related code template. To do this, open the project settings...

makandra dev

...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...

...close them as well! See the suggested helper at the bottom of this card. Test support If you access Redis in tests, I suggest introducing a helper method. Example for...

...redis ||= Redis.new(url: REDIS_URL) end end RSpec.configure do |config| config.include(RedisHelpers) end Your Tests may then say redis.get('example'). But I still want to use a global