From 7ce3dfa2770b2022f909164a0f24f8f38d8d8fb2 Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 2 May 2017 18:17:04 +0200 Subject: Refs #3178; Simplecov bogus config (almost) fixed --- .rspec | 1 + spec/lib/range_ext_spec.rb | 17 +++++++++++++++++ spec/spec_helper.rb | 19 ++++++++++--------- 3 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 spec/lib/range_ext_spec.rb diff --git a/.rspec b/.rspec index 53607ea52..986f6f5c1 100644 --- a/.rspec +++ b/.rspec @@ -1 +1,2 @@ --colour +-r spec_helper diff --git a/spec/lib/range_ext_spec.rb b/spec/lib/range_ext_spec.rb new file mode 100644 index 000000000..0e2365b5e --- /dev/null +++ b/spec/lib/range_ext_spec.rb @@ -0,0 +1,17 @@ +RSpec.describe Range do + context "intersection" do + it "is nil (sic) for two distinct ranges" do + expect( (1..2).intersection(3..4) ).to be_nil + end + + it "is the smaller of two if one is part of the other" do + expect( (1..2).intersection(0..3) ).to eq 1..2 + expect( (0..2).intersection(1..2) ).to eq 1..2 + end + + it "is the intersection otherwise" do + expect( (1..3) & (2..4) ).to eq 2..3 + expect( (2..4) & (1..3) ).to eq 2..3 + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cda753efe..891235b81 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,14 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' +require 'simplecov' +# if ENV['JOB_NAME'] +# require 'simplecov-rcov' +# SimpleCov.formatters = [ +# SimpleCov::Formatter::HTMLFormatter, +# SimpleCov::Formatter::RcovFormatter +# ] +# end +SimpleCov.start 'rails' + ENV["RAILS_ENV"] = 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' @@ -16,15 +26,6 @@ require 'simplecov' require 'sidekiq/testing' Sidekiq::Testing.fake! -if ENV['JOB_NAME'] - require 'simplecov-rcov' - SimpleCov.formatters = [ - SimpleCov::Formatter::HTMLFormatter, - SimpleCov::Formatter::RcovFormatter - ] -end -SimpleCov.start 'rails' - # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are # run as spec files by default. This means that files in spec/support that end -- cgit v1.2.3