Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[RENAME] Renaming to oauth-activeresource

  • Loading branch information...
commit ac0ccbfeb17bb19f00bf812f9b99f51b2a09a251 1 parent f1af190
@albertopq authored
View
2  Gemfile
@@ -1,6 +1,6 @@
source "http://rubygems.org"
-# Declare your gem's dependencies in oauth_active_resource.gemspec.
+# Declare your gem's dependencies in oauth-activeresource.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
View
0  lib/oauth_active_resource.rb → lib/oauth-activeresource.rb
File renamed without changes
View
0  lib/oauth_active_resource/version.rb → lib/oauth-activeresource/version.rb
File renamed without changes
View
2  lib/tasks/oauth_active_resource_tasks.rake
@@ -1,4 +1,4 @@
# desc "Explaining what the task does"
-# task :oauth_active_resource do
+# task :oauth-activeresource do
# # Task goes here
# end
View
21 oauth-activeresource.gemspec
@@ -0,0 +1,21 @@
+$:.push File.expand_path("../lib", __FILE__)
+
+# Maintain your gem's version:
+require "oauth-activeresource/version"
+
+# Describe your gem and declare its dependencies:
+Gem::Specification.new do |s|
+ s.name = "oauth-activeresource"
+ s.version = OauthActiveResource::VERSION
+ s.authors = ["Alberto Pastor"]
+ s.email = ["albert.pastor@gmail.com"]
+ s.homepage = ""
+ s.summary = "Rails gem that allows you to easily interact with an Oauth secured rest API with the ActiveResource model."
+
+ s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
+ s.test_files = Dir["test/**/*"]
+
+ s.add_dependency "rails", "~> 3.2.1"
+
+ s.add_development_dependency "sqlite3"
+end
View
2  test/dummy/config/application.rb
@@ -3,7 +3,7 @@
require 'rails/all'
Bundler.require
-require "oauth_active_resource"
+require "oauth-activeresource"
module Dummy
class Application < Rails::Application
View
56 test/oauth_activeresource_test.rb
@@ -0,0 +1,56 @@
+require 'test_helper'
+
+class OauthActiveResourceTest < ActiveSupport::TestCase
+
+ def setup
+ oauth_mock = stub("oauth")
+ oauth_mock.stubs(:get).with('http://example.com:80/users.json', {'Accept' => 'application/json'}).returns(valid_response_all)
+ oauth_mock.stubs(:post).with('http://example.com:80/users.json', list_users.first.to_json.to_s, {'Content-Type' => 'application/json'}).returns(valid_response_post)
+ User.oauth_connection = oauth_mock
+ end
+
+ def test_user_model_should_inheritate_from_oauth_activeresource
+ assert_equal OauthActiveResource::Base, User.superclass
+ end
+
+ def test_user_model_should_assign_access_token_after_assigning_to_base
+ OauthActiveResource::Base.oauth_connection = "test"
+ assert_equal User.oauth_connection, "test"
+ end
+
+ def test_find_should_request_get
+ user = User.find(:all).first
+ assert_kind_of User, user
+ assert_equal user.name, "test"
+ end
+
+ def test_create_should_request_post
+ user = User.create(list_users.first)
+ assert_kind_of User, user
+ assert_equal user.name, list_users.first[:user][:name]
+ end
+
+ private
+
+ def list_users
+ [{:user => {:name => "test"}}]
+ end
+
+ def valid_response_all
+ response = stub("http_response")
+ response.stubs(:code).returns(200)
+ response.stubs(:body).returns(list_users.to_json)
+ response
+ end
+
+ def valid_response_post
+ [{:user => {:name => "test"}}]
+ response = stub("http_response")
+ response.stubs(:code).returns(200)
+ response.stubs(:[]).returns(nil)
+ response.stubs(:body).returns(nil)
+ response
+ end
+
+end
+
Please sign in to comment.
Something went wrong with that request. Please try again.