Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* lib/jaribio/plan.rb: now inherits from RemoteObject * lib/jaribio/record.rb (initialize): fixed some bugs * lib/jaribio/remote_object.rb: new file, this is a base class for our active_resource objects that will automatically add the needed api_key query parameter as needed * lib/jaribio_formatter.rb: fixing some requires * spec/lib/jaribio/record_spec.rb: new spec * spec/lib/jaribio/rspec_formatter_spec.rb: fixed the spec related to results which was wrong before * spec/spec_helper.rb: require in jaribio_formatter instead of jaribio-formatter
- Loading branch information
Brian Jones
committed
Mar 6, 2012
1 parent
397d679
commit 93c2ed4
Showing
7 changed files
with
64 additions
and
21 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'active_resource' | ||
require 'active_support/core_ext/class/attribute_accessors' | ||
|
||
module Jaribio | ||
class RemoteObject < ActiveResource::Base | ||
cattr_accessor :api_key | ||
|
||
# use json, not xml | ||
self.format = :json | ||
|
||
# set timeout to 5 seconds (does not affect DNS lookups generally) | ||
self.timeout = 5 | ||
|
||
class << self | ||
def query_string(options) | ||
options = {} if options.nil? | ||
options[:api_key] = api_key unless api_key.nil? | ||
super(options) | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
%w(rspec_formatter.rb record.rb formatter/version.rb).each do |file| | ||
%w(remote_object plan rspec_formatter record formatter/version).each do |file| | ||
require File.expand_path(File.join(File.dirname(__FILE__), 'jaribio', file)) | ||
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,28 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') | ||
|
||
describe "Jaribio::Record" do | ||
describe "#failed?" do | ||
it "is true when not set" do | ||
Jaribio::Record.new().failed?.should be_true | ||
end | ||
|
||
it "is true when state is FAIL" do | ||
Jaribio::Record.new(:state => Jaribio::Record::FAIL).failed?.should be_true | ||
end | ||
|
||
it "is false when state is PASS" do | ||
Jaribio::Record.new(:state => Jaribio::Record::PASS).failed?.should be_false | ||
end | ||
end | ||
|
||
describe "#eql?" do | ||
let(:attributes) { Hash.new(:key => 'key', :description => 'description', :state => Jaribio::Record::PASS) } | ||
|
||
it "true if attributes are eql?" do | ||
a = Jaribio::Record.new(attributes) | ||
b = Jaribio::Record.new(attributes) | ||
a.should eql(b) | ||
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