The linked MDN article is quite informative of a neat feature supported by all major browsers: Unicode character class escape...
...visit url_for(request.params) end For a step that distinguishes between drivers (Selenium, Rack::Test, Culerity), check n4k3d.com...
...a transformable example of katapult's features Development Add katapult update script Speed up tests (now running in about 9 min) Improve development workflow (see README) No bundler issues in...
...tests any more
CarrierWave comes with some RSpec matchers which will make testing more comfortable. Let's say you have an Uploader like this: class MyUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick
...a class Movie with an attribute poster. In your spec file, you can add tests to check the dimensions of the several versions by writing RSpec.describe Movie, type: :model do...
Usually our code lives on GitLab, therefore our documentation for CI testing is extensive in this environment. If you are tied to GitHub e.g. because your customer uses it, you...
...template uses two such custom actions: setup-node and setup-ruby .github/workflows/integration-testing.yml name: Integration Testing on: push: branches: [ main, production ] pull_request: branches: [ main, production ] # Display "Run Workflow" button on...
...they are wrapping the same native DOM elements: $('body') == $('body') // false In order to test if two jQuery objects refer to the same native DOM elements, use is:
Jasmine equality matcher for jQuery See here for a custom Jasmine matcher that tests if two jQuery objects are equal...
If you want to have routes that are only available in tests (e.g. for testing obscure redirects), you can use the with_routing helper -- but that one destroys existing routes...
...may break a specs that require them to work. To keep both "regular" and test routes, do this: class MyApplicationController < ActionController::Base def show render text: 'Welcome to my application...
This step tests whether a given select option comes preselected in the HTML. There is another step to test that an option is available at all. Capybara Then /^"([^"]*)" should be...
...web browser. It's pretty convenient. By installing a Chrome addon you can also test your local code on http://localhost...
...to record communication with remote APIs is a great way to stub requests in tests. However, you may still want to look at the request data like the payload your...
...have_requested(:post, 'http://example.com').with(body: 'yolo') Easy peasy. Related cards Faking and testing the network with WebMock
Some helpers for poking around at your Capybara driven browser's cookies in integration tests. Supports Capybara's bundled drivers (rack-test, Selenium Webdriver), and adapters for other drivers may...
Re-creating a complex ActiveRecord scenario quickly without setting up a full-blown Rails app can come in handy e.g...
...authorized users only 3. Using the same storage folder for multiple Rails environments or test processes This one affects your developers. If an image with ID 4 always ends up...
...as public/system/images/4.jpg, multiple Rails environments (e.g. development and test) will randomly see and overwrite each other's files. See Always store your Paperclip attachments in a separate folder per environment...
Geordi 0.16+ supports running selenium tests with project-specific firefox versions. Just update the gem. It will still default to using the old 5.0.1 firefox. If you want another one...
This cucumber step is useful for testing an image (looking at the src of the image). Then(/^I should see the image "([^"]*)"$/) do |filename_with_extension| expect(page).to have...
Then I should see the image "placeholder.png" Outline: Read more about how to test a uploaded file here, e.g. file downloads...
sudo gem install parallel script/plugin install git://github.com/grosser/parallel_tests.git Adapt config/database.yml test: database: xxx_test<%= ENV['TEST_ENV_NUMBER'] %> Create test databases script/dbconsole -p CREATE DATABASE `xxx...
... Generate RSpec files script/generate rspec (you'll probably only let it overwrite files in script/) Prepare test databases Now and after each migration: rake parallel:prepare Run tests
...en”. They reappear when Chrome gets updated. This may help you running your Selenium tests using the Chrome driver on applications that choose the language from what the browser sends...
I had to deal with JavaScript Undefined Error while accessing a specific CKEditor instance to fill in text. Ensure everything...
...behavior to be impractical, but it is by design. In order to perform a test or action in all matching elements, do not use within but prefer the attached "inside...
...work across all revisions that you will be bisecting. If you're referencing a test file that's under version control, make sure you always run the correct test.There are...
Spreewald now comes with a step that tests if a form field is visible: Then the "Due date" field should be visible But the "Author" field should not be visible...
...checks if that field is hidden via CSS (or Javascript). It is not currently tested if the label is visible or hidden. For this see: Check that an element is...
When using state_machine you sometimes need to know whether an object may execute a certain transition. Let's take...
...URL, which can lead to errors when you have absolute URLs in your Cucumber tests. If you really need to use absolute URLs somewhere, say in an email you send...
Single step and slow motion for Cucumber scenarios can come in handy, especially in @javascript scenarios. # features/support/examiners.rb AfterStep('@slow_motion...