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.
@@ -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
@@ -1,8 +0,0 @@
1
- require 'minitest/spec'
2
- require 'minitest/autorun'
3
- require 'webmock/minitest'
4
-
5
- require 'restpack_web'
6
-
7
- ENV['RESTPACK_ACCESS_KEY'] = 'secret'
8
- ENV['RESTPACK_CORE_SERVICE'] = 'core.restpack-sample.org'