Skip to content

Commit

Permalink
Improved pending output.
Browse files Browse the repository at this point in the history
Also removed overrides of to_s and inspect on Example for easier
debugging.
  • Loading branch information
dchelimsky committed Jul 12, 2010
1 parent cbd5a8a commit ff13202
Showing 5 changed files with 33 additions and 26 deletions.
13 changes: 11 additions & 2 deletions features/hooks/around_hooks.feature
Original file line number Diff line number Diff line change
@@ -155,7 +155,12 @@ Feature: around hooks
"""
When I run "rspec ./around_block_with_implicit_pending_example.rb"
Then the output should contain "1 example, 0 failures, 1 pending"
And the output should contain "implicit pending example should be detected as Not Yet Implemented (Not Yet Implemented)"
And the output should contain:
"""
Pending:
implicit pending example should be detected as Not Yet Implemented
# Not Yet Implemented
"""


Scenario: explicitly pending examples should be detected as pending
@@ -173,7 +178,11 @@ Feature: around hooks
"""
When I run "rspec ./around_block_with_explicit_pending_example.rb"
Then the output should contain "1 example, 0 failures, 1 pending"
And the output should contain "explicit pending example should be detected as pending (No reason given)"
And the output should contain:
"""
explicit pending example should be detected as pending
# No reason given
"""

Scenario: multiple around hooks in the same scope are all run
Given a file named "around_hooks_in_same_scope.rb" with:
24 changes: 18 additions & 6 deletions features/pending/pending_examples.feature
Original file line number Diff line number Diff line change
@@ -28,9 +28,15 @@ Feature: pending examples
"""
When I run "rspec ./pending_without_block_spec.rb"
Then the exit status should be 0
And the output should contain "1 example, 0 failures, 1 pending"
And the output should contain "(something else getting finished)"
And the output should contain "pending_without_block_spec.rb:2"
And the output should contain:
"""
1 example, 0 failures, 1 pending
Pending:
an example is implemented but waiting
# something else getting finished
# ./pending_without_block_spec.rb:2
"""

Scenario: pending any arbitary reason, with a block that fails
Given a file named "pending_with_failing_block_spec.rb" with:
@@ -45,9 +51,15 @@ Feature: pending examples
"""
When I run "rspec ./pending_with_failing_block_spec.rb"
Then the exit status should be 0
And the output should contain "1 example, 0 failures, 1 pending"
And the output should contain "(something else getting finished)"
And the output should contain "pending_with_failing_block_spec.rb:2"
And the output should contain:
"""
1 example, 0 failures, 1 pending
Pending:
an example is implemented but waiting
# something else getting finished
# ./pending_with_failing_block_spec.rb:2
"""

Scenario: pending any arbitary reason, with a block that passes
Given a file named "pending_with_passing_block_spec.rb" with:
3 changes: 0 additions & 3 deletions lib/rspec/core/example.rb
Original file line number Diff line number Diff line change
@@ -12,9 +12,6 @@ def self.delegate_to_metadata(*keys)

delegate_to_metadata :description, :full_description, :execution_result, :file_path, :pending

alias_method :inspect, :full_description
alias_method :to_s, :full_description

def initialize(example_group_class, desc, options, example_block=nil)
@example_group_class, @options, @example_block = example_group_class, options, example_block
@metadata = @example_group_class.metadata.for_example(desc, options)
7 changes: 4 additions & 3 deletions lib/rspec/core/formatters/base_text_formatter.rb
Original file line number Diff line number Diff line change
@@ -72,8 +72,9 @@ def dump_pending
output.puts
output.puts "Pending:"
pending_examples.each do |pending_example|
output.puts " #{pending_example} (#{pending_example.metadata[:execution_result][:pending_message]})"
output.puts grey(" # #{format_caller(pending_example.metadata[:location])}")
output.puts yellow(" #{pending_example.full_description}")
output.puts grey(" # #{pending_example.metadata[:execution_result][:pending_message]}")
output.puts grey(" # #{format_caller(pending_example.metadata[:location])}")
end
end
end
@@ -127,7 +128,7 @@ def pluralize(count, string)
end

def format_caller(caller_info)
caller_info.to_s.split(':in `block').first
backtrace_line(caller_info.to_s.split(':in `block').first)
end

end
12 changes: 0 additions & 12 deletions spec/rspec/core/example_spec.rb
Original file line number Diff line number Diff line change
@@ -16,18 +16,6 @@
end
end

describe '#inspect' do
it "should return 'group description - description'" do
example_instance.inspect.should == 'group description example description'
end
end

describe '#to_s' do
it "should return #inspect" do
example_instance.to_s.should == example_instance.inspect
end
end

describe '#described_class' do
it "returns the class (if any) of the outermost example group" do
described_class.should == RSpec::Core::Example

0 comments on commit ff13202

Please sign in to comment.