...yourself in Cucumber scenarios. Cucumber Factory We have a very useful gem to create test data in cucumber: cucumber_factory. Read through the README. Integrate it into your MovieDB and...
...you cannot find any opportunities to DRY up a Cucumber scenario, do this exercise (testing the file upload from before): Write a scenario: User can upload a movie poster in...
...if you make any error in programming. E.g. a simple typo would make the test above green. The block will catch the Spec:: exception and the test will be happy...
You can define methods in any example group using Ruby's def keyword or define_method method: describe "example" do...
Testing with real live production data does come with at least one catch. All those real live users in your production environment have real live email addresses that receive real...
...Find descendant(s) by CSS selector .find(selector) one: .querySelector(selector), many: .querySelectorAll(selector) Test an element (returns boolean) .is(selector) .matches(selector) Test for class presence (boolean) .hasClass(class...
.replace(/^/, '#') Ruby My use case was comparing colors in an integration test, so I used JS to get the pseudo element's style via Selenium, and then processed it...
...not to include 3 Applications Tip This can be used to test for exclusion of multiple values all at once...
...Here is how to circumvent that. What's going on? You are making ActionController::TestRequests in your specs, and their #initialize method does this: self.session = TestSession.new This means that each...
...behavior by stubbing the controller's session and querying that stub: persisted_session = ActionController::TestSession.new controller.stub :session => persisted_session # do things persisted_session[:something].should ... Apply this workaround only when...
PostgreSQL supports the SQL OVERLAPS operator. You can use it to test if two date ranges overlap: => SELECT ('2001-02-16'::date, '2001-12-21'::date) OVERLAPS...
...date, '2002-10-30'::date); overlaps -------- false Also compare our card Test if two date ranges overlap in Ruby or Rails...
...want to use it in production, but it may serve you well for some testing/prototyping/etc...
require 'spreadsheet' Spreadsheet.client_encoding = 'UTF-8' book = Spreadsheet::Workbook.new sheet1 = book.create_worksheet :name => 'test' money_format = Spreadsheet::Format.new :number_format => "#,##0.00 [$€-407]" date_format = Spreadsheet::Format.new :number_format => 'DD.MM.YYYY...
...sheet1.column(2).default_format = date_format sheet1.row(0).push "just text", 5.98, DateTime.now book.write 'test.xls' That's how to insert Links into a excel cell book = Spreadsheet::Workbook.new sheet1 = book.create...
Shared example groups are a useful RSpec feature. Unfortunately the default directory structure generated by rspec-rails has no obvious...
...SSL::SSLError: SSL_connect SYSCALL returned=5 errno=0 state=unknown state SSL Server Test This SSL Server Test can help finding out which SSL/TLS versions the server can handle...
Custom matchers are a useful RSpec feature which you can use to DRY up repetitive expectations in your specs. Unfortunately...
...and check if your application responds and everything looks okay. Run your application's tests...
...rails generate cucumber:install --capybara to integrate cucumber/capybara into your rails project. Run your tests and fix error messages by reintegrating parts from your backed up files...
...files from the dist folder, which is most often <ES6 javascript. 9. Achieve green tests. 10. Check if postcss, uglifier, babel and other compilers work for production. This can be...
Then the "sorted" select should be sorted But the "unsorted" select should not be sorted
VCR.use_cassette(' ', match_requests_on: %i[method oauth_uri]) do # Your test here
...is not used before removing it. If you remove the --dry-run flag, all tests will actually run and you can skip adding the require_relative line. It will take...
...page will show up in your browser. Note that if you run your Cucumber tests using the cuc script from our geordi gem, it will automatically detect cucumber_spinner and...
FactoryBot.define do factory :parent do transient do child_name nil child_allowed_to_drive false end child do association(:child...
...and change the stored environment: RAILS_ENV=development rails db:environment:set For parallel tests: rake parallel:rake[db:environment:set] Then re-run your command. Or, if you are...
You can chain multiple Capybara matchers on the page or any element: expect(page) .to have_content('Example Course')