Skip to content

Instantly share code, notes, and snippets.

@padi
Last active September 1, 2016 05:53
Show Gist options
  • Select an option

  • Save padi/237e41aa80e62819d81a87cceace80b3 to your computer and use it in GitHub Desktop.

Select an option

Save padi/237e41aa80e62819d81a87cceace80b3 to your computer and use it in GitHub Desktop.
Fat-free RSpec test setup for Plain Old Ruby Objects within Rails.
# spec_helper for faster testing of plain old ruby objects
# To check if a spec is ready for this spec_helper,
# just replace `require "spec_helper"`
# with `require "slim_spec_helper"` and edit
# this file as necessary
# Loads a subset of the gemfile using bundler/inline
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
if File.exists?(ENV['BUNDLE_GEMFILE'])
gemfile(true) do
source 'https://rubygems.org'
gem 'rails'
gem 'rspec-rails'
gem 'pry'
end
else
$stderr.puts "No BUNDLE_GEMFILE"
raise e
end
# Add services to $LOAD_PATH
$:.unshift File.expand_path('../app/services', File.dirname(__FILE__))
RSpec.configure do |config|
config.mock_with :rspec
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment