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...
...the user is certain. Solution If you need to circumvent this protection, e.g. to test that your application behaves correctly despite being misused, do this: page.execute_script 'history.back()' page.execute_script...
Spreewald now comes with a step that tests if a form field is visible: Then the "Due date" field should be visible But the "Author" field should not be visible...
...checks if that field is hidden via CSS (or Javascript). It is not currently tested if the label is visible or hidden. For this see: Check that an element is...
...web browser. It's pretty convenient. By installing a Chrome addon you can also test your local code on http://localhost...
If the application under test makes sound, you probably want to disable this during integration testing. You can use the args option to pass parameters to the browser. For Chrome...
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...
There is a kind of features in web applications that hinder automated integration tests. Examples include cookie consent banners or form captchas. Clearly, these should be disabled so you do...
...not have to explicitly deal with them in each and every test (like, every test starting with accepting the cookies notice). On the other hand, they must be tested as...
Sometimes PDF cucumber tests fail at the first test run and succeed at the second run. You can fix this with this step: When PDF generation is ready
When using state_machine you sometimes need to know whether an object may execute a certain transition. Let's take...
...scrollbars ? '==' : '!=' scroll_height.should.send(comparison, offset_height) end This should respect padding. However, I have not tested if margins have an effect on it...
...x86_64 -cdrom filename.iso If you prepared a USB pen drive and want to test it, run it like this (/dev/sdx being your device name; you may need to sudo...
...gem you often hook onto events like this: update.before do do_something end For testing such things in your controller you should -- as always -- not trigger something that eventually calls...
If you want to test that a certain text is contained within the document title of your page, you can do so using Selenium and a step such as
Our collection of the most useful Cucumber steps, Spreewald, now supports exact matching of form fields and lets you use...
This step will pass if the specified select is sorted. Then /^the "(.*?)" select should be sorted$/ do |label, negate|
...servers. It spins up when you run your feature specs, so that you can test your purchase flow without hitting Stripe’s servers or making any external HTTP requests.
...ve also had tests actually hitting the testing sandbox of Stripe, which worked OK most of the time (can be flakey...
To test whether a hash includes an expected sub-hash: expect(user.attributes).to match(hash_including('name' => 'Bruce Wayne')) expect(User).to receive(:create!).with(hash_including('name' => 'Bruce Wayne...
The step definition below lets you say: Then I should see a field "Password" But I should not see a...
Tooltips that are delivered through HTML attributes are encoded. Decode entities before checking for their presence. Capybara: Then /^there should...
This is surprisingly difficult when there is a with the same text on the page, but you really want to...
The step definition below allows you to write: Then I should see a link labeled "Foo" But I should not...
The step definitions below allow you to write this in both Webrat and Capybara: When I follow "Download as PDF...
Spreewald has steps that let you test that e-mails have been sent, using arbitrary conditions in any combination. The attached file is for legacy purposes only...
The step definition below allows you to write: Then I should see an HTML redirect to "http://www.makandracards.com" in the...