...runners like in the following example .gitlab-ci.yml: rubocop: interruptible: true script: - 'bundle exec rubocop' rspec: interruptible: true script: - 'bundle exec rspec' Afterwards new pushes to your MR will cancel all...
...und Nachteile von integration tests? Wann bringt man was zum Einsatz? Lerne Tests mit RSpec zu schreiben Verstehe welche Nachteile entstehen wenn man zu viel testet Tests schreiben kostet Zeit...
...sind weitere Tests nicht mehr so nützlich (teilw. Überschneidung von Tests) Lerne wie du RSpec einsetzt um deine Scripts zu testen Inhalte Writing basic tests with Rspec Rspec Dokumentation
As we are slowly switching from Cucumber scenarios to RSpec feature specs, you might be tempted to write assertions like this one: feature 'authorization for cards management' do
...behavior is that the Capybara test server is running in another thread, and the RSpec thread can't "see" the exception at this point in time. As we are emulating...
...to grab both the key and value from a hash Rerun Only Failures With RSpec RSpec can be configured to run only failed specs: RSpec.configure do |config| config.example_status_persistence...
...file_path = "tmp/failed_specs.txt" end # Then, run "rspec --only-failures" Disassemble Some Codes RubyVM::InstructionSequence#compile can be used to compile Ruby code on the fly. It offers a #disasm method...
...horizon').where('year > 1995').order(:year).to_a Adapt both the integration test and RSpec examples for the search functionality, using the guidelines from the "Testing" chapter in Growing Rails...
...Applications in Practice. RSpec examples should cover all edge cases E2E tests should only cover one "happy path" to show successful integration Open budgets in Project Hero (makandra only)
...or change the encoding. This is all possible, look up for the proper options. RSpec We used this helper in some project to do not have to write comma separated...
file end def generate_empty_csv file = Tempfile.new file.write(' ') file.rewind file end end RSpec.configure do |c| c.include CsvHelpers end The you can generate a csv file like this:
...enable the polling feature for the one E2E test that tests polling. In an RSpec request spec this would look like this: scenario 'The project list is updated periodically' do...
...exceptions (previous default behavior, value false) Using the new default needs to change a RSpec test like this: Before it 'raises an exception if the page could not be found...
...need to check the underlying exception, you can temporary change the show_exception setting: RSpec.configure do |config| config.around(:each, :show_exceptions) do |example| show_exceptions = Rails.application.env_config['action_dispatch.show_exceptions'] Rails.application.env...
...just say create(:movie) instead of FactoryBot.create(:movie). You can configure this like so: RSpec.configure do |config| config.include FactoryBot::Syntax::Methods end Also see RSpec: Where to put custom matchers...
...file uploads with Rails Carrierwave: How to attach files in tests Carrierwave: Built-in RSpec matchers CarrierWave: Processing images with libvips Multipart formposts Content Disposition Header Exercise In MovieDB, allow...
Rendering of image versions and validation of file extension can be tested with RSpec These can be model specs for either the Movie or your PosterUploader
...install the socat package) Start you integration test e.g. REMOTE_DEBUGGING=1 bundle exec rspec spec/system/some_spec.rb with a debugger set Open chrome://inspect/. It should list the test Chrome under...
...don't run the super method inside #initialize, the object is marked as frozen. Rspec mocks (e.g. using partial doubles with receive(partial_double).to ...) in tests would raise...
...the following error (just imagine how hard debugging can be): ArgumentError: Cannot proxy frozen objects, rspec-mocks relies on proxies for method stubbing and expectations. If you define initialize with...
...tests, that you reset ActionMailer::Base.default_url_options after e.g. request specs, e.g. spec/support/action_mailer.rb: RSpec.configure do |config| config.around(type: :request) do |example| url_options = ActionMailer::Base.default_url_options.dup example.run ActionMailer::Base.default_url...
...specs to pass. This way we see Jasmine failures in our regular test runs. RSpec In a feature spec you can run Jasmine specs like this: scenario 'Jasmine tests' do...
...groups, are only excluded, when both of the groups are excluded, e.g. to exclude rspec in the following example, you will have to bundle without test and cucumber:
gem 'rspec'
find('.test2', visible: :hidden) finds the .test2 element As an example, an RSpec test which tries to confirm an element exists but is currently not visible, would say...
...If you access Redis in tests, I suggest introducing a helper method. Example for RSpec: module RedisHelpers def redis @redis ||= Redis.new(url: REDIS_URL) end end RSpec.configure do |config| config.include...
...screenshot can automatically save screenshots and the HTML for failed Capybara tests in Cucumber, RSpec or Minitest. Requires Capybara-Webkit, Selenium or poltergeist for making screenshots. Screenshots are saved into...
...good reason) not rendered in controller specs. If you need it to happen, use: RSpec 1 (Rails 2): integrate_views RSpec 2 (Rails 3): render_views Note that you can...
Simply load the TimeHelpers module as required by your test framework. Example: RSpec.configure do |config| config.include ActiveSupport::Testing::TimeHelpers end Comparison to Timecop Timecop allows you to choose...
...file_fixture is not available by default. To enable it, include a support module from rspec-rails: FactoryBot::SyntaxRunner.include(RSpec::Rails::FileFixtureSupport) That includes ActiveSupport::Testing::FileFixtures, where file_fixture...
...includes a way to see what an e-mail will look like. Integration to RSpec All you need to do is implement a preview-class in spec/mailers/previews/notifier_preview.rb: class NotifierPreview < ActionMailer...
after_save { byebug if $debug; nil } def lock self.locked = true save end end Rspec.describe User do let(:user) { create(:user) } before do # Many users are created and saved in...
...marked_for_destruction?).sum(&:amount) end end How to test the correct behaviour in rspec it 'ignores invoice items marked for destruction in a nested update' do invoice = Invoice.make