forked from simplecov-ruby/simplecov
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace test/unit + shoulda with RSpec
- Loading branch information
Showing
58 changed files
with
808 additions
and
744 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
--require rspec/legacy_formatters | ||
--color | ||
--order random | ||
--warning |
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,29 @@ | ||
require "helper" | ||
|
||
# Tests that verify that on 1.8 versions of ruby, simplecov simply | ||
# does not launch and does not cause errors on the way | ||
# | ||
# TODO: This should be expanded upon all methods that could potentially | ||
# be called in a test/spec-helper simplecov config block | ||
# | ||
describe "Ruby 1.8 fallback" do | ||
it "return false when calling SimpleCov.start" do | ||
expect(SimpleCov.start).to be false | ||
end | ||
|
||
it "return false when calling SimpleCov.start with a block" do | ||
expect(SimpleCov.start { fail "Shouldn't reach this!" }).to be false | ||
end | ||
|
||
it "return false when calling SimpleCov.configure with a block" do | ||
expect(SimpleCov.configure { fail "Shouldn't reach this!" }).to be false | ||
end | ||
|
||
it "allow to define a profile" do | ||
expect do | ||
SimpleCov.profiles.define "testprofile" do | ||
add_filter "/config/" | ||
end | ||
end.not_to raise_error | ||
end | ||
end if RUBY_VERSION.start_with? "1.8" |
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,46 @@ | ||
require "helper" | ||
|
||
describe SimpleCov::CommandGuesser do | ||
subject { SimpleCov::CommandGuesser } | ||
it 'correctly guesses "Unit Tests" for unit tests' do | ||
subject.original_run_command = "/some/path/test/units/foo_bar_test.rb" | ||
expect(subject.guess).to eq("Unit Tests") | ||
subject.original_run_command = "test/units/foo.rb" | ||
expect(subject.guess).to eq("Unit Tests") | ||
subject.original_run_command = "test/foo.rb" | ||
expect(subject.guess).to eq("Unit Tests") | ||
subject.original_run_command = "test/{models,helpers,unit}/**/*_test.rb" | ||
expect(subject.guess).to eq("Unit Tests") | ||
end | ||
|
||
it 'correctly guesses "Functional Tests" for functional tests' do | ||
subject.original_run_command = "/some/path/test/functional/foo_bar_controller_test.rb" | ||
expect(subject.guess).to eq("Functional Tests") | ||
subject.original_run_command = "test/{controllers,mailers,functional}/**/*_test.rb" | ||
expect(subject.guess).to eq("Functional Tests") | ||
end | ||
|
||
it 'correctly guesses "Integration Tests" for integration tests' do | ||
subject.original_run_command = "/some/path/test/integration/foo_bar_controller_test.rb" | ||
expect(subject.guess).to eq("Integration Tests") | ||
subject.original_run_command = "test/integration/**/*_test.rb" | ||
expect(subject.guess).to eq("Integration Tests") | ||
end | ||
|
||
it 'correctly guesses "Cucumber Features" for cucumber features' do | ||
subject.original_run_command = "features" | ||
expect(subject.guess).to eq("Cucumber Features") | ||
subject.original_run_command = "cucumber" | ||
expect(subject.guess).to eq("Cucumber Features") | ||
end | ||
|
||
it 'correctly guesses "RSpec" for RSpec' do | ||
subject.original_run_command = "/some/path/spec/foo.rb" | ||
expect(subject.guess).to eq("RSpec") | ||
end | ||
|
||
it "defaults to RSpec because RSpec constant is defined" do | ||
subject.original_run_command = "some_arbitrary_command with arguments" | ||
expect(subject.guess).to eq("RSpec") | ||
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require "helper" | ||
|
||
# Test to verify correct handling of deleted files | ||
# See https://github.com/colszowka/simplecov/issues/9 | ||
describe "A source file which is subsequently deleted" do | ||
it "does not cause an error" do | ||
Dir.chdir(File.join(File.dirname(__FILE__), "fixtures")) do | ||
`ruby deleted_source_sample.rb` | ||
expect($?.exitstatus).to be_zero | ||
end | ||
end | ||
end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,40 @@ | ||
require "helper" | ||
|
||
describe SimpleCov::Result do | ||
subject 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, 2, 2, 0, nil, nil, 0, nil, nil, nil], | ||
} | ||
SimpleCov::Result.new(original_result).files | ||
end | ||
|
||
it "has 11 covered lines" do | ||
expect(subject.covered_lines).to eq(11) | ||
end | ||
|
||
it "has 3 missed lines" do | ||
expect(subject.missed_lines).to eq(3) | ||
end | ||
|
||
it "has 19 never lines" do | ||
expect(subject.never_lines).to eq(19) | ||
end | ||
|
||
it "has 14 lines of code" do | ||
expect(subject.lines_of_code).to eq(14) | ||
end | ||
|
||
it "has 3 skipped lines" do | ||
expect(subject.skipped_lines).to eq(3) | ||
end | ||
|
||
it "has the correct covered percent" do | ||
expect(subject.covered_percent).to eq(78.57142857142857) | ||
end | ||
|
||
it "has the correct covered strength" do | ||
expect(subject.covered_strength).to eq(0.9285714285714286) | ||
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
require "helper" | ||
|
||
describe SimpleCov::SourceFile do | ||
subject do | ||
SimpleCov::SourceFile.new(source_fixture("sample.rb"), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]) | ||
end | ||
|
||
it "doesn't match a new SimpleCov::StringFilter 'foobar'" do | ||
expect(SimpleCov::StringFilter.new("foobar")).not_to be_matches subject | ||
end | ||
|
||
it "doesn't match a new SimpleCov::StringFilter 'some/path'" do | ||
expect(SimpleCov::StringFilter.new("some/path")).not_to be_matches subject | ||
end | ||
|
||
it "matches a new SimpleCov::StringFilter 'spec/fixtures'" do | ||
expect(SimpleCov::StringFilter.new("spec/fixtures")).to be_matches subject | ||
end | ||
|
||
it "matches a new SimpleCov::StringFilter 'spec/fixtures/sample.rb'" do | ||
expect(SimpleCov::StringFilter.new("spec/fixtures/sample.rb")).to be_matches subject | ||
end | ||
|
||
it "matches a new SimpleCov::StringFilter 'sample.rb'" do | ||
expect(SimpleCov::StringFilter.new("sample.rb")).to be_matches subject | ||
end | ||
|
||
it "doesn't match a new SimpleCov::BlockFilter that is not applicable" do | ||
expect(SimpleCov::BlockFilter.new(proc { |s| File.basename(s.filename) == "foo.rb" })).not_to be_matches subject | ||
end | ||
|
||
it "matches a new SimpleCov::BlockFilter that is applicable" do | ||
expect(SimpleCov::BlockFilter.new(proc { |s| File.basename(s.filename) == "sample.rb" })).to be_matches subject | ||
end | ||
|
||
it "matches a new SimpleCov::ArrayFilter when 'sample.rb' is passed as array" do | ||
expect(SimpleCov::ArrayFilter.new(["sample.rb"])).to be_matches subject | ||
end | ||
|
||
it "doesn't match a new SimpleCov::ArrayFilter when a file path different than 'sample.rb' is passed as array" do | ||
expect(SimpleCov::ArrayFilter.new(["other_file.rb"])).not_to be_matches subject | ||
end | ||
|
||
it "matches a new SimpleCov::ArrayFilter when two file paths including 'sample.rb' are passed as array" do | ||
expect(SimpleCov::ArrayFilter.new(["sample.rb", "other_file.rb"])).to be_matches subject | ||
end | ||
|
||
context "with no filters set up and a basic source file in an array" do | ||
before do | ||
@prev_filters, SimpleCov.filters = SimpleCov.filters, [] | ||
end | ||
|
||
subject do | ||
[SimpleCov::SourceFile.new(source_fixture("sample.rb"), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil])] | ||
end | ||
|
||
after do | ||
SimpleCov.filters = @prev_filters | ||
end | ||
|
||
it 'returns 0 items after executing SimpleCov.filtered on files when using a "sample" string filter' do | ||
SimpleCov.add_filter "sample" | ||
expect(SimpleCov.filtered(subject).count).to be_zero | ||
end | ||
|
||
it 'returns 0 items after executing SimpleCov.filtered on files when using a "spec/fixtures" string filter' do | ||
SimpleCov.add_filter "spec/fixtures" | ||
expect(SimpleCov.filtered(subject).count).to be_zero | ||
end | ||
|
||
it 'returns 1 item after executing SimpleCov.filtered on files when using a "fooo" string filter' do | ||
SimpleCov.add_filter "fooo" | ||
expect(SimpleCov.filtered(subject).count).to eq(1) | ||
end | ||
|
||
it "returns 0 items after executing SimpleCov.filtered on files when using a block filter that returns true" do | ||
SimpleCov.add_filter do | ||
true | ||
end | ||
expect(SimpleCov.filtered(subject).count).to be_zero | ||
end | ||
|
||
it "returns 1 item after executing SimpleCov.filtered on files when using an always-false block filter" do | ||
SimpleCov.add_filter do | ||
false | ||
end | ||
expect(SimpleCov.filtered(subject).count).to eq(1) | ||
end | ||
|
||
it "returns a FileList after filtering" do | ||
SimpleCov.add_filter "fooo" | ||
expect(SimpleCov.filtered(subject)).to be_a SimpleCov::FileList | ||
end | ||
end | ||
end if SimpleCov.usable? |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.