Unfortunately, Capybara does not offer a switch to disable cookies in your test browser. However, you can work around that by using a tiny Rack middleware -- it works for both...

...Selenium and non-Selenium tests. Wouldn't it be nice to say something like this? Given cookies are disabled When I try to sign in Then I should see "Can...

...wait until one of the two requests is finished. Concurrent requests in development and tests Normally having multiple threads for development is fine. Puma can handle blocking threads e.g. when...

...count = Integer(ENV['RAILS_MAX_THREADS'] || 5) Note: Having multiple workers in development and tests might cause unexpected issues (database transactions and other shared states), you should not enable it...

jetmore.org

swaks is a very nice tool to test SMTP. For the most linux distributions you can easily install it with your package management system. This example send an email from...

...Date: Mon, 04 Nov 2013 15:56:19 +0100 ~> To: to@example.com ~> From: from@example.com ~> Subject: test Mon, 04 Nov 2013 15:56:19 +0100 ~> X-Mailer: swaks v20111230.0 jetmore.org/john/code/swaks/ ~>

Possible Reason 1: parallel_tests - running more processes than features If you run old versions of parallel_tests with more processes than you have Cucumber features, you will get errors...

...The bug is fixed in versions 0.6.18+. Possible Reason 2: You are running parallel tests but you are using an (probably old) database.yml which is not setup for parallel tests...

...you are writing to the cookie more than once, but when doing so, integration tests (Cucumber) may break for you with this error: You have a nil object when you...

Geordi uses parallel_tests if available for running the test suite. To debug an application it is very unhandy to have multiple processes as your terminal I/O will not work...

...as expected once a breakpoint is hit. Even parallel_tests support an option to enable a single process run, it is not possible to pass this option through geordi. But...

...a habit of using this regularly, as it has high potential to make your tests hard to read and understand. You're often better of by using factories, generally different...

...implementation patterns, or just duplicating some of your tests' code. In some situations this has benefits, like making complex setups simpler if you want to modify only one aspect.

...afterwards again. CSSnext Input: body { font-variant: small-caps; background-image: image-set(url(test_1.svg) 1x, url(test_2.svg) 2x); } Output: body { -webkit-font-feature-settings: "c2sc"; font-feature-settings: "c2sc...

...font-variant: small-caps; background-image: -webkit-image-set(url(test_1.svg) 1x, url((test_2.svg) 2x); background-image: image-set(url(test_1.svg) 1x, url(test_2.svg); } Autoprefixer Input: body { ::placeholder { color: gray...

Large projects usually have large test suites that can run for a long time. This can be annoying as running tests blocks you from picking up the next story -- but...

...simply push that branch and check it out on your 2nd copy to run tests there. You can pick up a new story and work on that on your "main...

We are maintaining some vintage projects with tests written in Test::Unit instead of RSpec. Mocks and stubs are not features of Test::Unit, but you can use the Mocha...

...Here is a snippet that shows the current settings and lets you send a test mail directly from the console: mailer = ActionMailer::Base.new # check settings: mailer.delivery_method # -> :smtp mailer.smtp_settings...

...authentication: nil, enable_starttls_auto: true } # send mail: mailer.mail(from: 'sender@example.com', to: 'recipient@example.com', subject: 'test', body: "Hello, you've got mail!").deliver You could use this to test the spam...

github.com

You know that Devise offers RSpec test helpers for controller specs. However, in request specs, they will not work. Here is a solution for request specs, adapted from the Devise...

...wiki. We will simply use Warden's test helpers -- you probably already load them for your Cucumber tests. First, we define sign_in and sign_out methods. These will behave...

Aruba is an extension to Cucumber that helps integration-testing command line tools. When your tests involve a Rails test application, your tool's Bundler environment will shadow that of...

...the test application. To fix this, just call unset_bundler_env_vars in a Cucumber Before block. Previously suggested solution Put the snippet below into your tool's features/support/env.rb -- now...

The Basic Authentication header encodes username and password. Effectively, it's just Base64 plus a "Basic" prefix.

You can set the resolution and user agent used in selenium tests with chrome with the method described in this card, but you can also set the accept-language and...

Capybara drivers will usually delete all cookies after each scenario. If you need to lose cookie data in the middle...

I needed to make sure that an element is visible and not overshadowed by an element that has a higher...

...jQueryUI's Sortable plugin (either directly or via Angular's ui.sortable), you might struggle testing your nice drag&drop GUI since Selenium webdriver does not support native dragging events.

...jQueryUI uses jquery.simulate for their testing, so why shouldn't you? There is even an extension to it that makes testing drag & drop quite easy. Here is what you need...

We are using Spring in our tests for sequential test execution but not for parallel test execution. And Rails requires you to set the config.cache_classes = false if you are...

...using Spring in tests. With our setup, this would raise the following error in cucumber-rails for parallel test executions due to some legacy database cleaner issue. WARNING: You have...

TLDR: In tests you need to clean out the database before each example. Use :transaction where possible. Use :deletion for Selenium features or when you have a lot of MyISAM...

Understanding database cleaning You want to clean out your test database after each test, so the next test can start from a blank database. To do so you have...

...don't provide canditional validations (validations with if: option). Here is how to write tests for the condition: Class: class Employee < ActiveRecored::Base validates :office, presence: true, if: manager?

... end end Test: describe Employee do describe '#office' do context 'is a manager' do before { allow(subject).to receive(:manager?).and_return(true) } it { is_expected.to validate_presence_of(:office...

Plugins (and gems) are typically tested using a complete sample rails application that lives in the spec folder of the plugin. If your gem is supposed to work with multiple...

...the print stylesheet. This card describes how to write a simple Cucumber feature that tests some aspects of a print stylesheets. This way, the requirement of having a print stylesheet...

...is manifested in your tests and cannot be inadvertedly removed from the code. Note that you can always use your DevTools to preview the print styles in your browser.

...when it was called during browser interaction in development but doesn't make the test fail. The reason Development autoloading isn't smart enough to find the referenced class

...other environments (test, staging, production) autoloading is disabled, that all classes are already loaded when browser interaction takes place what makes rails able to find the class even without the...