Skip to content

Instantly share code, notes, and snippets.

@elvanja
Created November 19, 2012 07:11
Show Gist options
  • Save elvanja/4109371 to your computer and use it in GitHub Desktop.
Save elvanja/4109371 to your computer and use it in GitHub Desktop.
Spec helper without Rails
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
# Requires all extra / autoload paths, @see /config/initializers/auto_require.rb
# Recommendation: do not rely on autoload for domain objects, use this just for specs
unless defined?(Rails)
%W(
app/persistence
app/representers
app/use_cases
app/values
lib
).each do |autoload_path|
Dir[File.expand_path("../../#{autoload_path}/**/*.rb", __FILE__)].each { |f| require f }
end
end
RSpec.configure do |config|
# disable should syntax, it wil become obsolete in future RSpec releases
# http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
config.expect_with :rspec do |c|
c.syntax = :expect
end
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment