Skip to content

Instantly share code, notes, and snippets.

@lcuevastodoit
Created June 11, 2023 19:41
Show Gist options
  • Save lcuevastodoit/6c1521737d28d74fec1521448787ea53 to your computer and use it in GitHub Desktop.
Save lcuevastodoit/6c1521737d28d74fec1521448787ea53 to your computer and use it in GitHub Desktop.
how to run RSpec tests without Rails
  • Run gem install rspec to install the RSpec gem globally
  • Create an spec folder
  • Configure RSpec:
require 'rspec'

 # load root location rb classes to test
Dir['./*.rb'].sort.each { |file| require file }
 # load /app folder rb classes to test
Dir['./app/**/*.rb'].sort.each { |file| require file }

RSpec.configure do |config|
   # add extra configuration here
end
  • create new specs on spec folder remember to add require 'spec_helper'at the beginning of the class
  • run from the root folder
  rspec spec -f d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment