Skip to content
Browse files

Issue #68 working on tests

* lib/jaribio/execution.rb (record_results): default plans to empty
array
* lib/jaribio/rspec_formatter.rb (close): default plans to empty array
* spec/lib/jaribio/rspec_formatter_spec.rb: adding tests
* spec/lib/jaribio/execution_spec.rb: new file
  • Loading branch information...
1 parent c7530c4 commit 9babe4bea14215665d2eb2b65c86cd25dff61a8c Brian Jones committed Apr 5, 2012
View
4 jaribio_formatter/lib/jaribio/execution.rb
@@ -5,8 +5,8 @@ module Jaribio
class Execution < RemoteObject
self.prefix = '/plans/:plan_id/cases/:test_case_id/'
- def self.record_results(records, plans = nil)
- if plans.nil?
+ def self.record_results(records, plans = [])
+ if plans.size == 0
plans = Jaribio::Plan.find(:all, :from => :open)
end
View
2 jaribio_formatter/lib/jaribio/rspec_formatter.rb
@@ -100,7 +100,7 @@ def close()
end
end
- plans = nil
+ plans = []
# create executions for specific plans only
if RSpec.configuration.jaribio_plans.size > 0
RSpec.configuration.jaribio_plans.each do |plan_id|
View
8 jaribio_formatter/spec/lib/jaribio/execution_spec.rb
@@ -0,0 +1,8 @@
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+
+describe "Jaribio::Result" do
+ describe "#record_results" do
+ it "finds open plans"
+ it "creates new executions for open plans and existing test cases"
+ end
+end
View
50 jaribio_formatter/spec/lib/jaribio/rspec_formatter_spec.rb
@@ -96,7 +96,50 @@ def verify_key_and_description(example, expected_key, expected_description)
end
it "has output indicating when a specified key does not exist in Jaribio"
- it "creates new executions for open plans and existing test cases"
+
+ describe "#close" do
+ let(:formatter) { Jaribio::RSpecFormatter.new(output) }
+ let!(:configuration) {
+ double("config",
+ :jaribio_url => 'http://localhost/jaribio',
+ :jaribio_api_key => 'api_key',
+ :jaribio_timeout => 10,
+ :treat_symbols_as_metadata_keys_with_true_values? => true)
+ }
+
+ before do
+ RSpec.should_receive(:configuration).at_least(:once).and_return(configuration)
+ Jaribio::Execution.should_receive(:record_results)
+ end
+
+ it "creates missing test cases" do
+ configuration.should_receive(:jaribio_auto_create).and_return(true)
+ configuration.should_receive(:jaribio_plans).and_return([])
+
+ Jaribio::TestCase.should_receive(:find).and_return(nil)
+ test_case = double("Jaribio::TestCase")
+ Jaribio::TestCase.should_receive(:new).and_return(test_case)
+ test_case.should_receive(:save)
+
+ example = example_group.example("example 1", :jaribio_key => 'abc123') { fail }
+ example_group.run(formatter)
+ formatter.close()
+ end
+
+ it "finds configured plans" do
+ configuration.should_receive(:jaribio_auto_create).and_return(false)
+ configuration.should_receive(:jaribio_plans).twice.and_return([1])
+
+ plan = double("Jaribio::Plan")
+ plan.should_receive(:open?).and_return(true)
+ Jaribio::Plan.should_receive(:find).with(1).once.and_return(plan)
+
+ example = example_group.example("example 1", :jaribio_key => 'abc123') { fail }
+ example_group.run(formatter)
+ formatter.close()
+ end
+
+ end
describe "can configure" do
@@ -117,9 +160,4 @@ def verify_key_and_description(example, expected_key, expected_description)
end
end
- describe "when configured to create test cases" do
- it "creates new test cases if the test case does not exist"
- it "creates new executions for open plans and new test cases"
- end
-
end

0 comments on commit 9babe4b

Please sign in to comment.
Something went wrong with that request. Please try again.