Skip to content

Commit

Permalink
Fix Coveralls merged result reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Spataro committed Sep 30, 2014
1 parent 121afcd commit a3312c4
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 17 deletions.
9 changes: 0 additions & 9 deletions .simplecov

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -6,5 +6,5 @@ rvm:
- 2.0.0
- 2.1.0
script:
- bundle exec rake ci:spec && bundle exec rake ci:cucumber
- bundle exec rake ci:spec && bundle exec rake ci:cucumber && bundle exec rake coveralls:push
bundler_args: --without debugger development
5 changes: 5 additions & 0 deletions Rakefile
Expand Up @@ -7,6 +7,7 @@ require 'rake'
begin
require 'rdoc/task'
require 'jeweler'
require 'coveralls/rake/task'
rescue LoadError
# ignore; these gems can be excluded from the bundle using --without
end
Expand Down Expand Up @@ -78,6 +79,10 @@ if defined?(Jeweler)
CLEAN.include('pkg')
end

if defined?(Coveralls)
Coveralls::RakeTask.new
end

RightDevelop::CI::RakeTask.new
RightDevelop::Git::RakeTask.new
RightDevelop::S3::RakeTask.new
23 changes: 17 additions & 6 deletions features/step_definitions/ruby_steps.rb
Expand Up @@ -12,17 +12,24 @@
basedir = File.expand_path('../../..', __FILE__)
File.open(gemfile, 'w') do |file|
file.puts "source 'https://rubygems.org'"
file.puts "gem 'right_develop', :path=>'#{basedir}'"
file.puts "gem 'coveralls'" unless RUBY_VERSION =~ /^1\.8/
file.puts "gem 'right_develop', :path=>'#{basedir}', :require=>false"
file.puts "gem 'coveralls', :require=>false" unless RUBY_VERSION =~ /^1\.8/
end
end

unless File.exist?(simplecov)
File.open(simplecov, 'w') do |file|
dir = File.expand_path('../../../coverage', __FILE__)
root_dir = File.expand_path('../../..', __FILE__)
coverage_dir = File.join(root_dir, 'coverage')
# IMPORTANT: each scenario we invoke must use a distinct command_name, else coverage results
# will overwrite one another!
suite = "cucumber[#{scenario_location}]"

file.puts "require 'coveralls'"
file.puts "Coveralls.wear! do"
file.puts " coverage_dir '#{dir}'"
file.puts "Coveralls.wear_merged! do"
file.puts " command_name '#{suite}'"
file.puts " root '#{root_dir}'"
file.puts " coverage_dir '#{coverage_dir}'"
file.puts "end"
end
end
Expand Down Expand Up @@ -50,6 +57,7 @@
step 'a Rakefile'
rakefile = ruby_app_path('Rakefile')
File.open(rakefile, 'w') do |file|
file.puts "require 'simplecov'" unless RUBY_VERSION =~ /^1\.8/
file.puts "require 'right_develop'"
file.puts "#{mod}::RakeTask.new"
end
Expand All @@ -69,6 +77,7 @@
step 'a Rakefile'
rakefile = ruby_app_path('Rakefile')
File.open(rakefile, 'w') do |file|
file.puts "require 'simplecov'" unless RUBY_VERSION =~ /^1\.8/
file.puts "require 'right_develop'"
content.split("\n").each do |line|
file.puts line
Expand All @@ -83,7 +92,7 @@
File.open(spec, 'w') do |file|
# ensure that our formatter's coverage gets handled
file.puts "require 'simplecov'" unless RUBY_VERSION =~ /^1\.8/

file.puts "require 'right_develop'"
# always include one passing test case as a baseline
file.puts "describe String do"
file.puts " it 'has a size' do"
Expand Down Expand Up @@ -121,6 +130,7 @@
File.open(spec, 'w') do |file|
# ensure that our formatter's coverage gets handled
file.puts "require 'simplecov'" unless RUBY_VERSION =~ /^1\.8/
file.puts "require 'right_develop'"

content.split("\n").each do |line|
file.puts line
Expand All @@ -143,6 +153,7 @@
File.open(env, 'w') do |file|
# ensure that our formatter's coverage gets handled
file.puts "require 'simplecov'" unless RUBY_VERSION =~ /^1\.8/
file.puts "require 'right_develop'"
end
end

Expand Down
6 changes: 6 additions & 0 deletions features/support/env.rb
Expand Up @@ -77,8 +77,14 @@ def ruby_app_shell(cmd, options={})

module RightDevelopWorld
include RubyAppHelper

# @return [String] the filename and line of the current scenario
attr_reader :scenario_location
end

Before do |scenario|
@scenario_location = scenario.location
end
# The Cucumber world
World(RightDevelopWorld)

Expand Down
7 changes: 6 additions & 1 deletion spec/spec_helper.rb
Expand Up @@ -26,6 +26,11 @@
$: << lib_dir unless $:.include?(lib_dir)

require 'coveralls'
Coveralls.wear!
Coveralls.wear_merged! do
command_name 'spec'
add_filter '/features/'
add_filter '/spec/'
add_filter '/vendor/'
end

require 'right_develop'

0 comments on commit a3312c4

Please sign in to comment.