Skip to content

Commit

Permalink
even shorter description of Proc location
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Apr 23, 2011
1 parent aecda56 commit 52eca40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/rspec/core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,11 @@ def alias_it_should_behave_like_to(new_name, report_label = '')
end

PROC_HEX_NUMBER = /0x[0-9a-f]+@/
PROJECT_DIR = File.expand_path('.')

def exclusion_filter=(filter)
def filter.description
reject { |k, v| DEFAULT_EXCLUSION_FILTERS[k] == v }.inspect.gsub(PROC_HEX_NUMBER, '')
reject { |k, v| DEFAULT_EXCLUSION_FILTERS[k] == v }.inspect.gsub(PROC_HEX_NUMBER, '').gsub(PROJECT_DIR, '.').gsub(' (lambda)','')
end

settings[:exclusion_filter] = filter
Expand Down
9 changes: 7 additions & 2 deletions spec/rspec/core/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,18 @@ def metadata_hash(*args)
config.exclusion_filter.description.should == { :unless => :custom_filter }.inspect
end

it 'does not include the unnecessary hex number for lambdas' do
# check the assumption of this example
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.exclusion_filter[:foo] = lambda { }
config.filter_run_excluding :bar => lambda { }
config.exclusion_filter.description.should_not include('0x')
config.exclusion_filter.description.should_not include(project_dir)
config.exclusion_filter.description.should_not include(' (lambda)')
end
end

Expand Down

0 comments on commit 52eca40

Please sign in to comment.