0.0
Low commit activity in last 3 years
A long-lived project that still receives updates
pludoni GmbH's RSpec template. Just require in spec_helper
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

PludoniRspec

Gem Version

pludoni GmbH's RSpec helper for modern Rails apps (+5.1, RSpec > 3.5)

Just include in your spec_helper / rails_helper

ENV["RAILS_ENV"] ||= 'test'

require 'pludoni_rspec'
PludoniRspec.run

What's done:

  • Maintain Test Schema

  • spec/support/**.rb will be loaded for overriding in projects

  • describe 'what', freeze_time: '2018-01-01 12:00' do Tag for examples. If Timecop is available, this will be used, otherwise Rails 5.x default travel_to

  • Simplecov coverage recording started at beginning

  • Capybara+Chromedriver config with Chromedriver, Headless (will probably not work on OSX though)

    • Available Helper:
    • console_logs - Show console log output of browser
    • drop_in_dropzone(file_path) - drop a file into the first "Dropzone"
    • screenshot(path=nil) - make a screenshot to public/screenshots/*.png
    • skip_confirm(page) - ignore all confirm('') alert boxes from now
    • in_browser('user_1') do ... end - simulate multi-user scenarios / change browser session
  • Rspec configs:

    • Persistence Path: tmp/rspec.failed.txt to enable --next-failure / --only-failures switches
    • executable: nf and of
      • nf -> rspec --next-failure
      • of -> rspec --only-failures
    • clears ActionMailer deliveries before each scenario
    • default backtrace without rails, fabrication, grape, rack
    • fixtures in spec/fixtures
    • Transactional Fixtures enabled - no DatabaseCleaner needed anymore for Rails > 5.1

Optional - Loaded if companion gem is available:

  • VCR - sensible VCR is available (not required by Gem)

  • Devise - Test helpers loaded, if Devise is available, and included in Controller specs

  • Shared Contexts that can be included on demand:

    • include_context 'mails' - For working with ActionMailer::Base.deliveries
      • mails_with(to: '') - Filter mails sent to a user
      • last_mail == ActionMailer::Base.deliveries.last
      • mails == ActionMailer::Base.deliveries
      • extract_link_from(last_mail, link: 0) - gets you the link (without protocol + host) of the first link in the last mail with a html body
    • include_context 'active_job_inline'
      • all ActiveJobs will be run immediately in this group

Gitlab coverage + test report

Gitlab supports inlining test-coverage + showing detailed failed/passed test statistics. This gems includes the necessary formatters. Coverage is automatically loaded in CI. For test case integration, add the RspecJunitFormatter to the rspec command in your bin/ci/run command etc.

e.g. using multiple rspec runs

  bundle exec rspec --color --tty --failure-exit-code 0 --format RspecJunitFormatter -out rspec1.xml
  bundle exec rspec --color --tty --only-failures --format RspecJunitFormatter -out rspec2.xml
# .gitlab-ci.yml
artifacts:
  reports:
    cobertura: coverage/coverage.xml
    junit: 'rspec*.xml'