add coverage tool

This commit is contained in:
Anton Chuchkalov 2015-12-14 17:27:07 +04:00
parent 062aebe5f2
commit ba25c41082
3 changed files with 50 additions and 22 deletions

View File

@ -36,4 +36,5 @@ end
group :devepoment do
gem 'byebug'
gem 'guard-rspec', require: false
gem 'simplecov', require: false
end

View File

@ -60,6 +60,7 @@ GEM
gherkin (~> 2.12.0)
daemons (1.2.3)
diff-lcs (1.2.5)
docile (1.1.5)
em-websocket (0.3.8)
addressable (>= 2.1.1)
eventmachine (>= 0.12.9)
@ -291,6 +292,11 @@ GEM
json
redis (>= 3.0.6)
redis-namespace (>= 1.3.1)
simplecov (0.11.1)
docile (~> 1.1.0)
json (~> 1.8)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
sinatra (1.4.5)
rack (~> 1.4)
rack-protection (~> 1.4)
@ -352,9 +358,13 @@ DEPENDENCIES
rspec (~> 3.3)
rspec_junit_formatter
sidekiq (= 3.2.6)
simplecov
sinatra (= 1.4.5)
sinatra-contrib
sinatra-websocket
test-unit
thin (~> 1.5.1)
wisper
BUNDLED WITH
1.10.6

View File

@ -4,32 +4,49 @@ require 'factory_girl'
require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/inflector'
# setup load_path and require support files
root = File.join(File.dirname(__FILE__), "..")
$LOAD_PATH.push root unless $LOAD_PATH.include? root
# suppress output
original_stdout = $stdout
$stdout = File.open(File::NULL, "w")
Dir[("./spec/support/**/*.rb")].each { |f| require f }
Dir[("./spec/shared_contexts/**/*.rb")].each { |f| require f }
# Factory girl configuration
FactoryGirl.define do
# do not try to persist, but raise validation errors
to_create { |model| model.validate! }
def suppress_output!
original_stdout = $stdout
$stdout = File.open(File::NULL, "w")
RSpec.configure do |config|
config.after(:all) do
$stdout = original_stdout
end
end
end
FactoryGirl.find_definitions
def check_coverage
require 'simplecov'
SimpleCov.start do
add_filter { |src| src.filename =~ /spec\// }
end
end
def require_support_files
root = File.join(File.dirname(__FILE__), "..")
$LOAD_PATH.push root unless $LOAD_PATH.include?(root)
Dir[("#{root}/spec/support/**/*.rb")].each { |f| require f }
Dir[("#{root}/spec/shared_contexts/**/*.rb")].each { |f| require f }
end
def setup_factory_girl
FactoryGirl.define do
# do not persist, but raise validation errors
to_create { |model| model.validate! }
end
FactoryGirl.find_definitions
RSpec.configure { |config| config.include FactoryGirl::Syntax::Methods }
end
# extra configuration
suppress_output!
check_coverage if ENV['COVERAGE']
require_support_files
setup_factory_girl
# RSpec configuration
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.after(:all) do
$stdout = original_stdout
end
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.