-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from infertux/on_ruby
Refactor on_ruby helper to handle Ruby 2.0
- Loading branch information
Showing
13 changed files
with
469 additions
and
503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
require 'helper' | ||
|
||
class TestCommandGuesser < Test::Unit::TestCase | ||
on_ruby '1.9' do | ||
def self.should_guess_command_name(expectation, *argv) | ||
argv.each do |args| | ||
should "return '#{expectation}' for '#{args}'" do | ||
SimpleCov::CommandGuesser.original_run_command = args | ||
assert_equal expectation, SimpleCov::CommandGuesser.guess | ||
end | ||
def self.should_guess_command_name(expectation, *argv) | ||
argv.each do |args| | ||
should "return '#{expectation}' for '#{args}'" do | ||
SimpleCov::CommandGuesser.original_run_command = args | ||
assert_equal expectation, SimpleCov::CommandGuesser.guess | ||
end | ||
end | ||
|
||
should_guess_command_name "Unit Tests", '/some/path/test/units/foo_bar_test.rb', 'test/units/foo.rb', 'test/foo.rb', 'test/{models,helpers,unit}/**/*_test.rb' | ||
should_guess_command_name "Functional Tests", '/some/path/test/functional/foo_bar_controller_test.rb', 'test/{controllers,mailers,functional}/**/*_test.rb' | ||
should_guess_command_name "Integration Tests", '/some/path/test/integration/foo_bar_controller_test.rb', 'test/integration/**/*_test.rb' | ||
should_guess_command_name "Cucumber Features", 'features', 'cucumber', 'cucumber features' | ||
should_guess_command_name "RSpec", '/some/path/spec/foo.rb' | ||
should_guess_command_name "Unit Tests", 'some_arbitrary_command with arguments' # Because Test::Unit const is defined! | ||
end | ||
end | ||
|
||
should_guess_command_name "Unit Tests", '/some/path/test/units/foo_bar_test.rb', 'test/units/foo.rb', 'test/foo.rb', 'test/{models,helpers,unit}/**/*_test.rb' | ||
should_guess_command_name "Functional Tests", '/some/path/test/functional/foo_bar_controller_test.rb', 'test/{controllers,mailers,functional}/**/*_test.rb' | ||
should_guess_command_name "Integration Tests", '/some/path/test/integration/foo_bar_controller_test.rb', 'test/integration/**/*_test.rb' | ||
should_guess_command_name "Cucumber Features", 'features', 'cucumber', 'cucumber features' | ||
should_guess_command_name "RSpec", '/some/path/spec/foo.rb' | ||
should_guess_command_name "Unit Tests", 'some_arbitrary_command with arguments' # Because Test::Unit const is defined! | ||
end if SimpleCov.usable? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
require 'helper' | ||
|
||
class TestFileList < Test::Unit::TestCase | ||
on_ruby "1.9" do | ||
context "With a file list from a result" do | ||
setup do | ||
original_result = {source_fixture('sample.rb') => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil], | ||
source_fixture('app/models/user.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil], | ||
source_fixture('app/controllers/sample_controller.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]} | ||
@file_list = SimpleCov::Result.new(original_result).files | ||
end | ||
context "With a file list from a result" do | ||
setup do | ||
original_result = {source_fixture('sample.rb') => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil], | ||
source_fixture('app/models/user.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil], | ||
source_fixture('app/controllers/sample_controller.rb') => [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]} | ||
@file_list = SimpleCov::Result.new(original_result).files | ||
end | ||
|
||
should("have 13 covered_lines") { assert_equal 13, @file_list.covered_lines } | ||
should("have 2 missed_lines") { assert_equal 2, @file_list.missed_lines } | ||
should("have 18 never_lines") { assert_equal 18, @file_list.never_lines } | ||
should("have 15 lines_of_code") { assert_equal 15, @file_list.lines_of_code } | ||
should("have 3 skipped_lines") { assert_equal 3, @file_list.skipped_lines } | ||
should("have 13 covered_lines") { assert_equal 13, @file_list.covered_lines } | ||
should("have 2 missed_lines") { assert_equal 2, @file_list.missed_lines } | ||
should("have 18 never_lines") { assert_equal 18, @file_list.never_lines } | ||
should("have 15 lines_of_code") { assert_equal 15, @file_list.lines_of_code } | ||
should("have 3 skipped_lines") { assert_equal 3, @file_list.skipped_lines } | ||
|
||
should "have correct covered_percent" do | ||
assert_equal 100.0*13/15, @file_list.covered_percent | ||
end | ||
should "have correct covered_percent" do | ||
assert_equal 100.0*13/15, @file_list.covered_percent | ||
end | ||
end | ||
end | ||
end if SimpleCov.usable? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,78 @@ | ||
require 'helper' | ||
|
||
class TestFilters < Test::Unit::TestCase | ||
on_ruby '1.9' do | ||
context "A source file initialized with some coverage data" do | ||
setup do | ||
@source_file = SimpleCov::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]) | ||
end | ||
context "A source file initialized with some coverage data" do | ||
setup do | ||
@source_file = SimpleCov::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]) | ||
end | ||
|
||
should "not match a new SimpleCov::StringFilter 'foobar'" do | ||
assert !SimpleCov::StringFilter.new('foobar').matches?(@source_file) | ||
end | ||
should "not match a new SimpleCov::StringFilter 'foobar'" do | ||
assert !SimpleCov::StringFilter.new('foobar').matches?(@source_file) | ||
end | ||
|
||
should "not match a new SimpleCov::StringFilter 'some/path'" do | ||
assert !SimpleCov::StringFilter.new('some/path').matches?(@source_file) | ||
end | ||
should "not match a new SimpleCov::StringFilter 'some/path'" do | ||
assert !SimpleCov::StringFilter.new('some/path').matches?(@source_file) | ||
end | ||
|
||
should "match a new SimpleCov::StringFilter 'test/fixtures'" do | ||
assert SimpleCov::StringFilter.new('test/fixtures').matches?(@source_file) | ||
end | ||
should "match a new SimpleCov::StringFilter 'test/fixtures'" do | ||
assert SimpleCov::StringFilter.new('test/fixtures').matches?(@source_file) | ||
end | ||
|
||
should "match a new SimpleCov::StringFilter 'test/fixtures/sample.rb'" do | ||
assert SimpleCov::StringFilter.new('test/fixtures/sample.rb').matches?(@source_file) | ||
end | ||
should "match a new SimpleCov::StringFilter 'test/fixtures/sample.rb'" do | ||
assert SimpleCov::StringFilter.new('test/fixtures/sample.rb').matches?(@source_file) | ||
end | ||
|
||
should "match a new SimpleCov::StringFilter 'sample.rb'" do | ||
assert SimpleCov::StringFilter.new('sample.rb').matches?(@source_file) | ||
end | ||
should "match a new SimpleCov::StringFilter 'sample.rb'" do | ||
assert SimpleCov::StringFilter.new('sample.rb').matches?(@source_file) | ||
end | ||
|
||
should "not match a new SimpleCov::BlockFilter that is not applicable" do | ||
assert !SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'foo.rb'}).matches?(@source_file) | ||
end | ||
should "not match a new SimpleCov::BlockFilter that is not applicable" do | ||
assert !SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'foo.rb'}).matches?(@source_file) | ||
end | ||
|
||
should "match a new SimpleCov::BlockFilter that is applicable" do | ||
assert SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'sample.rb'}).matches?(@source_file) | ||
end | ||
should "match a new SimpleCov::BlockFilter that is applicable" do | ||
assert SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'sample.rb'}).matches?(@source_file) | ||
end | ||
end | ||
|
||
context "with no filters set up and a basic source file in an array" do | ||
setup do | ||
SimpleCov.filters = [] | ||
@files = [SimpleCov::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])] | ||
end | ||
context "with no filters set up and a basic source file in an array" do | ||
setup do | ||
SimpleCov.filters = [] | ||
@files = [SimpleCov::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])] | ||
end | ||
|
||
should "return 0 items after executing SimpleCov.filtered on files when using a 'sample' string filter" do | ||
SimpleCov.add_filter "sample" | ||
assert_equal 0, SimpleCov.filtered(@files).count | ||
end | ||
should "return 0 items after executing SimpleCov.filtered on files when using a 'sample' string filter" do | ||
SimpleCov.add_filter "sample" | ||
assert_equal 0, SimpleCov.filtered(@files).count | ||
end | ||
|
||
should "return 0 items after executing SimpleCov.filtered on files when using a 'test/fixtures/' string filter" do | ||
SimpleCov.add_filter "test/fixtures" | ||
assert_equal 0, SimpleCov.filtered(@files).count | ||
end | ||
should "return 0 items after executing SimpleCov.filtered on files when using a 'test/fixtures/' string filter" do | ||
SimpleCov.add_filter "test/fixtures" | ||
assert_equal 0, SimpleCov.filtered(@files).count | ||
end | ||
|
||
should "return 1 item after executing SimpleCov.filtered on files when using a 'fooo' string filter" do | ||
SimpleCov.add_filter "fooo" | ||
assert_equal 1, SimpleCov.filtered(@files).count | ||
end | ||
should "return 1 item after executing SimpleCov.filtered on files when using a 'fooo' string filter" do | ||
SimpleCov.add_filter "fooo" | ||
assert_equal 1, SimpleCov.filtered(@files).count | ||
end | ||
|
||
should "return 0 items after executing SimpleCov.filtered on files when using a block filter that returns true" do | ||
SimpleCov.add_filter do |src_file| | ||
true | ||
end | ||
assert_equal 0, SimpleCov.filtered(@files).count | ||
should "return 0 items after executing SimpleCov.filtered on files when using a block filter that returns true" do | ||
SimpleCov.add_filter do |src_file| | ||
true | ||
end | ||
assert_equal 0, SimpleCov.filtered(@files).count | ||
end | ||
|
||
should "return 1 item after executing SimpleCov.filtered on files when using an always-false block filter" do | ||
SimpleCov.add_filter do |src_file| | ||
false | ||
end | ||
assert_equal 1, SimpleCov.filtered(@files).count | ||
should "return 1 item after executing SimpleCov.filtered on files when using an always-false block filter" do | ||
SimpleCov.add_filter do |src_file| | ||
false | ||
end | ||
assert_equal 1, SimpleCov.filtered(@files).count | ||
end | ||
|
||
should "return a FileList after filtering" do | ||
SimpleCov.add_filter "fooo" | ||
assert_equal SimpleCov::FileList, SimpleCov.filtered(@files).class | ||
end | ||
should "return a FileList after filtering" do | ||
SimpleCov.add_filter "fooo" | ||
assert_equal SimpleCov::FileList, SimpleCov.filtered(@files).class | ||
end | ||
end | ||
end | ||
end if SimpleCov.usable? |
Oops, something went wrong.