-
Notifications
You must be signed in to change notification settings - Fork 552
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added version checks to unit tests so they only get executed on
applicable ruby versions. Also added Rake Task 'multitest', which will run rake test on 1.9.2, 1.8.7 and 1.8.6 via rvm. Use `rake multitest:bundle` to bundle install on all multitest rubies. Also added a fix that made test suites fail on 1.8.6 in a mysterious fashion. See issue #18
- Loading branch information
Showing
12 changed files
with
430 additions
and
377 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module ShouldaMacros | ||
# | ||
# Simple block helper for running certain tests only on specific ruby versions. | ||
# The given strings will be regexp-matched against RUBY_VERSION | ||
# | ||
def on_ruby(*ruby_versions) | ||
yield if ruby_versions.any? {|v| RUBY_VERSION =~ /#{v}/ } | ||
end | ||
end |
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,18 +1,20 @@ | ||
require 'helper' | ||
|
||
class TestCommandGuesser < Test::Unit::TestCase | ||
def self.should_guess_command_name(expectation, *argv) | ||
argv.each do |args| | ||
should "return '#{expectation}' for '#{args}'" do | ||
assert_equal expectation, SimpleCov::CommandGuesser.guess(args) | ||
on_ruby '1.9' do | ||
def self.should_guess_command_name(expectation, *argv) | ||
argv.each do |args| | ||
should "return '#{expectation}' for '#{args}'" do | ||
assert_equal expectation, SimpleCov::CommandGuesser.guess(args) | ||
end | ||
end | ||
end | ||
end | ||
|
||
should_guess_command_name "Unit Tests", '/some/path/test/units/foo_bar_test.rb', 'test/units/foo.rb', 'test/foo.rb' | ||
should_guess_command_name "Functional Tests", '/some/path/test/functional/foo_bar_controller_test.rb' | ||
should_guess_command_name "Integration Tests", '/some/path/test/integration/foo_bar_controller_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 "some_arbitrary_command with arguments", 'some_arbitrary_command with arguments' | ||
should_guess_command_name "Unit Tests", '/some/path/test/units/foo_bar_test.rb', 'test/units/foo.rb', 'test/foo.rb' | ||
should_guess_command_name "Functional Tests", '/some/path/test/functional/foo_bar_controller_test.rb' | ||
should_guess_command_name "Integration Tests", '/some/path/test/integration/foo_bar_controller_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 "some_arbitrary_command with arguments", 'some_arbitrary_command with arguments' | ||
end | ||
end |
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,73 +1,75 @@ | ||
require 'helper' | ||
|
||
class TestFilters < Test::Unit::TestCase | ||
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 | ||
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 | ||
|
||
should "pass a new SimpleCov::StringFilter 'foobar'" do | ||
assert SimpleCov::StringFilter.new('foobar').passes?(@source_file) | ||
end | ||
should "pass a new SimpleCov::StringFilter 'foobar'" do | ||
assert SimpleCov::StringFilter.new('foobar').passes?(@source_file) | ||
end | ||
|
||
should "pass a new SimpleCov::StringFilter 'some/path'" do | ||
assert SimpleCov::StringFilter.new('some/path').passes?(@source_file) | ||
end | ||
should "pass a new SimpleCov::StringFilter 'some/path'" do | ||
assert SimpleCov::StringFilter.new('some/path').passes?(@source_file) | ||
end | ||
|
||
should "not pass a new SimpleCov::StringFilter 'test/fixtures'" do | ||
assert !SimpleCov::StringFilter.new('test/fixtures').passes?(@source_file) | ||
end | ||
should "not pass a new SimpleCov::StringFilter 'test/fixtures'" do | ||
assert !SimpleCov::StringFilter.new('test/fixtures').passes?(@source_file) | ||
end | ||
|
||
should "not pass a new SimpleCov::StringFilter 'test/fixtures/sample.rb'" do | ||
assert !SimpleCov::StringFilter.new('test/fixtures/sample.rb').passes?(@source_file) | ||
end | ||
should "not pass a new SimpleCov::StringFilter 'test/fixtures/sample.rb'" do | ||
assert !SimpleCov::StringFilter.new('test/fixtures/sample.rb').passes?(@source_file) | ||
end | ||
|
||
should "not pass a new SimpleCov::StringFilter 'sample.rb'" do | ||
assert !SimpleCov::StringFilter.new('sample.rb').passes?(@source_file) | ||
end | ||
should "not pass a new SimpleCov::StringFilter 'sample.rb'" do | ||
assert !SimpleCov::StringFilter.new('sample.rb').passes?(@source_file) | ||
end | ||
|
||
should "pass a new SimpleCov::BlockFilter that is not applicable" do | ||
assert SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'foo.rb'}).passes?(@source_file) | ||
end | ||
should "pass a new SimpleCov::BlockFilter that is not applicable" do | ||
assert SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'foo.rb'}).passes?(@source_file) | ||
end | ||
|
||
should "not pass a new SimpleCov::BlockFilter that is applicable" do | ||
assert !SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'sample.rb'}).passes?(@source_file) | ||
should "not pass a new SimpleCov::BlockFilter that is applicable" do | ||
assert !SimpleCov::BlockFilter.new(Proc.new {|s| File.basename(s.filename) == 'sample.rb'}).passes?(@source_file) | ||
end | ||
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 | ||
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 | ||
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 | ||
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 | ||
assert_equal 1, SimpleCov.filtered(@files).count | ||
end | ||
end | ||
end |
Oops, something went wrong.