end Note that you need to tag the scenario with @allow-rescue to test that an error is shown like this @allow-rescue Scenario: Accessing the admin area requires...

web.archive.org

...you use that "db count" and process the loaded elements. A common example is tests: Imagine a test that sets up a few records and finishes the test setup by...

...records have loaded (i.e. cached) their associations too early and now are missing elements. Tests relying on the setup will fail, because they will operate on the loaded records. You...

web.archive.org

...as pending, include a failing spec body or RSpec 3 will consider the pending test as failing. The reasoning is: If the spec is flagged as pending but passes, it...

...work the way you how you would like it to. To create a nice test coverage report, copy the attached file to lib/tasks/rcov.rake. After that rake rcov:all will run...

...app/controllers/shared and app/models/shared (which may or may not be entirely correct for your case). Tested that it works with Selenium features Doesn't add rake tasks outside development environment

...should way of writing specs for expecting things to happen. However, if you have tests you cannot change (e.g. because they are inside a gem, spanning multiple versions of Rails...

...Solution: Add gem 'minitest' to your Gemfile, before any rspec gem. Another MiniTest::Unit::TestCase is now Minitest::Test. From /Users/makandra/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/test/unit/testcase.rb:8:in ` ' In order to remove this message, you...

blog.salsify.com

...problem of pending AJAX requests dying in the browser when the server ends a test or switches scenarios. We were able to work around this issue in most projects by...

...Listening on localhost:36309, CTRL+C to stop If you are running parallel tests with thin, this will clutter you output. Disable thin logging with these lines: # e.g. in features/support/thin.rb...

Thin::Logging.silent = true Note that this disables all logging in tests. Instead, you also might set a different logger with Thin::Logging.logger = . See Thin::Logging for details...

...gem will show a default of 30 records per page. If you want to test pagination in a Cucumber feature, you don't want to create 31 records just for...

...Using Capybara RSpec matchers One rule of thumb I try to follow in capybara tests is using capybara matchers and not plain rspec matchers. One example: visit(some_page)

...sure the datepicker is loaded before interacting with it See also Fixing flaky E2E tests

...above commands does, see explainshell. Note that we use geordi cucumber to run our tests. If you don't, xargs cucumber or similar might work for you. Part of Geordi...

Note that if you plan to freeze your Firefox versions because your Selenium tests break whenever Firefox updates, there is a better way that lets you keep an up-to...

betterspecs.org

betterspecs.org is a documentation on how to write better RSpec tests. Note that there are also other approaches like The Self-Contained Test, which is complementary to the dry-approches...

rubydoc.info

Preface: Normally, you would not need this in integrations tests (probably that's why it is so hard to achieve), because it is no actual "integration testing". If you use...

...in features/support/paths.rb. Capybara The step definition is part of Spreewald. The step has been tested with multiple versions of Capybara, Rack::Test and Selenium. Webrat (legacy) This is a simpler...

...or when you accidentally interact with the browser frame. This will result in flickering tests, which are "randomly" red and green. In fact, this behavior is not random at all...

...better understanding of Selenium focus issues, and what you can do to get your test suite stable again. Preventing accidental interaction with the Selenium window When Selenium windows steal your...

developer.mozilla.org

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

makandra dev
github.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

makandra dev

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

...data from external XML and JSON APIs in Ruby, and learn several techniques for testing code that talks to the network without making your test suite slow or flaky.

...the failure modes of an external API: errors, no results, ambiguous results. You can test code that talks to the network in several ways — real calls, stubs, request-level mocking...

stackoverflow.com

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

web.archive.org

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