The Basic Authentication header encodes username and password. Effectively, it's just Base64 plus a "Basic" prefix.
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...
...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...
...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...
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...
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...
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...
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...
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...
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...
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...
...start playing video or audio. E.g. if you attempt to call video.play() in a test, the call will reject with a message like this: NotAllowedError: play() failed because the user...
...with the document first. https://goo.gl/xX8pDD Workaround To pretend document interaction in a test you can create an element, click on it, and remove the element again. This unblocks...
Capybara drivers will usually delete all cookies after each scenario. If you need to lose cookie data in the middle...
...this instead of the spec_helper: --require rails_helper If you are using parallel_tests and this is not working for you, .rspec might be ignored. Try using a .rspec...
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...
The ActionDispatch module of Rails gives you the helper method flash to access the flash messages in a response.
...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...
...by CSS, the following will work with Selenium, but not when using the Rack::Test driver. The Selenium driver correctly only considers text that is actually visible to a user...
...Then I should not see "foobear" This is because the Rack::Test driver does not know if an element is visible, and only looks at the DOM. Spreewald offers steps...
...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...
When testing code that uses pushState / replaceState, your browser will appear to navigate away from http://localhost:3000/specs (or wherever you run your Jasmine tests). This is inconvenient, since reloading...
...the document will no longer re-run the test suite. To remedy this, copy the attached file to a place like spec/javascripts/helpers and #= require it from your tests. It will...