...active class switches to the clicked link. In a Jasmine spec I wanted to test this behaviour. Unpoly's up.hello emits an up:fragment:inserted event, in whose callback function...

...add logic to your application code that helps to modify the Accept-Language in tests. Here is an example for a Rails application with Cucumber integration tests: class ApplicationController

...and will cause unexpected errors with Selenium. You will see errors in your integration tests like below if you are affected by the issue: The field's content "" did not...

After removing the line above in the configuration it could happen that the tests are no longer running in headless mode. Updating the selenium-webdriver gem to >= 3.13.0 fixed...

Here is how to switch your Selenium to Chrome: Make sure you've got a recent version of chromedriver in...

whattrainisitnow.com

...subsequent ESR releases overlap for three months. This way enterprises have a quarter to test the new version and migrate their clients...

...external URL (like http://somehost.com/some/path) you will find that this is hard to test with Cucumber and Capybara: A non-Javascript Rack::Test scenario will just ignore the host...

...and try to open /some/path in your local application A Selenium test will actually follow the redirect, which you probably don't want either There are two workarounds for this...

tl;dr You can use ordered to ensure that messages are received in a specific order. Example expect(ClassA).to...

To test concurrent code, you will need to run multiple threads. Unfortunately, when you use blocking system calls (e.g. locks on the database), Ruby 1.8 threads won't work because...

@writer.puts "Started: #{i}" sleep 0.01 @writer.puts "Finished: #{i}" end @writer.close end end @writer.close # test whether we always get alternating "Started" / "Finished" lines lines = @reader.lines.to_a lines.should be_present # it...

In our monitoring, RabbitMQ queues like aliveness-test may show up as unresponsive, with a ping timeout after 10 seconds. The logfile will generally read like this: operation queue.delete caused...

...to perform operation on queue 'example' in vhost '/' due to timeout For the aliveness-test queue, you can can use this command to delete it: rabbitmqctl eval 'rabbit_amqqueue:internal...

tl;dr: Always have your attachment path start with :rails_root/storage/#{Rails.env}#{ENV['RAILS_TEST_NUMBER']}/. The directory where you save your Paperclip attachments should not look like this: storage/photos/1...

...storage/attachments/1/... storage/attachments/2/... The problem with this is that multiple environments (at least development and test) will share the same directory structure. This will cause you pain eventually. Files will get...

...callback passed to promiseState will be called asynchronously in the next microtask. Usage example: Tests Note Since this card was written Jasmine has implemented asynchronous matchers that let you expect...

...sufficient to use the then() function. Where promiseState() becomes useful is when writing unit tests for a function that returns a promise. Let's say we write a promise-based...

RSpec 1, RSpec 2 To test whether two arrays have the same elements regardless of order, RSpec 1 and 2 give you the =~ matcher: actual_array.should =~ expected_array Rspec 3

...array takes an argument, but contain_exactly takes a list of elements as varargs. Test::Unit If you install shoulda-matchers you can say: assert_same_elements([:a, :b, :c...

theprogrammingbutler.com

See the Spreewald README for more cool features. You can use it to test links that were opened with a link_to(..., :target => '_blank') link or other ways that...

...create new tabs or windows. Important This only works with Selenium enabled tests...

Instead of running all missing migrations on your test database with rake db:migrate RAILS_ENV=test you can also use a handful of rake tasks to prepare the database...

...structure directly. They can produce different results, though. In a nutshell, to ensure your test database gains the correct structure: Don't use rake db:test:prepare carelessly

...it has not yet recorded. Some signs an error is caused by randomness The test is green on a single run but red when run in parallel

...always green on recording but red when the cassette is used The test is green on one day and red the following day Finding the randomness Taking a close look...

To run a single test file: rake test:units TEST=test/unit/post_test.rb rake test:functionals TEST=test/functional/posts_controller_test.rb rake test:integration TEST=test/integration/admin_news_posts_test.rb You may even run a single test method:

...I test test/unit/post_test.rb -n "name of the test" ruby -I test test/functional/posts_controller_test.rb -n test_name_of_the_test # underscored, prefixed with 'test_' Or all tests matching a regular expression:

...when two focus-sensitive Selenium scenarios run at the same time (probably with parallel_tests). This can help you to detect and fix flickering integration tests. The attached feature works...

...you'll see). Default is 5 minutes. It should be longer than your flickering tests take to run. Make sure that your root_path contains a form element (select, input...

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

...by "regular" browsers, search engine crawlers, or other web client software. Cucumber In Rack::Test, you can set your user agent like this on Capybara: Given /^my user agent is...

...User-Agent', agent) # Or, for older Capybaras: # page.driver.header('User-Agent', agent) end For Selenium tests with Firefox, it seems you can set the general.useragent.override profile setting to your preferred value...

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

...a script that helps you create an unchanging version of Firefox for your Selenium tests. In particular, this new copy of Firefox will have the following properties:

Once the setup process has completed, you have two Firefoxes: One for Selenium tests, one for regular browsing. You can now update your regular Firefox without fear of Selenium...

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/ ~>