Permalink
Browse files

Support pending specs

  • Loading branch information...
1 parent bac0348 commit 26e394c1305e5ea2f154c79e6225c6864c933148 Dan Hansen and Davis W. Frank committed Mar 1, 2013
@@ -2,7 +2,12 @@ module Jasmine
module Formatters
class Console < Struct.new(:results)
def summary
- "#{pluralize(results.size, 'spec')}, #{pluralize(results.failures.size, 'failure')}"
+ summary = "#{pluralize(results.size, 'spec')}, " +
+ "#{pluralize(results.failures.size, 'failure')}"
+
+ summary += ", #{pluralize(results.pending_specs.size, 'pending spec')}" unless results.pending_specs.empty?
+
+ summary
end
def failures
@@ -10,6 +10,12 @@ def failures
}
end
+ def pending_specs
+ @results.select { |result|
+ result.status == "pending"
+ }
+ end
+
def size
@results.size
end
@@ -3,7 +3,7 @@
describe Jasmine::Formatters::Console do
describe "#failures" do
it "shows the failure messages" do
- results = OpenStruct.new(:size => 2, :failures => [failing_result, failing_result])
+ results = OpenStruct.new(:size => 2, :failures => [failing_result, failing_result], :pending_specs => [])
subject = Jasmine::Formatters::Console.new(results)
subject.failures.should match(/a suite with a failing spec/)
@@ -15,15 +15,15 @@
describe "#summary" do
describe "when the full suite passes" do
it "shows the spec counts" do
- results = OpenStruct.new(:size => 1, :failures => [])
+ results = OpenStruct.new(:size => 1, :failures => [], :pending_specs => [])
subject = Jasmine::Formatters::Console.new(results)
subject.summary.should match(/1 spec/)
subject.summary.should match(/0 failures/)
end
it "shows the spec counts (pluralized)" do
- results = OpenStruct.new(:size => 2, :failures => [])
+ results = OpenStruct.new(:size => 2, :failures => [], :pending_specs=> [])
subject = Jasmine::Formatters::Console.new(results)
subject.summary.should match(/2 specs/)
@@ -33,21 +33,47 @@
describe "when there are failures" do
it "shows the spec counts" do
- results = OpenStruct.new(:size => 2, :failures => [failing_result])
+ results = OpenStruct.new(:size => 2, :failures => [failing_result], :pending_specs=> [])
subject = Jasmine::Formatters::Console.new(results)
subject.summary.should match(/2 specs/)
subject.summary.should match(/1 failure/)
end
it "shows the spec counts (pluralized)" do
- results = OpenStruct.new(:size => 2, :failures => [failing_result, failing_result])
+ results = OpenStruct.new(:size => 2, :failures => [failing_result, failing_result], :pending_specs=> [])
subject = Jasmine::Formatters::Console.new(results)
subject.summary.should match(/2 specs/)
subject.summary.should match(/2 failures/)
end
end
+
+ describe "when there are pending specs" do
+ it "shows the spec counts" do
+ results = OpenStruct.new(:size => 2, :failures => [failing_result], :pending_specs => [pending_result])
+ subject = Jasmine::Formatters::Console.new(results)
+
+ subject.summary.should match(/1 pending spec/)
+ end
+
+ it "shows the spec counts (pluralized)" do
+ results = OpenStruct.new(:size => 2, :failures => [], :pending_specs => [pending_result, pending_result])
+ subject = Jasmine::Formatters::Console.new(results)
+
+ subject.summary.should match(/2 pending specs/)
+ end
+ end
+
+ describe "when there are no pending specs" do
+
+ it "should not mention pending specs" do
+ results = OpenStruct.new(:size => 2, :failures => [], :pending_specs => [])
+ subject = Jasmine::Formatters::Console.new(results)
+
+ subject.summary.should_not match(/pending spec[s]/)
+ end
+ end
end
def failing_result
@@ -59,4 +85,8 @@ def failing_result
def passing_result
OpenStruct.new(passing_raw_result)
end
+
+ def pending_result
+ OpenStruct.new(pending_raw_result)
+ end
end
View
@@ -2,7 +2,7 @@
describe Jasmine::Results do
describe "#failures" do
- it "should report a failure count" do
+ it "should report all the failing spec" do
subject = Jasmine::Results.new([failing_raw_result, failing_raw_result])
subject.failures.size.should == 2
@@ -11,6 +11,16 @@
end
end
+ describe "#pending_specs" do
+ it "should report all the pending specs" do
+ subject = Jasmine::Results.new([pending_raw_result, pending_raw_result])
+ subject.pending_specs.size.should == 2
+
+ subject = Jasmine::Results.new([pending_raw_result, passing_raw_result])
+ subject.pending_specs.size.should == 1
+ end
+ end
+
describe "#size" do
it "should report the spec count" do
subject = Jasmine::Results.new([failing_raw_result, failing_raw_result])
View
@@ -59,6 +59,10 @@ def passing_raw_result
raw_result("passed")
end
+def pending_raw_result
+ raw_result("pending")
+end
+
def failing_raw_result
raw_result("failed", {
"id" => 124,

0 comments on commit 26e394c

Please sign in to comment.