From 3f15991dc9394f6a2bd850e60ee54730bfffbc8b Mon Sep 17 00:00:00 2001 From: Rafael Lima Date: Thu, 26 Sep 2013 19:04:03 -0300 Subject: [PATCH] Refactory spec_helper --- spec/spec_helper.rb | 25 +++++-------------------- spec/support/bitstamp_setup.rb | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 spec/support/bitstamp_setup.rb diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 897b937..46474b7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,6 +8,10 @@ require 'bitstamp' +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[File.expand_path("./spec/support/**/*.rb")].each { |f| require f } + # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| config.treat_symbols_as_metadata_keys_with_true_values = true @@ -19,23 +23,4 @@ # the seed, which is printed after each run. # --seed 1234 config.order = 'random' - - config.before(:all) {} - config.before(:each) do - # The famous singleton problem - Bitstamp.setup do |config| - config.key = nil - config.secret = nil - end - end - config.after(:all) {} - config.after(:each) {} -end - -def read_bitstamp_yaml - Bitstamp.setup do |config| - raise "You must set environment variable BITSTAMP_KEY and BITSTAMP_SECRET with your username and password to run specs." if ENV['BITSTAMP_KEY'].nil? or ENV['BITSTAMP_SECRET'].nil? - config.key = ENV['BITSTAMP_KEY'] - config.secret = ENV['BITSTAMP_SECRET'] - end -end +end \ No newline at end of file diff --git a/spec/support/bitstamp_setup.rb b/spec/support/bitstamp_setup.rb new file mode 100644 index 0000000..aa854f0 --- /dev/null +++ b/spec/support/bitstamp_setup.rb @@ -0,0 +1,17 @@ +RSpec.configure do |config| + config.before(:each) do + # The famous singleton problem + Bitstamp.setup do |config| + config.key = nil + config.secret = nil + end + end +end + +def read_bitstamp_yaml + Bitstamp.setup do |config| + raise "You must set environment variable BITSTAMP_KEY and BITSTAMP_SECRET with your username and password to run specs." if ENV['BITSTAMP_KEY'].nil? or ENV['BITSTAMP_SECRET'].nil? + config.key = ENV['BITSTAMP_KEY'] + config.secret = ENV['BITSTAMP_SECRET'] + end +end