Permalink
Browse files

Add xspecify and xexample as temp pending hooks.

Thanks to Ben Mabey for the suggestion.
  • Loading branch information...
1 parent 06991c4 commit b5fa88268d247b4f6b23f1aa437ab1bae54aadfe @dchelimsky dchelimsky committed Aug 25, 2011
View
@@ -19,6 +19,7 @@ As of 2.7.0, you must explicity `require "rspec/autorun"` unless you use the
* Friendly error message when shared context cannot be found (Sławosz
Sławiński)
* Clear formatters when resetting config (John Bintz)
+ * Add xspecify and xexample as temp-pending methods (David Chelimsky)
* Bug fixes
* Include Rake::DSL to remove deprecation warnings in Rake > 0.8.7 (Pivotal
@@ -77,22 +77,35 @@ Feature: pending examples
And the output should contain "Expected pending 'something else getting finished' to fail. No Error was raised."
And the output should contain "pending_with_passing_block_spec.rb:3"
- Scenario: temporarily pending by changing "it" to "xit"
- Given a file named "pending_with_xit_spec.rb" with:
+ Scenario: temporarily pending by prefixing `it`, `specify`, or `example` with an x
+ Given a file named "temporarily_pending_spec.rb" with:
"""
describe "an example" do
xit "is pending using xit" do
- true.should be(true)
+ end
+
+ xspecify "is pending using xspecify" do
+ end
+
+ xexample "is pending using xexample" do
end
end
"""
- When I run `rspec pending_with_xit_spec.rb`
+ When I run `rspec temporarily_pending_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 "3 examples, 0 failures, 3 pending"
And the output should contain:
"""
Pending:
an example is pending using xit
+ # Not Yet Implemented
+ # ./temporarily_pending_spec.rb:2
+ an example is pending using xspecify
+ # Not Yet Implemented
+ # ./temporarily_pending_spec.rb:5
+ an example is pending using xexample
+ # Not Yet Implemented
+ # ./temporarily_pending_spec.rb:8
"""
Scenario: example with no docstring and pending method using documentation formatter
@@ -60,10 +60,14 @@ class << self
alias_example_to :it
alias_example_to :specify
- alias_example_to :focused, :focused => true, :focus => true
- alias_example_to :focus, :focused => true, :focus => true
- alias_example_to :pending, :pending => true
- alias_example_to :xit, :pending => true
+
+ alias_example_to :pending, :pending => true
+ alias_example_to :xexample, :pending => true
+ alias_example_to :xit, :pending => true
+ alias_example_to :xspecify, :pending => true
+
+ alias_example_to :focused, :focused => true, :focus => true
+ alias_example_to :focus, :focused => true, :focus => true
def self.define_nested_shared_group_method(new_name, report_label=nil)
module_eval(<<-END_RUBY, __FILE__, __LINE__)
@@ -607,6 +607,23 @@ def metadata_hash(*args)
end
end
+ matcher :add_a_pending_example_with do |method_name|
+ match do |group|
+ group = ExampleGroup.describe
+ group.send(method_name, "is pending") { }
+ group.run
+ group.examples.first.should be_pending
+ end
+ end
+
+ %w[pending xit xspecify xexample].each do |method_name|
+ describe "##{method_name}" do
+ it "generates a pending example" do
+ ExampleGroup.describe.should add_a_pending_example_with(method_name)
+ end
+ end
+ end
+
describe "adding examples" do
it "allows adding an example using 'it'" do
@@ -615,13 +632,6 @@ def metadata_hash(*args)
group.examples.size.should eq(1)
end
- it "allows adding a pending example using 'xit'" do
- group = ExampleGroup.describe
- group.xit("is pending") { }
- group.run
- group.examples.first.should be_pending
- end
-
it "exposes all examples at examples" do
group = ExampleGroup.describe
group.it("should do something 1") { }

0 comments on commit b5fa882

Please sign in to comment.