rainforest 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6cbbfc3410b0696d478289fce462b081c2dc5f6
4
- data.tar.gz: 3f665a7a8ffb46ec8fc23d6dde9c296ca55cd474
3
+ metadata.gz: 5496746f5fddf8d06efaa1c314708342ab14e4e5
4
+ data.tar.gz: 5dfe782d311724c030f200bb878f2f5a164b11f9
5
5
  SHA512:
6
- metadata.gz: 442f253755bb2bcabeb923ce94e6cf1f6018f88317eeeeb5cea7d9ea75d461c85390346c44b94ff24813a79ddc4caeee7a17a1eb343fc1b858b9c7de29319fb8
7
- data.tar.gz: e4a9787bdd2fa079adce0bc6a7ad26c83a3c62d09f91bfb3becefece959f3fdfafbc1ec94dcc096b82bd575673bfdfe9f7192aa4d0eb678a46be2fdf7af28bfe
6
+ metadata.gz: 63f0afd4b748a9594acb335fb9673a36c4e4c42add4efeabd8bb46c570d03595e2c537cfa8bbecf311fc91dc1e7d1f4b4e35a2c1309a6207e2b3233897cc5398
7
+ data.tar.gz: f2bd530419fb69a8630e9b43a7ea15b1abc09a34e1036ebc4eb73aa79326cd040ef5f35231dc60357586809ea446b50d45dcd9244c6bffb3539cd2d842b9b4b5
data/.gitignore CHANGED
@@ -2,3 +2,8 @@
2
2
  /Gemfile.lock
3
3
  .rvmrc
4
4
  Gemfile.lock
5
+ <<<<<<< HEAD
6
+ tags
7
+ =======
8
+ .DS_Store
9
+ >>>>>>> adding_tests
@@ -1,10 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
- - 1.9.2
5
- - 1.9.3
6
3
  - 2.0.0
7
- gemfile:
8
- - gemfiles/default-with-activesupport.gemfile
9
- - gemfiles/json.gemfile
10
- - gemfiles/yajl.gemfile
4
+ - 1.9.3
@@ -1 +1,2 @@
1
1
  Jon Calhoun <joncalhoun@gmail.com>
2
+ Simon Mathieu <simon@rainforestqa.com>
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
- Installation
2
- ------------
1
+ [![Build Status](https://travis-ci.org/rainforestapp/rainforest-ruby.png?branch=master)](https://travis-ci.org/rainforestapp/rainforest-ruby)
2
+
3
+ # Installation
3
4
 
4
5
  Install the gem:
5
6
 
@@ -9,31 +10,17 @@ gem install rainforest
9
10
 
10
11
  Import the Rainforest client in your application:
11
12
 
12
- ```
13
+ ```ruby
13
14
  require 'rainforest'
14
15
  ```
15
16
 
16
- Requirements
17
- ------------
17
+ # Requirements
18
18
 
19
- * Ruby 1.8.7 or above. (Ruby 1.8.6 may work if you load
20
- ActiveSupport.)
19
+ * Ruby 1.9.3 or above.
21
20
  * rest-client, multi_json
22
21
 
23
- Development
24
- -----------
25
-
26
- Test cases can be run with: `bundle exec rake test`
27
-
28
-
29
- Docs
30
- ----
31
-
32
- You can find the Rainforest docs here: https://app.rainforestqa.com/docs
33
22
 
34
-
35
- Examples
36
- --------
23
+ # Examples
37
24
 
38
25
  ```ruby
39
26
  require 'rainforest'
@@ -51,6 +38,14 @@ run.delete # abort a run
51
38
 
52
39
 
53
40
  # Kick off a run with all tests
54
- new_run = Rainforest::Run.create(test: ["all"])
55
-
41
+ new_run = Rainforest::Run.create(tests: ["all"])
56
42
  ```
43
+
44
+ # Docs
45
+
46
+ You can find the Rainforest docs here: https://docs.rainforestqa.com/
47
+
48
+
49
+ # Development
50
+
51
+ Test cases can be run with: `bundle exec rake test`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 1.0.4
@@ -215,8 +215,6 @@ module Rainforest
215
215
  raise invalid_request_error error, rcode, rbody, error_obj
216
216
  when 401
217
217
  raise authentication_error error, rcode, rbody, error_obj
218
- when 402
219
- raise card_error error, rcode, rbody, error_obj
220
218
  else
221
219
  raise api_error error, rcode, rbody, error_obj
222
220
  end
@@ -224,17 +222,12 @@ module Rainforest
224
222
  end
225
223
 
226
224
  def self.invalid_request_error(error, rcode, rbody, error_obj)
227
- InvalidRequestError.new(error[:message], error[:param], rcode,
225
+ InvalidRequestError.new("Invalid Request Error", error[:param], rcode,
228
226
  rbody, error_obj)
229
227
  end
230
228
 
231
229
  def self.authentication_error(error, rcode, rbody, error_obj)
232
- AuthenticationError.new(error[:message], rcode, rbody, error_obj)
233
- end
234
-
235
- def self.card_error(error, rcode, rbody, error_obj)
236
- CardError.new(error[:message], error[:param], error[:code],
237
- rcode, rbody, error_obj)
230
+ AuthenticationError.new("Authentication Error", rcode, rbody, error_obj)
238
231
  end
239
232
 
240
233
  def self.api_error(error, rcode, rbody, error_obj)
@@ -4,9 +4,7 @@ module Rainforest
4
4
  module ClassMethods
5
5
  def all(filters={}, api_key=nil)
6
6
  response, api_key = Rainforest.request(:get, url, api_key, filters)
7
-
8
- # TODO(jon): Suggest an object attribute be returned instead of this.
9
- Util.convert_to_rainforest_object(response, api_key, class_name.downcase)
7
+ Util.convert_to_rainforest_object(response, api_key)
10
8
  end
11
9
  end
12
10
 
@@ -50,9 +50,6 @@ module Rainforest
50
50
  @previous_metadata = values[:metadata]
51
51
  removed = partial ? Set.new : Set.new(@values.keys - values.keys)
52
52
  added = Set.new(values.keys - @values.keys)
53
- # Wipe old state before setting new. This is useful for e.g. updating a
54
- # customer, where there is no persistent card parameter. Mark those values
55
- # which don't persist as transient
56
53
 
57
54
  instance_eval do
58
55
  remove_accessors(removed)
@@ -17,20 +17,19 @@ module Rainforest
17
17
 
18
18
  def self.object_classes
19
19
  @object_classes ||= {
20
- 'test' => Test,
21
- 'run' => Run,
20
+ 'Run' => Run,
22
21
  'list' => ListObject
23
22
  }
24
23
  end
25
24
 
26
25
  # TODO(jon): Suggest an object attribute be returned instead of this.
27
- def self.convert_to_rainforest_object(resp, api_key, klass = nil)
26
+ def self.convert_to_rainforest_object(resp, api_key)
28
27
  case resp
29
28
  when Array
30
- resp.map { |i| convert_to_rainforest_object(i, api_key, klass) }
29
+ resp.map { |i| convert_to_rainforest_object(i, api_key) }
31
30
  when Hash
32
31
  # Try converting to a known object class. If none available, fall back to generic RainforestObject
33
- object_classes.fetch(klass || resp[:object], RainforestObject).construct_from(resp, api_key)
32
+ object_classes.fetch(resp[:object], RainforestObject).construct_from(resp, api_key)
34
33
  else
35
34
  resp
36
35
  end
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+ require File.expand_path('../../test_helper', __FILE__)
3
+
4
+ module Rainforest
5
+ class AuthTest < ::Test::Unit::TestCase
6
+ context "With a valid api token, any request" do
7
+ should "not raise an exception" do
8
+ response = test_response({}, 200)
9
+ @mock.expects(:get).once.returns(response)
10
+ Rainforest::Test.retrieve("1")
11
+ end
12
+ end
13
+
14
+ context "With an invalid api token, any request" do
15
+ should "raise an exception" do
16
+ response = test_response({error:"Authentication required"}, 401)
17
+ assert_raises AuthenticationError do
18
+ @mock.expects(:get).once.raises(RestClient::ExceptionWithResponse.new(response, 401))
19
+ Rainforest::Test.retrieve("1")
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,36 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Rainforest
4
+ class RunTest < ::Test::Unit::TestCase
5
+ should "be listable" do
6
+ @mock.expects(:get).once.returns(test_response(test_run_array))
7
+ runs = Rainforest::Run.all
8
+ assert runs.data.kind_of? Array
9
+
10
+ runs.data.each do |run|
11
+ assert run.kind_of?(Rainforest::Run)
12
+ end
13
+ end
14
+
15
+ should "be retrievable individually" do
16
+ @mock.expects(:get).once.returns(test_response(test_run))
17
+ run = Rainforest::Run.retrieve("test_run")
18
+ assert run.kind_of?(Rainforest::Run)
19
+ end
20
+
21
+ should "be abortable" do
22
+ @mock.expects(:get).once.returns(test_response(test_run))
23
+ @mock.expects(:delete).once.returns(test_response(test_run(state: "aborted")))
24
+ run = Rainforest::Run.retrieve("test_run")
25
+ run = run.delete
26
+
27
+ assert_equal("aborted", run.state)
28
+ end
29
+
30
+ should "be createable" do
31
+ @mock.expects(:post).once.returns(test_response(test_run))
32
+ run = Rainforest::Run.create(tests: ["all"])
33
+ assert run.kind_of?(Rainforest::Run)
34
+ end
35
+ end
36
+ end
@@ -1,3 +1,4 @@
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__), "..", "lib")
1
2
  require 'rainforest'
2
3
  require 'test/unit'
3
4
  require 'mocha/setup'
@@ -37,6 +38,7 @@ end
37
38
  def test_test(params={})
38
39
  {
39
40
  id: 2181,
41
+ object: "Test",
40
42
  created_at: "2013-11-05T04:57:55Z",
41
43
  test_id: 2181,
42
44
  site_id: 860,
@@ -72,12 +74,13 @@ def test_test(params={})
72
74
  created_at: "2013-11-13T14:38:01Z",
73
75
  state: "in_progress"
74
76
  }
75
- }
77
+ }.merge(params)
76
78
  end
77
79
 
78
80
  def test_run(params={})
79
81
  {
80
82
  id: 4244,
83
+ object: "Run",
81
84
  created_at: "2013-11-13T14:38:01Z",
82
85
  environment_id: 1144,
83
86
  test_count: 1,
@@ -128,7 +131,7 @@ def test_run(params={})
128
131
  }
129
132
  ],
130
133
  requested_tests: [2181]
131
- }
134
+ }.merge(params)
132
135
  end
133
136
 
134
137
  def test_run_array
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rainforest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Calhon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-13 00:00:00.000000000 Z
11
+ date: 2013-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -123,10 +123,8 @@ files:
123
123
  - gemfiles/default-with-activesupport.gemfile
124
124
  - gemfiles/json.gemfile
125
125
  - gemfiles/yajl.gemfile
126
- - lib/.DS_Store
127
126
  - lib/data/ca-certificates.crt
128
127
  - lib/rainforest.rb
129
- - lib/rainforest/.DS_Store
130
128
  - lib/rainforest/api_operations/create.rb
131
129
  - lib/rainforest/api_operations/delete.rb
132
130
  - lib/rainforest/api_operations/list.rb
@@ -142,16 +140,14 @@ files:
142
140
  - lib/rainforest/rainforest_object.rb
143
141
  - lib/rainforest/run.rb
144
142
  - lib/rainforest/singleton_api_resource.rb
145
- - lib/rainforest/test.rb
146
143
  - lib/rainforest/util.rb
147
144
  - lib/rainforest/version.rb
148
145
  - rainforest.gemspec
149
- - test/.DS_Store
150
- - test/rainforest/.DS_Store
151
146
  - test/rainforest/api_resource_test.rb
147
+ - test/rainforest/auth_test.rb
152
148
  - test/rainforest/list_object_test.rb
153
149
  - test/rainforest/metadata_test.rb
154
- - test/rainforest/test_test.rb
150
+ - test/rainforest/run_test.rb
155
151
  - test/rainforest/util_test.rb
156
152
  - test/test_helper.rb
157
153
  homepage: https://github.com/joncalhoun/rainforest-ruby
@@ -178,10 +174,10 @@ signing_key:
178
174
  specification_version: 4
179
175
  summary: Ruby bindings for the Rainforest API
180
176
  test_files:
181
- - test/rainforest/.DS_Store
182
177
  - test/rainforest/api_resource_test.rb
178
+ - test/rainforest/auth_test.rb
183
179
  - test/rainforest/list_object_test.rb
184
180
  - test/rainforest/metadata_test.rb
185
- - test/rainforest/test_test.rb
181
+ - test/rainforest/run_test.rb
186
182
  - test/rainforest/util_test.rb
187
183
  - test/test_helper.rb
Binary file
Binary file
@@ -1,14 +0,0 @@
1
- module Rainforest
2
- class Test < APIResource
3
- include Rainforest::APIOperations::Create
4
- include Rainforest::APIOperations::Delete
5
- include Rainforest::APIOperations::Update
6
- include Rainforest::APIOperations::List
7
-
8
- def self.tags(filters={}, api_key=nil)
9
- response, api_key = Rainforest.request(:get, url + "/tags", api_key, filters)
10
- response
11
- end
12
-
13
- end
14
- end
Binary file
Binary file
@@ -1,8 +0,0 @@
1
- require File.expand_path('../../test_helper', __FILE__)
2
-
3
- module Rainforest
4
- # Dear god this name is odd.. :( - jon
5
- class TestTest < ::Test::Unit::TestCase
6
- should_eventually "implement some tests"
7
- end
8
- end