Skip to content

Instantly share code, notes, and snippets.

@Whatapalaver
Last active June 11, 2021 19:57
Show Gist options
  • Save Whatapalaver/1e09a908c57bd5aac6bf5e1fe35419ac to your computer and use it in GitHub Desktop.
Save Whatapalaver/1e09a908c57bd5aac6bf5e1fe35419ac to your computer and use it in GitHub Desktop.
Setting up Simple ruby Project with RSpec
  • cd into new directory
  • gem install bundler
  • bundle init to create new Gemfile
  • Add the following to Gemfile:
gem 'rake'
gem 'rubocop', '0.56.0'

group :test do
  gem 'rspec'
  gem 'simplecov', require: false
  gem 'simplecov-console', require: false
  gem "guard"
  gem 'guard-rspec', require: false
end
  • bundle install
  • rspec --init to create RSpec helper and file structure
  • guard init to setup guard file
  • guard init rspec to setup guard file with rspec
  • mkdir lib
  • add the following to the top of spec helper
require 'simplecov'
require 'simplecov-console'

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
  SimpleCov::Formatter::Console,
  # Want a nice code coverage website? Uncomment this next line!
  # SimpleCov::Formatter::HTMLFormatter
])
SimpleCov.start
  • create a Rakefile and paste in the following:
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new :spec

task default: [:spec]
  • add the following line to .rspec: --color --format documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment