-
Notifications
You must be signed in to change notification settings - Fork 560
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 #207 from mikerobe/profiles
rename adapters "profiles"
- Loading branch information
Showing
9 changed files
with
97 additions
and
86 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 was deleted.
Oops, something went wrong.
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,44 @@ | ||
@test_unit @config @profiles | ||
Feature: | ||
|
||
In order to re-use SimpleCov settings across projects, | ||
profiles can be defined that hold configuration settings | ||
that can be loaded at once. | ||
|
||
Background: | ||
Given SimpleCov for Test/Unit is configured with: | ||
""" | ||
require 'simplecov' | ||
""" | ||
|
||
Scenario: Defining and using a custom profile | ||
Given a file named ".simplecov" with: | ||
""" | ||
SimpleCov.profiles.define 'custom_command' do | ||
command_name "Profile Command" | ||
end | ||
SimpleCov.start do | ||
load_profile 'test_frameworks' | ||
load_profile 'custom_command' | ||
end | ||
""" | ||
|
||
When I open the coverage report generated with `bundle exec rake test` | ||
Then I should see "4 files in total." | ||
And I should see "using Profile Command" within "#footer" | ||
|
||
Scenario: Using existing profile in custom profile and supplying profile to start command | ||
Given a file named ".simplecov" with: | ||
""" | ||
SimpleCov.profiles.define 'my_profile' do | ||
load_profile 'test_frameworks' | ||
command_name "My Profile" | ||
end | ||
SimpleCov.start 'my_profile' | ||
""" | ||
|
||
When I open the coverage report generated with `bundle exec rake test` | ||
Then I should see "4 files in total." | ||
And I should see "using My Profile" within "#footer" |
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,29 +1,29 @@ | ||
# | ||
# Adapters are glorified SimpleCov configuration procs that can be easily | ||
# Profiles are SimpleCov configuration procs that can be easily | ||
# loaded using SimpleCov.start :rails and defined using | ||
# SimpleCov.adapters.define :foo do | ||
# SimpleCov.profiles.define :foo do | ||
# # SimpleCov configuration here, same as in SimpleCov.configure | ||
# end | ||
# | ||
class SimpleCov::Adapters < Hash | ||
class SimpleCov::Profiles < Hash | ||
# | ||
# Define a SimpleCov adapter: | ||
# SimpleCov.adapters.define 'rails' do | ||
# Define a SimpleCov profile: | ||
# SimpleCov.profiles.define 'rails' do | ||
# # Same as SimpleCov.configure do .. here | ||
# end | ||
# | ||
def define(name, &blk) | ||
name = name.to_sym | ||
raise "SimpleCov Adapter '#{name}' is already defined" unless self[name].nil? | ||
raise "SimpleCov Profile '#{name}' is already defined" unless self[name].nil? | ||
self[name] = blk | ||
end | ||
|
||
# | ||
# Applies the adapter of given name on SimpleCov.configure | ||
# Applies the profile of given name on SimpleCov.configure | ||
# | ||
def load(name) | ||
name = name.to_sym | ||
raise "Could not find SimpleCov Adapter called '#{name}'" unless has_key?(name) | ||
raise "Could not find SimpleCov Profile called '#{name}'" unless has_key?(name) | ||
SimpleCov.configure(&self[name]) | ||
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