rhoconnect-rb 0.3.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ module Rhoconnectrb
2
+ module API
3
+ class System
4
+
5
+ def self.klass
6
+ self.to_s.underscore.split('/')[2]
7
+ end
8
+
9
+ def self.method_missing method_name, *args
10
+ action = method_name.to_s.split("_")
11
+ Base.send(action[0],"/#{klass}/#{action[1]}",args[0])
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,43 @@
1
+ module Rhoconnectrb
2
+ module API
3
+ class Users
4
+ def self.klass
5
+ self.to_s.underscore.split('/')[2]
6
+ end
7
+
8
+ def self.method_missing method_name, *args
9
+ action = method_name.to_s.split("_")
10
+ #handle CRUD operations
11
+ if action.size == 1
12
+ if action[0] =~ /put|delete/
13
+ resp = Base.send(action[0],"/#{klass}/#{args[0]}",args[1])
14
+ else
15
+ url = args.size > 0 ? "/#{klass}/#{args[0]}" : "/#{klass}"
16
+ resp = Base.send(action[0],url,args[1])
17
+ end
18
+ end
19
+
20
+ if action.size > 1
21
+ verb = action.delete_at(0)
22
+ #if posting without parameters just post with data else contruct url
23
+ if verb == 'post' and !args[1]
24
+ resp = Base.send(verb,"/#{klass}/#{action[0]}",args[0])
25
+ else
26
+ if args[0].class.to_s == 'String'
27
+ url = "/#{klass}/#{args[0]}/#{action[0]}"
28
+ else
29
+ url = klass
30
+ args[0].each_with_index do |value,index|
31
+ url += "/#{value}"
32
+ url += "/#{action[index]}" if action[index]
33
+ end
34
+ end
35
+ resp = Base.send(verb,url,args[1])
36
+ end
37
+ end
38
+ resp
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -1,6 +1,6 @@
1
1
  require 'uri'
2
2
 
3
- module Rhoconnect
3
+ module Rhoconnectrb
4
4
  class Client
5
5
  attr_accessor :uri, :token
6
6
 
@@ -14,16 +14,16 @@ module Rhoconnect
14
14
 
15
15
  # allow configuration, uri or environment variable initialization
16
16
  def initialize(params = {})
17
- uri = params[:uri] || Rhoconnect.configuration.uri || ENV['RHOCONNECT_URL']
17
+ uri = params[:uri] || Rhoconnectrb.configuration.uri || ENV['RHOCONNECT_URL']
18
18
  raise ArgumentError.new("Please provide a :uri or set RHOCONNECT_URL") unless uri
19
19
  @uri = URI.parse(uri)
20
20
 
21
- @token = params[:token] || Rhoconnect.configuration.token || @uri.user
21
+ @token = params[:token] || Rhoconnectrb.configuration.token || @uri.user
22
22
  @uri.user = nil; @uri = @uri.to_s
23
23
 
24
24
  raise ArgumentError.new("Please provide a :token or set it in uri") unless @token
25
25
 
26
- RestClient.proxy = ENV['HTTP_PROXY'] || ENV['http_proxy'] || Rhoconnect.configuration.http_proxy
26
+ RestClient.proxy = ENV['HTTP_PROXY'] || ENV['http_proxy'] || Rhoconnectrb.configuration.http_proxy
27
27
  end
28
28
 
29
29
  def create(source_name, partition, obj = {})
@@ -86,7 +86,7 @@ module Rhoconnect
86
86
 
87
87
  def api_headers # :nodoc:
88
88
  {
89
- 'User-Agent' => Rhoconnect::VERSION,
89
+ 'User-Agent' => Rhoconnectrb::VERSION,
90
90
  'X-Ruby-Version' => RUBY_VERSION,
91
91
  'X-Ruby-Platform' => RUBY_PLATFORM
92
92
  }
@@ -1,4 +1,4 @@
1
- module Rhoconnect
1
+ module Rhoconnectrb
2
2
  class Configuration
3
3
  attr_accessor :uri, :token, :authenticate, :sync_time_as_int, :app_endpoint, :http_proxy
4
4
 
@@ -12,11 +12,11 @@ module Rhoconnect
12
12
  attr_accessor :configuration
13
13
  end
14
14
 
15
- # Configure Rhoconnect in an initializer:
15
+ # Configure Rhoconnectrb in an initializer:
16
16
  # like config/initializers/rhoconnect.rb
17
17
  #
18
- # Setup the Rhoconnect uri and api token.
19
- # Use rhoconnect:get_token to get the token value.
18
+ # Setup the Rhoconnectrb uri and api token.
19
+ # Use rhoconnectrb:get_token to get the token value.
20
20
  #
21
21
  # config.uri = "http://myrhoconnect.com"
22
22
  # config.token = "secrettoken"
@@ -25,7 +25,7 @@ module Rhoconnect
25
25
  # }
26
26
  #
27
27
  # @example
28
- # Rhoconnect.configure do |config|
28
+ # Rhoconnectrb.configure do |config|
29
29
  # config.uri = "http://myrhoconnect.com"
30
30
  # config.token = "secrettoken"
31
31
  # end
@@ -42,11 +42,11 @@ module Rhoconnect
42
42
  uri = uri.to_s
43
43
  end
44
44
  token ||= ENV['token'] || self.configuration.token
45
- Rhoconnect::Client.set_app_endpoint(:url => uri + "/rc/v1/system/appserver",
45
+ Rhoconnectrb::Client.set_app_endpoint(:url => uri + "/rc/v1/system/appserver",
46
46
  :payload => {:adapter_url => endpoint_url}.to_json,
47
47
  :headers => {:content_type => 'application/json', 'X-RhoConnect-API-TOKEN' => token}
48
48
  ) if endpoint_url && uri && token
49
49
  end
50
50
  end
51
51
 
52
- Rhoconnect.configure { }
52
+ Rhoconnectrb.configure { }
@@ -1,15 +1,15 @@
1
1
  require 'json'
2
2
 
3
- module Rhoconnect
3
+ module Rhoconnectrb
4
4
  class EndpointHelpers
5
5
  def self.authenticate(content_type, body)
6
6
  code, params = 200, parse_params(content_type, body)
7
- if Rhoconnect.configuration.authenticate
8
- code = 401 unless Rhoconnect.configuration.authenticate.call(params)
7
+ if Rhoconnectrb.configuration.authenticate
8
+ code = 401 unless Rhoconnectrb.configuration.authenticate.call(params)
9
9
  end
10
10
  [code, {'Content-Type' => 'text/plain'}, [code == 200 ? params['login'] : ""]]
11
11
  end
12
-
12
+
13
13
  def self.query(content_type, body)
14
14
  params = parse_params(content_type, body)
15
15
  action, c_type, result, records = :rhoconnect_query, 'application/json', {}, []
@@ -28,10 +28,10 @@ module Rhoconnect
28
28
  c_type = 'text/plain'
29
29
  # Log warning if something broke
30
30
  warn error
31
- end
31
+ end
32
32
  [code, {'Content-Type' => c_type}, [result]]
33
33
  end
34
-
34
+
35
35
  def self.on_cud(action, content_type, body)
36
36
  params = parse_params(content_type, body)
37
37
  object_id = ""
@@ -42,21 +42,21 @@ module Rhoconnect
42
42
  end
43
43
  [code, {'Content-Type' => "text/plain"}, [error || object_id]]
44
44
  end
45
-
45
+
46
46
  def self.create(content_type, body)
47
47
  self.on_cud(:create, content_type, body)
48
48
  end
49
-
49
+
50
50
  def self.update(content_type, body)
51
- self.on_cud(:update, content_type, body)
51
+ self.on_cud(:update, content_type, body)
52
52
  end
53
-
53
+
54
54
  def self.delete(content_type, body)
55
- self.on_cud(:delete, content_type, body)
55
+ self.on_cud(:delete, content_type, body)
56
56
  end
57
-
57
+
58
58
  private
59
-
59
+
60
60
  def self.get_rhoconnect_resource(resource_name, action)
61
61
  code, error = 200, nil
62
62
  begin
@@ -66,7 +66,7 @@ module Rhoconnect
66
66
  error = "error on method `#{action}` for #{resource_name}: #{ne.message}"
67
67
  code = 404
68
68
  rescue NameError
69
- error = "Missing Rhoconnect::Resource #{resource_name}"
69
+ error = "Missing Rhoconnectrb::Resource #{resource_name}"
70
70
  code = 404
71
71
  # TODO: catch HaltException and Exception here, built-in source adapter will handle them
72
72
  rescue Exception => e
@@ -75,11 +75,11 @@ module Rhoconnect
75
75
  end
76
76
  [code, error]
77
77
  end
78
-
78
+
79
79
  def self.parse_params(content_type, params)
80
80
  if content_type and content_type.match(/^application\/json/) and params and params.length > 2
81
81
  JSON.parse(params)
82
- else
82
+ else
83
83
  {}
84
84
  end
85
85
  end
@@ -91,23 +91,23 @@ if defined? Rails
91
91
  #if Rails::VERSION::STRING.to_i >= 3
92
92
  class Engine < Rails::Engine; end
93
93
  #end
94
-
95
- module Rhoconnect
94
+
95
+ module Rhoconnectrb
96
96
  class BaseEndpoint
97
97
  def self.call(env)
98
98
  req = Rack::Request.new(env)
99
- Rhoconnect::EndpointHelpers.send(self.to_s.downcase.split("::")[1].to_sym, req.content_type, req.body.read)
99
+ Rhoconnectrb::EndpointHelpers.send(self.to_s.downcase.split("::")[1].to_sym, req.content_type, req.body.read)
100
100
  end
101
101
  end
102
-
102
+
103
103
  class Authenticate < BaseEndpoint; end
104
-
104
+
105
105
  class Query < BaseEndpoint; end
106
-
106
+
107
107
  class Create < BaseEndpoint; end
108
-
108
+
109
109
  class Update < BaseEndpoint; end
110
-
110
+
111
111
  class Delete < BaseEndpoint; end
112
112
  end
113
113
  end
@@ -117,7 +117,7 @@ end
117
117
  if defined? Sinatra
118
118
  # Defines Sinatra routes
119
119
  # This is automatically registered if you are using
120
- # the 'classic' style sinatra application. To use in a
120
+ # the 'classic' style sinatra application. To use in a
121
121
  # classic application:
122
122
  #
123
123
  # require 'rubygems'
@@ -133,9 +133,9 @@ if defined? Sinatra
133
133
  #
134
134
  # require 'sinatra/base'
135
135
  # require 'rhoconnect-rb'
136
- #
136
+ #
137
137
  # class Myapp < Sinatra::Base
138
- # register Sinatra::RhoconnectEndpoints
138
+ # register Sinatra::RhoconnectrbEndpoints
139
139
  # get '/' do
140
140
  # 'hello world'
141
141
  # end
@@ -143,13 +143,13 @@ if defined? Sinatra
143
143
  module Sinatra
144
144
  module RhoconnectHelpers
145
145
  def call_helper(method,*args)
146
- code, c_type, body = Rhoconnect::EndpointHelpers.send(method,*args)
146
+ code, c_type, body = Rhoconnectrb::EndpointHelpers.send(method,*args)
147
147
  content_type c_type['Content-Type']
148
148
  status code
149
149
  body[0]
150
150
  end
151
151
  end
152
-
152
+
153
153
  module RhoconnectEndpoints
154
154
  def self.registered(app)
155
155
  # install our endpoint helpers
@@ -1,4 +1,4 @@
1
- module Rhoconnect
1
+ module Rhoconnectrb
2
2
  class Railtie < Rails::Railtie
3
3
 
4
4
  rake_tasks do
@@ -1,4 +1,4 @@
1
- module Rhoconnect
1
+ module Rhoconnectrb
2
2
  module Resource
3
3
 
4
4
  def self.included(model)
@@ -72,7 +72,7 @@ module Rhoconnect
72
72
  attribs = self.attributes.dup
73
73
  attribs.each do |key,value|
74
74
  attribs[key] = Time.parse(value.to_s).to_i.to_s if value.is_a?(Time) or value.is_a?(DateTime)
75
- end if Rhoconnect.configuration.sync_time_as_int
75
+ end if Rhoconnectrb.configuration.sync_time_as_int
76
76
  attribs
77
77
  end
78
78
 
@@ -82,7 +82,7 @@ module Rhoconnect
82
82
  unless self.skip_rhoconnect_callbacks
83
83
  attribs = self.normalized_attributes
84
84
  begin
85
- Rhoconnect::Client.new.send(action, self.class.to_s, self.get_partition, attribs)
85
+ Rhoconnectrb::Client.new.send(action, self.class.to_s, self.get_partition, attribs)
86
86
  rescue RestClient::Exception => re
87
87
  warn "#{self.class.to_s}: rhoconnect_#{action} returned error: #{re.message} - #{re.http_body}"
88
88
  rescue Exception => e
@@ -108,7 +108,7 @@ module Rhoconnect
108
108
  if is_datamapper?
109
109
  # test for dm-serializer
110
110
  if not is_defined?(DataMapper::Serialize)
111
- raise "Rhoconnect::Resource requires dm-serializer to work with DataMapper. Install with `gem install dm-serializer` and add to your application."
111
+ raise "Rhoconnectrb::Resource requires dm-serializer to work with DataMapper. Install with `gem install dm-serializer` and add to your application."
112
112
  end
113
113
  after :create, :rhoconnect_create
114
114
  after :destroy, :rhoconnect_destroy
@@ -118,7 +118,7 @@ module Rhoconnect
118
118
  after_destroy :rhoconnect_destroy
119
119
  after_update :rhoconnect_update
120
120
  else
121
- raise "Rhoconnect::Resource only supports ActiveRecord or DataMapper at this time."
121
+ raise "Rhoconnectrb::Resource only supports ActiveRecord or DataMapper at this time."
122
122
  end
123
123
  end
124
124
 
@@ -0,0 +1,3 @@
1
+ module Rhoconnectrb
2
+ VERSION = "1.0.0"
3
+ end
@@ -1,10 +1,10 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require 'rhoconnect/version'
3
+ require 'rhoconnectrb/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "rhoconnect-rb"
7
- s.version = Rhoconnect::VERSION
7
+ s.version = Rhoconnectrb::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Rhomobile"]
10
10
  s.date = Time.now.strftime('%Y-%m-%d')
data/spec/api_spec.rb ADDED
@@ -0,0 +1,155 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+ require File.join(File.dirname(__FILE__),"../lib","rhoconnect-rb.rb")
3
+ require File.join(File.dirname(__FILE__),"../lib/rhoconnectrb/api","base.rb")
4
+ require File.join(File.dirname(__FILE__),"../lib/rhoconnectrb/api","resource.rb")
5
+ require File.join(File.dirname(__FILE__),"../lib/rhoconnectrb/api","users.rb")
6
+ require File.join(File.dirname(__FILE__),"../lib/rhoconnectrb/api","store.rb")
7
+ require File.join(File.dirname(__FILE__),"../lib/rhoconnectrb/api","system.rb")
8
+ require File.join(File.dirname(__FILE__),"../lib/rhoconnectrb/api","sources.rb")
9
+ require File.join(File.dirname(__FILE__),"../lib/rhoconnectrb/api","read_state.rb")
10
+ require File.join(File.dirname(__FILE__),"../lib/rhoconnectrb/api","clients.rb")
11
+
12
+ describe Rhoconnectrb::API do
13
+ include WebMock::API
14
+
15
+ before(:each) do
16
+ stub_request(:get, "http://mytoken:@testurl.com/rc/v1/users").to_return(:body => "testuser")
17
+ stub_request(:get, "http://mytoken:@testurl.com/rc/v1/users/testuser/clients").to_return(:body=>'clientslist')
18
+ stub_request(:get, "http://mytoken:@testurl.com/rc/v1/users/testuser/sources/product/docnames").to_return(:body=>'docnames')
19
+ stub_request(:post, "http://mytoken:@testurl.com/rc/v1/read_state/users/testuser/sources/product").to_return(:body=>'readstate sources')
20
+ stub_request(:post, "http://mytoken:@testurl.com/rc/v1/users/testuser").to_return(:body => "testuser")
21
+ stub_request(:put, "http://mytoken:@testurl.com/rc/v1/users/testuser").to_return(:body => 'testuser')
22
+ stub_request(:delete, "http://mytoken:@testurl.com/rc/v1/users/testuser").to_return(:body => 'testuser')
23
+ stub_request(:post, "http://mytoken:@testurl.com/rc/v1/system/login").to_return(:body=>'login')
24
+ stub_request(:get, "http://mytoken:@testurl.com/rc/v1/system/appserver").to_return(:body=>'appserver')
25
+ stub_request(:post, "http://mytoken:@testurl.com/rc/v1/store/testdoc").to_return(:body=>'post store')
26
+ stub_request(:get, "http://mytoken:@testurl.com/rc/v1/store/testdoc").to_return(:body=>'get store')
27
+ stub_request(:get, "http://mytoken:@testurl.com/rc/v1/sources/type/app").to_return(:body=>'app sources')
28
+ stub_request(:get, "http://mytoken:@testurl.com/rc/v1/sources/Product").to_return(:body=>'Product')
29
+ stub_request(:put, "http://mytoken:@testurl.com/rc/v1/sources/Product").to_return(:body=>'put Product')
30
+ stub_request(:get, "http://mytoken:@testurl.com/rc/v1/clients/client_id/sources/source_id/docnames").to_return(:body=>'client sources docname')
31
+ stub_request(:get, "http://mytoken:@testurl.com/rc/v1/clients/client_id/sources/source_id/docs/docname").to_return(:body=>'client sources docs')
32
+ stub_request(:post, "http://mytoken:@testurl.com/rc/v1/clients/client_id/sources/source_id/docs/docname").to_return(:body=>'post client sources docs')
33
+ stub_request(:post, "http://mytoken:@testurl.com/app/v1/Product/push_objects").to_return(:body=>'push product object')
34
+ ENV['RHOCONNECT_URL'] = 'http://mytoken@testurl.com'
35
+ end
36
+
37
+ context "on base" do
38
+ it "should get token and url from env" do
39
+ Rhoconnectrb::API::Base.token.should == 'mytoken'
40
+ Rhoconnectrb::API::Base.resource.to_s.should == 'http://mytoken@testurl.com/rc/v1'
41
+ end
42
+ end
43
+ context "on users" do
44
+ it "should format get request url" do
45
+ resp = Rhoconnectrb::API::Users.get
46
+ resp.body.should == 'testuser'
47
+ end
48
+
49
+ it "should format post request" do
50
+ data = {:id=>'1'}
51
+ resp = Rhoconnectrb::API::Users.post('testuser',data)
52
+ resp.body.should == 'testuser'
53
+ end
54
+
55
+ it "should format put request" do
56
+ data = {:id=>'1'}
57
+ resp = Rhoconnectrb::API::Users.put('testuser',data)
58
+ resp.body.should == 'testuser'
59
+ end
60
+
61
+ it "should format delete request" do
62
+ resp = Rhoconnectrb::API::Users.delete('testuser')
63
+ resp.body.should == 'testuser'
64
+ end
65
+
66
+ it "should format user clients" do
67
+ resp = Rhoconnectrb::API::Users.get_clients('testuser')
68
+ resp.body.should == 'clientslist'
69
+ end
70
+
71
+ it "should format user sources docname" do
72
+ resp = Rhoconnectrb::API::Users.get_sources_docnames(['testuser','product'])
73
+ resp.body.should == 'docnames'
74
+ end
75
+ end
76
+ context "read state" do
77
+ it "should return readsate for user" do
78
+ data = {:refresh_time => 20}
79
+ resp = Rhoconnectrb::API::ReadState.post_users_sources(['testuser','product'],data)
80
+ resp.body.should == 'readstate sources'
81
+ end
82
+ end
83
+
84
+ context "on system" do
85
+ it "should login to system" do
86
+ data = {:login=>'test',:password=>'password'}
87
+ resp = Rhoconnectrb::API::System.post_login(data)
88
+ resp.body.should == 'login'
89
+ end
90
+
91
+ it "should get appserver" do
92
+ resp = Rhoconnectrb::API::System.get_appserver
93
+ resp.body.should == 'appserver'
94
+ end
95
+ end
96
+
97
+ context "on store" do
98
+ it "should store doc" do
99
+ data = {:data=>{:mydata=>'testdata'},:append=>'false'}
100
+ resp = Rhoconnectrb::API::Store.post('testdoc',data)
101
+ resp.body.should == 'post store'
102
+ end
103
+
104
+ it "should get store doc" do
105
+ resp = Rhoconnectrb::API::Store.get('testdoc')
106
+ resp.body.should == 'get store'
107
+ end
108
+ end
109
+
110
+ context "on source" do
111
+ it "should get partition type" do
112
+ resp = Rhoconnectrb::API::Sources.get_type('app')
113
+ resp.body.should == 'app sources'
114
+ end
115
+
116
+ it "should get source" do
117
+ resp = Rhoconnectrb::API::Sources.get('Product')
118
+ resp.body.should == 'Product'
119
+ end
120
+
121
+ it "should update source" do
122
+ data = {:user_name =>"testuser",:data=>{:poll_interval=>20}}
123
+ resp = Rhoconnectrb::API::Sources.put('Product',data)
124
+ resp.body.should == 'put Product'
125
+ end
126
+ end
127
+
128
+ context "on client" do
129
+ it "should get client sources docnames" do
130
+ resp = Rhoconnectrb::API::Clients.get_sources_docnames(['client_id','source_id'])
131
+ resp.body.should == 'client sources docname'
132
+ end
133
+
134
+ it "should get clients docs" do
135
+ resp = Rhoconnectrb::API::Clients.get_sources_docs(['client_id','source_id','docname'])
136
+ resp.body.should == 'client sources docs'
137
+ end
138
+
139
+ it "should post clients sources doc" do
140
+ data = {:data=>{:mydata=>'testdata'},:append=>'false'}
141
+ resp = Rhoconnectrb::API::Clients.post_sources_docs(['client_id','source_id','docname'],data)
142
+ resp.body.should == 'post client sources docs'
143
+ end
144
+ end
145
+
146
+ context "on resources" do
147
+ it "should push source objects" do
148
+ data = {:data=>{:mydata=>'testdata'},:append=>'false'}
149
+ resp = Rhoconnectrb::API::Resource.post_push_objects('Product',data)
150
+ resp.body.should == 'push product object'
151
+ end
152
+
153
+ end
154
+
155
+ end
data/spec/client_spec.rb CHANGED
@@ -1,39 +1,39 @@
1
1
  require File.join(File.dirname(__FILE__), 'spec_helper')
2
2
 
3
- describe Rhoconnect::Client do
3
+ describe Rhoconnectrb::Client do
4
4
 
5
5
  context "on initialize" do
6
6
  it "should initialize with Rhoconnect_URL environment var" do
7
7
  ENV['RHOCONNECT_URL'] = "http://token@test.rhoconnect.com"
8
- c = Rhoconnect::Client.new
8
+ c = Rhoconnectrb::Client.new
9
9
  c.token.should == 'token'
10
10
  c.uri.should == 'http://test.rhoconnect.com'
11
11
  ENV.delete('Rhoconnect_URL')
12
12
  end
13
13
 
14
14
  it "should initialize with :uri parameter" do
15
- c = Rhoconnect::Client.new(:uri => "http://token@test.rhoconnect.com")
15
+ c = Rhoconnectrb::Client.new(:uri => "http://token@test.rhoconnect.com")
16
16
  c.token.should == 'token'
17
17
  c.uri.should == 'http://test.rhoconnect.com'
18
18
  end
19
19
 
20
20
  it "should initialize with :token parameter" do
21
- c = Rhoconnect::Client.new(:uri => "http://test.rhoconnect.com", :token => "token")
21
+ c = Rhoconnectrb::Client.new(:uri => "http://test.rhoconnect.com", :token => "token")
22
22
  c.token.should == 'token'
23
23
  c.uri.should == 'http://test.rhoconnect.com'
24
24
  end
25
25
 
26
26
  it "should initialize with configure block" do
27
- Rhoconnect.configure do |config|
27
+ Rhoconnectrb.configure do |config|
28
28
  config.uri = "http://test.rhoconnect.com"
29
29
  config.token = "token"
30
30
  end
31
31
  begin
32
- c = Rhoconnect::Client.new
32
+ c = Rhoconnectrb::Client.new
33
33
  c.token.should == 'token'
34
34
  c.uri.should == 'http://test.rhoconnect.com'
35
35
  ensure
36
- Rhoconnect.configure do |config|
36
+ Rhoconnectrb.configure do |config|
37
37
  config.uri = nil
38
38
  config.token = nil
39
39
  end
@@ -42,19 +42,19 @@ describe Rhoconnect::Client do
42
42
 
43
43
  it "should raise ArgumentError if uri is missing" do
44
44
  ENV['RHOCONNECT_URL'] = nil
45
- lambda { Rhoconnect::Client.new }.should raise_error(ArgumentError, "Please provide a :uri or set RHOCONNECT_URL")
45
+ lambda { Rhoconnectrb::Client.new }.should raise_error(ArgumentError, "Please provide a :uri or set RHOCONNECT_URL")
46
46
  end
47
47
 
48
48
  it "should raise ArugmentError if token is missing" do
49
49
  lambda {
50
- Rhoconnect::Client.new(:uri => "http://test.rhoconnect.com")
50
+ Rhoconnectrb::Client.new(:uri => "http://test.rhoconnect.com")
51
51
  }.should raise_error(ArgumentError, "Please provide a :token or set it in uri")
52
52
  end
53
53
  end
54
54
 
55
55
  context "on create update destroy" do
56
56
  before(:each) do
57
- @client = Rhoconnect::Client.new(:uri => "http://token@test.rhoconnect.com")
57
+ @client = Rhoconnectrb::Client.new(:uri => "http://token@test.rhoconnect.com")
58
58
  end
59
59
 
60
60
  it "should create an object" do
@@ -102,7 +102,7 @@ describe Rhoconnect::Client do
102
102
 
103
103
  context "on set callbacks" do
104
104
  before(:each) do
105
- @client = Rhoconnect::Client.new(:uri => "http://token@test.rhoconnect.com")
105
+ @client = Rhoconnectrb::Client.new(:uri => "http://token@test.rhoconnect.com")
106
106
  end
107
107
 
108
108
  it "should set auth callback" do