simplecov 0.4.2 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -1
- data/.rvmrc +1 -1
- data/.travis.yml +9 -0
- data/CHANGELOG.md +64 -0
- data/Gemfile +7 -0
- data/README.rdoc +83 -66
- data/Rakefile +3 -7
- data/cucumber.yml +13 -0
- data/features/config_adapters.feature +44 -0
- data/features/config_autoload.feature +46 -0
- data/features/config_command_name.feature +33 -0
- data/features/config_coverage_dir.feature +20 -0
- data/features/config_deactivate_merging.feature +42 -0
- data/features/config_merge_timeout.feature +38 -0
- data/features/config_project_name.feature +27 -0
- data/features/config_styles.feature +93 -0
- data/features/cucumber_basic.feature +29 -0
- data/features/merging_test_unit_and_rspec.feature +44 -0
- data/features/rspec_basic.feature +31 -0
- data/features/rspec_groups_and_filters_basic.feature +29 -0
- data/features/rspec_groups_and_filters_complex.feature +35 -0
- data/features/rspec_without_simplecov.feature +20 -0
- data/features/step_definitions/html_steps.rb +42 -0
- data/features/step_definitions/simplecov_steps.rb +61 -0
- data/features/step_definitions/transformers.rb +13 -0
- data/features/step_definitions/web_steps.rb +64 -0
- data/features/support/env.rb +26 -0
- data/features/test_unit_basic.feature +34 -0
- data/features/test_unit_groups_and_filters_basic.feature +29 -0
- data/features/test_unit_groups_and_filters_complex.feature +35 -0
- data/features/test_unit_without_simplecov.feature +20 -0
- data/lib/simplecov.rb +15 -30
- data/lib/simplecov/adapters.rb +3 -26
- data/lib/simplecov/command_guesser.rb +2 -2
- data/lib/simplecov/configuration.rb +21 -21
- data/lib/simplecov/defaults.rb +48 -0
- data/lib/simplecov/file_list.rb +44 -0
- data/lib/simplecov/filter.rb +5 -5
- data/lib/simplecov/formatter.rb +1 -1
- data/lib/simplecov/formatter/simple_formatter.rb +1 -1
- data/lib/simplecov/jruby_float_fix.rb +1 -1
- data/lib/simplecov/merge_helpers.rb +4 -4
- data/lib/simplecov/result.rb +33 -30
- data/lib/simplecov/result_merger.rb +30 -13
- data/lib/simplecov/source_file.rb +78 -21
- data/lib/simplecov/version.rb +1 -1
- data/simplecov.gemspec +25 -22
- data/test/faked_project/Gemfile +6 -0
- data/test/faked_project/Rakefile +8 -0
- data/test/faked_project/cucumber.yml +13 -0
- data/test/faked_project/features/step_definitions/my_steps.rb +23 -0
- data/test/faked_project/features/support/env.rb +12 -0
- data/test/faked_project/features/test_stuff.feature +6 -0
- data/test/faked_project/lib/faked_project.rb +11 -0
- data/test/faked_project/lib/faked_project/framework_specific.rb +18 -0
- data/test/faked_project/lib/faked_project/meta_magic.rb +24 -0
- data/test/faked_project/lib/faked_project/some_class.rb +29 -0
- data/test/faked_project/spec/faked_spec.rb +11 -0
- data/test/faked_project/spec/meta_magic_spec.rb +10 -0
- data/test/faked_project/spec/some_class_spec.rb +10 -0
- data/test/faked_project/spec/spec_helper.rb +15 -0
- data/test/faked_project/test/faked_test.rb +11 -0
- data/test/faked_project/test/meta_magic_test.rb +13 -0
- data/test/faked_project/test/some_class_test.rb +15 -0
- data/test/faked_project/test/test_helper.rb +16 -0
- data/test/fixtures/app/controllers/sample_controller.rb +2 -2
- data/test/fixtures/app/models/user.rb +2 -2
- data/test/fixtures/frameworks/rspec_bad.rb +1 -1
- data/test/fixtures/frameworks/rspec_good.rb +1 -1
- data/test/fixtures/frameworks/testunit_bad.rb +1 -1
- data/test/fixtures/frameworks/testunit_good.rb +1 -1
- data/test/fixtures/resultset1.rb +1 -1
- data/test/fixtures/resultset2.rb +1 -1
- data/test/fixtures/sample.rb +8 -2
- data/test/helper.rb +17 -4
- data/test/shoulda_macros.rb +2 -2
- data/test/test_1_8_fallbacks.rb +3 -3
- data/test/test_command_guesser.rb +3 -3
- data/test/test_file_list.rb +24 -0
- data/test/test_filters.rb +18 -13
- data/test/test_merge_helpers.rb +23 -23
- data/test/test_result.rb +40 -31
- data/test/test_return_codes.rb +5 -5
- data/test/test_source_file.rb +39 -15
- data/test/test_source_file_line.rb +22 -22
- metadata +191 -53
- data/.document +0 -5
@@ -0,0 +1,13 @@
|
|
1
|
+
<%
|
2
|
+
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
3
|
+
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
4
|
+
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
|
5
|
+
interp_opts = if defined?(RUBY_ENGINE)
|
6
|
+
" --tags ~@exclude-#{RUBY_ENGINE}"
|
7
|
+
else
|
8
|
+
''
|
9
|
+
end
|
10
|
+
%>
|
11
|
+
default: <%= std_opts %><%= interp_opts %> features
|
12
|
+
wip: --tags @wip:30 --wip features<%= interp_opts %>
|
13
|
+
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip<%= interp_opts %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Given /^I want to keep stuff simple$/ do
|
2
|
+
1.should == 1
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^I write my cukes for the fake project$/ do
|
6
|
+
1.should == 1
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^I make all neccessary tests in a single step$/ do
|
10
|
+
FakedProject.foo.should == 'bar'
|
11
|
+
|
12
|
+
FrameworkSpecific.cucumber.should == "Only tested in Cucumber"
|
13
|
+
|
14
|
+
FakedProject.a_class_method.should == "this is a mixed-in class method"
|
15
|
+
|
16
|
+
FakedProject.new.an_instance_method.should == "this is a mixed-in instance method"
|
17
|
+
FakedProject.new.dynamic.should == "A dynamically defined instance method"
|
18
|
+
|
19
|
+
something = SomeClass.new("foo")
|
20
|
+
something.reverse.should == 'oof'
|
21
|
+
something.compare_with('foo').should be_true
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
|
3
|
+
# We're injecting simplecov_config via aruba in cucumber here
|
4
|
+
# depending on what the test case is...
|
5
|
+
begin
|
6
|
+
require File.join(File.dirname(__FILE__), 'simplecov_config')
|
7
|
+
rescue LoadError => err
|
8
|
+
$stderr.puts "No SimpleCov config file found!"
|
9
|
+
end
|
10
|
+
|
11
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '/../../lib'))
|
12
|
+
require 'faked_project'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# A pile of methods that only get tested in their frameworks
|
2
|
+
# and thus make this file only 100% covered when all framework test
|
3
|
+
# results are merged
|
4
|
+
module FrameworkSpecific
|
5
|
+
class << self
|
6
|
+
def cucumber
|
7
|
+
"Only tested in Cucumber"
|
8
|
+
end
|
9
|
+
|
10
|
+
def rspec
|
11
|
+
"Only tested in RSpec"
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_unit
|
15
|
+
"Only tested in Test/Unit"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module MetaMagic
|
2
|
+
module ClassMethods
|
3
|
+
def a_class_method
|
4
|
+
"this is a mixed-in class method"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module InstanceMethods
|
9
|
+
def an_instance_method
|
10
|
+
"this is a mixed-in instance method"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.included(base)
|
15
|
+
base.send :extend, ClassMethods
|
16
|
+
base.send :include, InstanceMethods
|
17
|
+
|
18
|
+
base.class_eval do
|
19
|
+
define_method :dynamic do
|
20
|
+
"A dynamically defined instance method"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class SomeClass
|
2
|
+
attr_reader :label
|
3
|
+
attr_accessor :some_attr
|
4
|
+
|
5
|
+
def initialize(label)
|
6
|
+
@label = label
|
7
|
+
end
|
8
|
+
|
9
|
+
def reverse
|
10
|
+
label.reverse
|
11
|
+
end
|
12
|
+
|
13
|
+
def compare_with(item)
|
14
|
+
if item == label
|
15
|
+
return true
|
16
|
+
else
|
17
|
+
raise "Item does not match label"
|
18
|
+
end
|
19
|
+
|
20
|
+
rescue => err
|
21
|
+
false
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def uncovered
|
27
|
+
"private method"
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FakedProject do
|
4
|
+
it "should have added a class method to FakedProject" do
|
5
|
+
FakedProject.a_class_method.should == "this is a mixed-in class method"
|
6
|
+
end
|
7
|
+
|
8
|
+
its(:an_instance_method) { should == "this is a mixed-in instance method" }
|
9
|
+
its(:dynamic) { should == "A dynamically defined instance method" }
|
10
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
|
3
|
+
# We're injecting simplecov_config via aruba in cucumber here
|
4
|
+
# depending on what the test case is...
|
5
|
+
begin
|
6
|
+
require File.join(File.dirname(__FILE__), 'simplecov_config')
|
7
|
+
rescue LoadError => err
|
8
|
+
$stderr.puts "No SimpleCov config file found!"
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'faked_project'
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
# some (optional) config here
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MetaMagicTest < Test::Unit::TestCase
|
4
|
+
def test_class_methods
|
5
|
+
assert_equal "this is a mixed-in class method", FakedProject.a_class_method
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_instance_methods
|
9
|
+
p = FakedProject.new
|
10
|
+
assert_equal "this is a mixed-in instance method", p.an_instance_method
|
11
|
+
assert_equal "A dynamically defined instance method", p.dynamic
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SomeClassTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@instance = SomeClass.new("foo")
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_reverse
|
9
|
+
assert_equal 'oof', @instance.reverse
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_comparison
|
13
|
+
assert @instance.compare_with('foo')
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
|
3
|
+
# We're injecting simplecov_config via aruba in cucumber here
|
4
|
+
# depending on what the test case is...
|
5
|
+
begin
|
6
|
+
require File.join(File.dirname(__FILE__), 'simplecov_config')
|
7
|
+
rescue LoadError => err
|
8
|
+
$stderr.puts "No SimpleCov config file found!"
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'faked_project'
|
12
|
+
|
13
|
+
require 'test/unit'
|
14
|
+
|
15
|
+
class Test::Unit::TestCase
|
16
|
+
end
|
data/test/fixtures/resultset1.rb
CHANGED
data/test/fixtures/resultset2.rb
CHANGED
data/test/fixtures/sample.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'bundler/setup'
|
3
2
|
require 'simplecov'
|
4
|
-
|
5
3
|
require 'test/unit'
|
6
4
|
require 'shoulda'
|
7
5
|
|
@@ -11,11 +9,26 @@ class Test::Unit::TestCase
|
|
11
9
|
def source_fixture(filename)
|
12
10
|
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', filename))
|
13
11
|
end
|
14
|
-
|
12
|
+
|
15
13
|
# Keep 1.8-rubies from complaining about missing tests in each file that covers only 1.9 functionality
|
16
14
|
def default_test
|
17
15
|
end
|
18
16
|
end
|
19
17
|
|
20
18
|
require 'shoulda_macros'
|
21
|
-
Test::Unit::TestCase.send :extend, ShouldaMacros
|
19
|
+
Test::Unit::TestCase.send :extend, ShouldaMacros
|
20
|
+
|
21
|
+
# Taken from http://stackoverflow.com/questions/4459330/how-do-i-temporarily-redirect-stderr-in-ruby
|
22
|
+
require "stringio"
|
23
|
+
|
24
|
+
def capture_stderr
|
25
|
+
# The output stream must be an IO-like object. In this case we capture it in
|
26
|
+
# an in-memory IO object so we can return the string value. You can assign any
|
27
|
+
# IO object here.
|
28
|
+
previous_stderr, $stderr = $stderr, StringIO.new
|
29
|
+
yield
|
30
|
+
$stderr.string
|
31
|
+
ensure
|
32
|
+
# Restore the previous value of stderr (typically equal to STDERR).
|
33
|
+
$stderr = previous_stderr
|
34
|
+
end
|
data/test/shoulda_macros.rb
CHANGED
@@ -2,10 +2,10 @@ module ShouldaMacros
|
|
2
2
|
#
|
3
3
|
# Simple block helper for running certain tests only on specific ruby versions.
|
4
4
|
# The given strings will be regexp-matched against RUBY_VERSION
|
5
|
-
#
|
5
|
+
#
|
6
6
|
def on_ruby(*ruby_versions)
|
7
7
|
context "On Ruby #{RUBY_VERSION}" do
|
8
8
|
yield
|
9
9
|
end if ruby_versions.any? {|v| RUBY_VERSION =~ /#{v}/ }
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
data/test/test_1_8_fallbacks.rb
CHANGED
@@ -11,15 +11,15 @@ class Test18FallBacks < Test::Unit::TestCase
|
|
11
11
|
should "return false when calling SimpleCov.start" do
|
12
12
|
assert_equal false, SimpleCov.start
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
should "return false when calling SimpleCov.start with a block" do
|
16
16
|
assert_equal false, SimpleCov.start { raise "Shouldn't reach this!?" }
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
should "return false when calling SimpleCov.configure with a block" do
|
20
20
|
assert_equal false, SimpleCov.configure { raise "Shouldn't reach this!?" }
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
should "allow to define an adapter" do
|
24
24
|
begin
|
25
25
|
SimpleCov.adapters.define 'testadapter' do
|