So you are comparing two Time objects in an RSpec example, and they are not equal, although they look equal: expected: Tue May 01 21:59:59 UTC 2007,
...know that you did not break anything. Prefer "big picture" integration-like tests (using RSpec) over unit tests. Acceptance and manual testing As early as possible, take actual time to...
...of the application. For alternatives see Cucumber: Testing file downloads with Selenium. Usage in RSpec feature specs Copy the DownloadHelpers module to spec/support. You can now include the helper in...
...all your feature specs: RSpec.configure do |config| config.include(DownloadHelpers, type: :feature) end Usage in Cucumber scenarios Copy the DownloadHelpers module to features/support. Then include the helper in your scenarios and...
...DatabaseCleaner configured to take care of not bloating your test database with old records: RSpec.configure do |config| config.before(:suite) do DatabaseCleaner.clean_with(:deletion) end config.before(:each) do DatabaseCleaner.strategy = :transaction
...migration database. This means we can now specify this second database when using DatabaseCleaner: RSpec.configure do |config| config.before(:suite) do DatabaseCleaner[:active_record].clean_with(:deletion) DatabaseCleaner[:active_record, db...
Helpers # performance_steps.rb # Cucumber steps for performance testing # Can easily be converted to an RSpec helper Given(/^I throttle the test browser I\/O to (\d+)kbps$/) do |kbps|
Simply add this to your .rspec instead: --require spec_helper If you are on rspec >= 3 and use a rails_helper.rb require 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_parallel file...
...only set this if you use a light terminal theme Improving Diffs for Ruby, RSpec and Cucumber files See Rails developers: Have better context in Git diffs. This will correctly...
...works in weird ways. Use the allow_value matcher instead: describe Email, '#sender' do # > Rspec 3 should syntax it { should allow_value("email@addresse.foo").for(:sender) } it { should_not allow_value...
...foo").for(:sender) } # Rspec 3 expect syntax it { is_expected.to allow_value("email@addresse.foo").for(:sender) } it { is_expected.not_to allow_value("foo").for(:sender) } end Errors that may occur if you do...
...which kinds of validations are built into Rails. Also read Testing ActiveRecord validations with RSpec. Make the following changes to your MovieDB: Make sure your MovieDB models have validations for...
...API from the example (skip this variant for the "upcoming movie" exercise) Use plain RSpec mocks ("stubs") to replace the HTTP request to the API with scripted behavior. Can you...
...s poster as a file attachment to the e-mail? Can you write a RSpec test for this? In the lesson Form Models we said that we don't like...
...to fix these errors in development instead of ignoring these in the logs. For RSpec you might want to use allow(ActionController::Parameters).to receive(:action_on_unpermitted_parameters).and...
...yet. Otherwise you could resize your window before every example just to be sure: RSpec.configure do |config| config.before(type: :feature) do case Capybara.current_driver when :desktop resize_browser_to(DESKTOP...
Currently we often use geordi to run cucumber and rspec tests. Geordi takes care of installing a matching chromedriver for the installed google-chrome binary. The google-chrome binary is...
Please note that the changed behavior can also be observed in Capybara's RSpec matchers like have_text...
...on how to migrate legacy approaches to assignable_values. Testing There is a custom RSpec matcher...
...name, like "Europe/Berlin" or "Asia/Tokyo". page.driver.browser.execute_cdp('Emulation.setTimezoneOverride', timezoneId: iana_zone_name) end end RSpec.configure do |config| config.include(TimeZoneHelpers, type: :feature) config.after(type: :feature, js: true) do set_browser_time...
...file type and adjust the code template according to your preferences. For example, the RSpec code template generates way too much boilerplate. Something like this is far more suitable for...
...following test was taken from a project using ActionDispatch::IntegrationTest. Though we usually use RSpec, this should give you the general idea. context 'favicons' do def link_selectors [ ['link[href...
...instructions in the README. Most likely you want: to add the Ruby, Rails and RSpec cops to include the unit test 2. Report all existing offenses and exclude them initially...
...the console IRB. console command: Ctrl + C now properly exits a local Rails console rspec and cucumber commands: Run specs even if the automatic chromedriver update fails Improve detection of...
...container you can run your tests export CHROMEDRIVER_URL=http://localhost:9999 bundle exec rspec specs/system/test_spec.rb # You might need to set remove `--headless` from your chromedriver options in e.g. selenium...
...out which test throws this deprecation warning. There are other workarounds, too: Geordi with Rspec: geordi rspec spec/ (providing a path will lead to a run in a single process...
...Rspec: bundle exec rspec Cucumber: DISPLAY=:17 bundle exec cucumber (Just like geordi uses port 17 for VNC to not see a test browser...
This only applies to RSpec below version 1.3.2. The issue has been fixed in RSpec 1.3.2, and most likely RSpec 2 and later versions. When you have a helper that...
...get('@content_for_title').should == 'Hello Universe' end Unfortunately, this may only work once. RSpec instanciates the helper object only once, thus keeping instance variables -- and since content_for always...