...go fixtureless with Shoulda + Factory Girl. All good, except one problem. Slow as fuck tests. So here’s fast_context as a solution for it. fast_context compiles all the...
...should’s within a context into a single test...
...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...
...Binding URL with the LogoutResponse. Keycloak does this when Front channel logout is disabled. Testing in development using a local keycloak server You can test this using a local keycloak...
...and is enabled per default This just worked for me, so no troubleshooting here Testing in development using a local keycloak server You can test this using a local keycloak...
...directly on GitLab, or by checking out the corresponding branch. You can assume that tests are green, but you need to confirm that everything requested in the issue is implemented...
...test coverage is good the code is maintainable What to do if the code is okay If the code is okay, you may either merge it into main yourself:
The idea is this: you take a job that you'd rather not do manually, and describe it to babushka...
...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...
View specs are a powerful tool to test several rendering paths by their cases instead of using a more costing feature spec. This is especially useful because they become quite...
...the view independent from the controller-logic. Therefore it will be more applicable to test views within request specs. But, even then, you still can use Caypbara's matchers within...
When you find similar groups of expect calls in your tests, you can improve readability by extracting the group into its own matcher. RSpec makes this easy by allowing matchers...
...to call other matchers. Example The following test checks that two variables foo and bar (1) have no lowercase characters and (2) end with an exclamation mark: expect(foo).to...
If a project ist configured to spawn CI runners for tests or deployment when pushing to the Repo, a habit of pushing WIP commits regularly may conflict with that.
...trashed_changed? end Or, move the conditions into the callback. This also allows you test the conditions more easily using a unit test: after_save :update_offices_people_count
if office_id_changed? || trashed_changed? ... end end Also see the card on testing conditional validations...
...serve requests with the HOST header hacker.xyz You need to take care in your tests, that you reset ActionMailer::Base.default_url_options after e.g. request specs, e.g. spec/support/action_mailer.rb: RSpec.configure do...
...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...
...should be ignored and no validation errors should be shown. Make sure to write tests for the showtimes form. How do you refer to the showtimes fields when there are...
...must not contain any code or names specific to movies or the movie form. Test that the component is reusable by allowing to add an actor's roles from within...
...number of words, lines and paragraphs, and outputs the result. For example: $ ruby count_words.rb test.txt test.txt has 123 words test.txt has 13 lines test.txt has 4 paragraphs Hint
The argument that using tests is a ideologic waster of time fails when one considers how it can help to insure architectural decisions...
I brought up the question whether tests should call the translation API when checking for the presence of a string...
Unit tests are to refactoring like a drop cloth is to painting. Both feel like more work at first but ultimately save you time by allowing you to move faster...
...no way to do it in Capybara, unfortunately. But if you're running your tests with the Selenium driver (and probably other drivers that support JavaScript), you can hack it
...main').search('horizon').where('year > 1995').order(:year).to_a Adapt both the integration test and RSpec examples for the search functionality, using the guidelines from the "Testing" chapter in...
...Growing Rails Applications in Practice. RSpec examples should cover all edge cases E2E tests should only cover one "happy path" to show successful integration Open budgets in Project Hero (makandra...
...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...
...instead reference another part of that email by a content ID cid:xxxxx@xxxxx.mail. Your tests will not be able to verify easily that you used the correct image version any...
...last point, it is recommended to use a feature flag and disable inlining in tests by default so you will still be able to easily test that your emails use...
Your development machine is usually on a very good network connection. To test how your application behaves on a slow network (e.g. mobile), you can simulate limited bandwidth. Chrome
...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...
...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...