makandra dev

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

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

This is an awful way to test whether a number is shown on the screen: Then I should see "5" It is awful because the step above is green for...

...see the number 5 The step also works if you you'd like to test that the number is followed by a unit: Then I should see the amount...

makandra dev

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

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

You want to test your 1GE or 10GE internet uplink? We needed to ensure we have full 10GE to the backbone for a customer project. Using netcat To test whether...

...pending Cucumber step (or feature) that also uses an existing VCR cassette, your pending test may fail at the very end with an error like this: There are unused HTTP...

...your VCR is configured to complain about cassettes that contain extra requests which your test did not use. This is often a good configuration. If you do not want to...

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

Summary: Don't add chromedriver-helper to the Gemfile the executables might break your tests in projects where chromedriver-helper is not in the Gemfile developers with different chrome versions...

...the chromedriver-helper gem, but don't have it in you Gemfile, your selenium tests might fail with: Selenium::WebDriver::Error::WebDriverError: unable to connect to chromedriver 127.0.0.1:9515

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

To test that an object was constructed by a given constructor function, use jasmine.any(Klass): describe('plus()', function() { it ('returns a number', function() { let result = plus(1, 2) expect(result...

You might not know that Rails disables CSRF protection in tests. This means that if you accidentally forget to send the CSRF token for non-GET requests, your tests will...

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

Use the following command to test if a server (in this example: makandra.com on port 443) uses Perfect Forward Secrecy (PFS): openssl s_client -connect makandra.com:443 -cipher ECDHE-RSA-RC4...

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

...option is available, not that it is selected. There is a separate step to test that an option is selected. Capybara (0.4.1 or higher) Then /^"([^"]*)" should( not)? be an option...

...a machine by sending an e-mail you can run the following: mail -s Test someone@example.com < /dev/null This will send an empty e-mail with "Test" as its subject to...

...someone@example.com. If you want it to contain a message body, call mail -s Test someone@example.com only; the mail application will then read your input from stdin. Finish your message by...

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

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

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

programmingtour.blogspot.com

We had a conversation about the fact that the 'TDD is about testing vs TDD is about design" debate that keeps popping up, especially now in the Ruby community...

This note describes a Cucumber step definition that lets you test whether or not a CSS selector is present on the site: Then I should see an element "#sign_in...

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

You might wonder about this request in your test.log: Started GET "/__identify__" for 127.0.0.1 at 2015-04-29 18:00:02 +0100 This is what happens: For drivers like Selenium...