braque 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/braque/model.rb +3 -2
- data/lib/braque/version.rb +1 -1
- data/spec/braque/multiple_model_spec.rb +3 -3
- data/spec/braque/subclassed_model_spec.rb +38 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a69209964c677b108f1b3984f052d4d0c645e82b
|
4
|
+
data.tar.gz: 0b7a8bfc21aaabb571f8e2903723b28bfab0b14c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 381a83fb6ec72a64b056043dec4d30c4294f7e8acb10c0837887c473d5c3ac703aed5f8ec02543abaeb4a11a49f3da69df37c07592d5d3e685d81fb4e6126d1d
|
7
|
+
data.tar.gz: 15abd9a742c265348c6ecd4d5caa8fd85114927c355d6aaf45e45d729857f937edefda05a57921f9ba87cb23a798783ca4613dc7a06f300852bd92e2f6009f95
|
data/lib/braque/model.rb
CHANGED
@@ -4,6 +4,9 @@ module Braque
|
|
4
4
|
include ::ActiveAttr::Model
|
5
5
|
|
6
6
|
included do
|
7
|
+
class_attribute :api_root
|
8
|
+
class_attribute :api_token
|
9
|
+
|
7
10
|
# NOTE: This assumes that the related API uses an ID attribute to
|
8
11
|
# define the resource. Rails will use this field to construct
|
9
12
|
# resource routes in client applications.
|
@@ -46,8 +49,6 @@ module Braque
|
|
46
49
|
|
47
50
|
module ClassMethods
|
48
51
|
include Braque::Collection
|
49
|
-
attr_accessor :api_root
|
50
|
-
attr_accessor :api_token
|
51
52
|
|
52
53
|
def list(options = {})
|
53
54
|
options = Hash[options.map { |k, v| [CGI.escape(k.to_s), v] }]
|
data/lib/braque/version.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe Braque::Model, type: :model do
|
4
4
|
context 'with multiple defined Braque::Model classes' do
|
5
5
|
before do
|
6
|
-
class
|
6
|
+
class Wind
|
7
7
|
include ::Braque::Model
|
8
8
|
self.api_root = 'http://localhost:9292'
|
9
9
|
self.api_token = 'replace-me'
|
@@ -19,8 +19,8 @@ RSpec.describe Braque::Model, type: :model do
|
|
19
19
|
it 'sets the correct api_root and api_token for each class' do
|
20
20
|
expect(Tide.api_root).to eq 'http://localhost:9393'
|
21
21
|
expect(Tide.api_token).to eq 'do-replace-me-as-well'
|
22
|
-
expect(
|
23
|
-
expect(
|
22
|
+
expect(Wind.api_root).to eq 'http://localhost:9292'
|
23
|
+
expect(Wind.api_token).to eq 'replace-me'
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Braque::Model, type: :model do
|
4
|
+
context 'with subclassed Braque::Model classes' do
|
5
|
+
before do
|
6
|
+
class GeologicModel
|
7
|
+
include ::Braque::Model
|
8
|
+
self.api_root = 'http://localhost:9292'
|
9
|
+
self.api_token = 'replace-me'
|
10
|
+
end
|
11
|
+
|
12
|
+
class ContinentalDrift < GeologicModel
|
13
|
+
end
|
14
|
+
|
15
|
+
class Convection < GeologicModel
|
16
|
+
self.api_root = 'http://localhost:9595'
|
17
|
+
self.api_token = 'ok-another-one-to-replace'
|
18
|
+
end
|
19
|
+
|
20
|
+
class SeafloorSpreading
|
21
|
+
include ::Braque::Model
|
22
|
+
self.api_root = 'http://localhost:9393'
|
23
|
+
self.api_token = 'do-replace-me-as-well'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'sets the correct api_root and api_token for each class' do
|
28
|
+
expect(GeologicModel.api_root).to eq 'http://localhost:9292'
|
29
|
+
expect(GeologicModel.api_token).to eq 'replace-me'
|
30
|
+
expect(ContinentalDrift.api_root).to eq 'http://localhost:9292'
|
31
|
+
expect(ContinentalDrift.api_token).to eq 'replace-me'
|
32
|
+
expect(Convection.api_root).to eq 'http://localhost:9595'
|
33
|
+
expect(Convection.api_token).to eq 'ok-another-one-to-replace'
|
34
|
+
expect(SeafloorSpreading.api_root).to eq 'http://localhost:9393'
|
35
|
+
expect(SeafloorSpreading.api_token).to eq 'do-replace-me-as-well'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: braque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Fareed
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- spec/braque/helpers/hypermedia_responses_helper_spec.rb
|
73
73
|
- spec/braque/model_spec.rb
|
74
74
|
- spec/braque/multiple_model_spec.rb
|
75
|
+
- spec/braque/subclassed_model_spec.rb
|
75
76
|
- spec/fixtures/collection.json
|
76
77
|
- spec/fixtures/resource.json
|
77
78
|
- spec/fixtures/root.json
|