forked from dchelimsky/rspec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added options hash to example group proxy.
- Loading branch information
1 parent
50ba934
commit a4b3aac
Showing
6 changed files
with
91 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This demonstrates the use of the options hash to support custom reporting. | ||
# To see the result, run this command from the project root: | ||
# | ||
# bin/spec --require examples/passing/options_formatter.rb examples/passing/options_example.rb \ | ||
# --format OptionsFormatter | ||
|
||
require File.dirname(__FILE__) + '/spec_helper' | ||
|
||
describe "this group will be reported", :report => true do | ||
it "this example will be reported", :report => true do | ||
# no-op | ||
end | ||
|
||
it "this example will not be reported", :report => false do | ||
# no-op | ||
end | ||
|
||
it "this example will also not be reported", :foo => 'bar' do | ||
# no-op | ||
end | ||
|
||
it "this example will also also not be reported" do | ||
# no-op | ||
end | ||
end | ||
|
||
describe "this group will not be reported", :report => false do | ||
it "though this example will", :report => true do | ||
# no-op | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# This is an example of how you can use a custom formatter to do custom | ||
# reporting. This formatter will only report example groups and examples that | ||
# have :report => true (or anything truthy) in the declaration. See | ||
# options_example.rb in this directory. | ||
|
||
require 'spec/runner/formatter/base_text_formatter' | ||
|
||
class OptionsFormatter < Spec::Runner::Formatter::BaseTextFormatter | ||
def example_started(proxy) | ||
if proxy.options[:report] | ||
puts proxy.description | ||
end | ||
end | ||
|
||
def example_group_started(proxy) | ||
if proxy.options[:report] | ||
puts proxy.description | ||
end | ||
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
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