restpack_web 0.2.21 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.gitignore +1 -1
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +2 -29
- data/Rakefile +2 -39
- data/lib/restpack_web.rb +6 -1
- data/lib/restpack_web/configuration.rb +16 -0
- data/lib/restpack_web/context.rb +52 -101
- data/lib/restpack_web/rack/domain.rb +36 -0
- data/lib/restpack_web/rack/session.rb +7 -0
- data/lib/restpack_web/rack/user.rb +35 -0
- data/lib/restpack_web/rails/controller.rb +9 -13
- data/lib/restpack_web/sinatra/app.rb +9 -16
- data/lib/restpack_web/version.rb +2 -2
- data/restpack_web.gemspec +23 -24
- metadata +55 -94
- data/LICENSE +0 -22
- data/lib/restpack_web/app.rb +0 -55
- data/lib/restpack_web/test_support.rb +0 -26
- data/spec/fixtures/channels.json +0 -354
- data/spec/fixtures/configurations_root.json +0 -59
- data/spec/fixtures/domains_search.json +0 -40
- data/spec/fixtures/users.json +0 -14
- data/spec/lib/restpack_web_spec.rb +0 -39
- data/spec/lib/test_support_spec.rb +0 -23
- data/spec/spec_helper.rb +0 -8
data/spec/fixtures/users.json
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"user": {
|
3
|
-
"id":1,
|
4
|
-
"channel_id":1,
|
5
|
-
"description":null,
|
6
|
-
"email":"lukasz.krystkowiak@gmail.com",
|
7
|
-
"image":null,
|
8
|
-
"avatar":"http://robohash.org/1.png?size=200x200",
|
9
|
-
"location":null,
|
10
|
-
"name":"Lukasz",
|
11
|
-
"nickname":"lukkry",
|
12
|
-
"url":"/api/v1/users/1.json"
|
13
|
-
}
|
14
|
-
}
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
require "rack/test"
|
3
|
-
require 'restpack_web/test_support'
|
4
|
-
|
5
|
-
include Rack::Test::Methods
|
6
|
-
|
7
|
-
describe RestPack::Web do
|
8
|
-
let(:app) {
|
9
|
-
RestPack::Web::App.new(
|
10
|
-
lambda { |env| [200, {'Content-Type' => 'text/plain'}, 'hello world'] },
|
11
|
-
{ core_domain: ENV['RESTPACK_CORE_SERVICE'], password: ENV['RESTPACK_ACCESS_KEY'] })
|
12
|
-
}
|
13
|
-
|
14
|
-
before do
|
15
|
-
RestPack::Web::TestSupport.stub_restpack_web
|
16
|
-
end
|
17
|
-
|
18
|
-
it "returns a valid response" do
|
19
|
-
get '/'
|
20
|
-
last_response.ok?.must_equal true
|
21
|
-
last_response.body.must_equal 'hello world'
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#add_user' do
|
25
|
-
let(:users_path){ File.expand_path('./spec/fixtures/users.json') }
|
26
|
-
|
27
|
-
before do
|
28
|
-
stub_request(:get, 'http://auth.restpack-sample.org/api/v1/users/1.json').
|
29
|
-
to_return(:body => File.read(users_path))
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'inject an user into env' do
|
33
|
-
get '/', {}, 'rack.session' => { :user_id => 1 }
|
34
|
-
last_request.env[:restpack][:user_id].must_equal 1
|
35
|
-
last_request.env[:restpack][:user]['email'].must_equal 'lukasz.krystkowiak@gmail.com'
|
36
|
-
last_request.env[:restpack][:user]['nickname'].must_equal 'lukkry'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
|
3
|
-
require 'net/http'
|
4
|
-
require 'restpack_web/test_support'
|
5
|
-
|
6
|
-
describe RestPack::Web::TestSupport do
|
7
|
-
let(:configurations_root_path){ File.expand_path('./spec/fixtures/configurations_root.json') }
|
8
|
-
let(:domains_search_path){ File.expand_path('./spec/fixtures/domains_search.json') }
|
9
|
-
let(:channels_path){ File.expand_path('./spec/fixtures/channels.json') }
|
10
|
-
|
11
|
-
describe '#stub_restpack_web' do
|
12
|
-
before do
|
13
|
-
RestPack::Web::TestSupport.stub_restpack_web
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'stub all requests to the core service' do
|
17
|
-
host = "http://:#{ENV['RESTPACK_ACCESS_KEY']}@#{ENV['RESTPACK_CORE_SERVICE']}/api/v1"
|
18
|
-
RestClient.get("#{host}/configurations/root.json").must_equal File.read(configurations_root_path)
|
19
|
-
RestClient.get("#{host}/domains/search.json?host=sinatra.restpack-sample.org").must_equal File.read(domains_search_path)
|
20
|
-
RestClient.get("#{host}/channels/1.json").must_equal File.read(channels_path)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|