Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

friendly description for both inclusion and exclusion filters

  • Loading branch information...
commit c66049af16c55bbce502c83b34c2a5f12bee4879 1 parent 52eca40
@dchelimsky dchelimsky authored
View
18 lib/rspec/core/configuration.rb
@@ -337,23 +337,21 @@ def alias_it_should_behave_like_to(new_name, report_label = '')
RSpec::Core::ExampleGroup.alias_it_should_behave_like_to(new_name, report_label)
end
- PROC_HEX_NUMBER = /0x[0-9a-f]+@/
- PROJECT_DIR = File.expand_path('.')
+ module Describable
+ PROC_HEX_NUMBER = /0x[0-9a-f]+@/
+ PROJECT_DIR = File.expand_path('.')
- def exclusion_filter=(filter)
- def filter.description
+ def description
reject { |k, v| DEFAULT_EXCLUSION_FILTERS[k] == v }.inspect.gsub(PROC_HEX_NUMBER, '').gsub(PROJECT_DIR, '.').gsub(' (lambda)','')
end
+ end
- settings[:exclusion_filter] = filter
+ def exclusion_filter=(filter)
+ settings[:exclusion_filter] = filter.extend(Describable)
end
def filter=(filter)
- def filter.description
- inspect.gsub(PROC_HEX_NUMBER, '')
- end
-
- settings[:filter] = filter
+ settings[:filter] = filter.extend(Describable)
end
def filter_run_including(*args)
View
16 spec/rspec/core/configuration_spec.rb
@@ -519,12 +519,24 @@ def metadata_hash(*args)
describe "#filter" do
describe "#description" do
- it 'does not include the unnecessary hex number for lambdas' do
+ # it 'does not include the unnecessary hex number for lambdas' do
# check the assumption of this example
+ # lambda { }.inspect.should include('0x')
+
+ # config.filter_run :bar => lambda { }
+ # config.filter.description.should_not include('0x')
+ # end
+ it 'cleans up the description' do
+ # check the assumptions of this example
+ project_dir = File.expand_path('.')
+ lambda { }.inspect.should include(project_dir)
lambda { }.inspect.should include('0x')
+ lambda { }.inspect.should include(' (lambda)') if RUBY_VERSION > '1.9'
- config.filter_run :bar => lambda { }
+ config.filter_run :foo => lambda { }
config.filter.description.should_not include('0x')
+ config.filter.description.should_not include(project_dir)
+ config.filter.description.should_not include(' (lambda)')
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.