Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for local and instance vars to SimpleCov DSL #238

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions features/config_styles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,34 @@ Feature:
Then I should see "4 files in total."
And I should see "using Config Test Runner" within "#footer"

Scenario: Inside start block, using instance var from outside
Given a file named ".simplecov" with:
"""
@filter = 'test'
SimpleCov.start do
add_filter @filter
command_name 'Config Test Runner'
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 Config Test Runner" within "#footer"

Scenario: Inside start block, using local var from outside
Given a file named ".simplecov" with:
"""
filter = 'test'
SimpleCov.start do
add_filter filter
command_name 'Config Test Runner'
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 Config Test Runner" within "#footer"

Scenario: Explicitly before start block
Given a file named ".simplecov" with:
"""
Expand Down
3 changes: 2 additions & 1 deletion lib/simplecov/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'fileutils'
require 'docile'
#
# Bundles the configuration options used for SimpleCov. All methods
# defined here are usable from SimpleCov directly. Please check out
Expand Down Expand Up @@ -118,7 +119,7 @@ def adapters
#
def configure(&block)
return false unless SimpleCov.usable?
instance_exec(&block)
Docile.dsl_eval(self, &block)
end

#
Expand Down
1 change: 1 addition & 0 deletions simplecov.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Gem::Specification.new do |gem|

gem.add_dependency 'multi_json'
gem.add_dependency 'simplecov-html', '~> 0.7.1'
gem.add_dependency 'docile', '~> 1.1.0'

gem.add_development_dependency 'appraisal', '~> 0.5.1'
gem.add_development_dependency 'rake', '~> 10.0.3'
Expand Down