her 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +19 -1279
  3. data/.rubocop_todo.yml +232 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +16 -4
  6. data/README.md +25 -1
  7. data/gemfiles/Gemfile.faraday-1.0 +6 -0
  8. data/her.gemspec +4 -3
  9. data/lib/her/api.rb +8 -7
  10. data/lib/her/collection.rb +2 -1
  11. data/lib/her/errors.rb +3 -1
  12. data/lib/her/json_api/model.rb +8 -12
  13. data/lib/her/middleware.rb +1 -1
  14. data/lib/her/middleware/accept_json.rb +1 -0
  15. data/lib/her/middleware/first_level_parse_json.rb +6 -5
  16. data/lib/her/middleware/json_api_parser.rb +6 -5
  17. data/lib/her/middleware/parse_json.rb +2 -1
  18. data/lib/her/middleware/second_level_parse_json.rb +6 -5
  19. data/lib/her/model/associations.rb +7 -7
  20. data/lib/her/model/associations/association.rb +7 -9
  21. data/lib/her/model/associations/association_proxy.rb +2 -3
  22. data/lib/her/model/associations/belongs_to_association.rb +2 -3
  23. data/lib/her/model/attributes.rb +14 -6
  24. data/lib/her/model/base.rb +2 -2
  25. data/lib/her/model/http.rb +7 -2
  26. data/lib/her/model/introspection.rb +5 -3
  27. data/lib/her/model/nested_attributes.rb +1 -1
  28. data/lib/her/model/orm.rb +27 -9
  29. data/lib/her/model/parse.rb +10 -12
  30. data/lib/her/model/paths.rb +3 -4
  31. data/lib/her/model/relation.rb +5 -4
  32. data/lib/her/version.rb +1 -1
  33. data/spec/api_spec.rb +3 -0
  34. data/spec/middleware/accept_json_spec.rb +1 -0
  35. data/spec/middleware/first_level_parse_json_spec.rb +2 -1
  36. data/spec/middleware/json_api_parser_spec.rb +1 -0
  37. data/spec/middleware/second_level_parse_json_spec.rb +1 -0
  38. data/spec/model/associations/association_proxy_spec.rb +1 -0
  39. data/spec/model/associations_spec.rb +98 -14
  40. data/spec/model/attributes_spec.rb +9 -3
  41. data/spec/model/callbacks_spec.rb +14 -15
  42. data/spec/model/dirty_spec.rb +1 -0
  43. data/spec/model/http_spec.rb +29 -18
  44. data/spec/model/introspection_spec.rb +3 -2
  45. data/spec/model/nested_attributes_spec.rb +1 -0
  46. data/spec/model/orm_spec.rb +39 -16
  47. data/spec/model/parse_spec.rb +24 -0
  48. data/spec/model/paths_spec.rb +1 -0
  49. data/spec/model/relation_spec.rb +3 -2
  50. data/spec/model/validations_spec.rb +1 -0
  51. data/spec/model_spec.rb +1 -0
  52. data/spec/support/extensions/array.rb +1 -0
  53. data/spec/support/extensions/hash.rb +1 -0
  54. metadata +15 -19
@@ -25,7 +25,7 @@ module Her
25
25
 
26
26
  associations.each do |association_name|
27
27
  unless allowed_association_names.include?(association_name)
28
- raise Her::Errors::AssociationUnknownError.new("Unknown association name :#{association_name}")
28
+ raise Her::Errors::AssociationUnknownError, "Unknown association name :#{association_name}"
29
29
  end
30
30
 
31
31
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
data/lib/her/model/orm.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  module Her
3
4
  module Model
4
5
  # This module adds ORM-like capabilities to the model
@@ -54,12 +55,22 @@ module Her
54
55
 
55
56
  # Similar to save(), except that ResourceInvalid is raised if the save fails
56
57
  def save!
57
- if !self.save
58
+ unless save
58
59
  raise Her::Errors::ResourceInvalid, self
59
60
  end
60
61
  self
61
62
  end
62
63
 
64
+ # Update a resource and return it
65
+ #
66
+ # @example
67
+ # @user = User.find(1)
68
+ # @user.update_attributes(:name => "Tobias Fünke")
69
+ # # Called via PUT "/users/1"
70
+ def update_attributes(attributes)
71
+ assign_attributes(attributes) && save
72
+ end
73
+
63
74
  # Destroy a resource
64
75
  #
65
76
  # @example
@@ -195,7 +206,7 @@ module Her
195
206
  #
196
207
  # User.all # Called via GET "/users?admin=1"
197
208
  # User.new.admin # => 1
198
- def default_scope(block=nil)
209
+ def default_scope(block = nil)
199
210
  @_her_default_scope ||= (!respond_to?(:default_scope) && superclass.respond_to?(:default_scope)) ? superclass.default_scope : scoped
200
211
  @_her_default_scope = @_her_default_scope.instance_exec(&block) unless block.nil?
201
212
  @_her_default_scope
@@ -217,8 +228,15 @@ module Her
217
228
  # @user = User.save_existing(1, { :fullname => "Tobias Fünke" })
218
229
  # # Called via PUT "/users/1"
219
230
  def save_existing(id, params)
231
+ save_existing!(id, params)
232
+ rescue Her::Errors::ResourceInvalid => e
233
+ e.resource
234
+ end
235
+
236
+ # Similar to .save_existing but raises ResourceInvalid if save fails
237
+ def save_existing!(id, params)
220
238
  resource = new(params.merge(primary_key => id))
221
- resource.save
239
+ resource.save!
222
240
  resource
223
241
  end
224
242
 
@@ -227,7 +245,7 @@ module Her
227
245
  # @example
228
246
  # User.destroy_existing(1)
229
247
  # # Called via DELETE "/users/1"
230
- def destroy_existing(id, params={})
248
+ def destroy_existing(id, params = {})
231
249
  request(params.merge(:_method => method_for(:destroy), :_path => build_request_path(params.merge(primary_key => id)))) do |parsed_data, response|
232
250
  data = parse(parsed_data[:data])
233
251
  metadata = parsed_data[:metadata]
@@ -256,15 +274,15 @@ module Her
256
274
  # If the request_new_object_on_build flag is set, the new object is requested via API.
257
275
  def build(attributes = {})
258
276
  params = attributes
259
- return self.new(params) unless self.request_new_object_on_build?
277
+ return new(params) unless request_new_object_on_build?
260
278
 
261
- path = self.build_request_path(params.merge(self.primary_key => 'new'))
262
- method = self.method_for(:new)
279
+ path = build_request_path(params.merge(primary_key => 'new'))
280
+ method = method_for(:new)
263
281
 
264
282
  resource = nil
265
- self.request(params.merge(:_method => method, :_path => path)) do |parsed_data, response|
283
+ request(params.merge(:_method => method, :_path => path)) do |parsed_data, response|
266
284
  if response.success?
267
- resource = self.new_from_parsed_data(parsed_data)
285
+ resource = new_from_parsed_data(parsed_data)
268
286
  end
269
287
  end
270
288
  resource
@@ -10,7 +10,7 @@ module Her
10
10
  # @user.to_params
11
11
  # # => { :id => 1, :name => 'John Smith' }
12
12
  def to_params
13
- self.class.to_params(self.attributes, self.changes)
13
+ self.class.to_params(attributes, changes)
14
14
  end
15
15
 
16
16
  module ClassMethods
@@ -31,7 +31,7 @@ module Her
31
31
  end
32
32
 
33
33
  # @private
34
- def to_params(attributes, changes={})
34
+ def to_params(attributes, changes = {})
35
35
  filtered_attributes = attributes.each_with_object({}) do |(key, value), memo|
36
36
  case value
37
37
  when Her::Model
@@ -45,10 +45,7 @@ module Her
45
45
  filtered_attributes.merge!(embeded_params(attributes))
46
46
 
47
47
  if her_api.options[:send_only_modified_attributes]
48
- filtered_attributes = changes.symbolize_keys.keys.inject({}) do |hash, attribute|
49
- hash[attribute] = filtered_attributes[attribute]
50
- hash
51
- end
48
+ filtered_attributes.slice! *changes.keys.map(&:to_sym)
52
49
  end
53
50
 
54
51
  if include_root_in_json?
@@ -133,11 +130,11 @@ module Her
133
130
  # user.name # => "Tobias"
134
131
  def root_element(value = nil)
135
132
  if value.nil?
136
- if json_api_format?
137
- @_her_root_element ||= self.name.split("::").last.pluralize.underscore.to_sym
138
- else
139
- @_her_root_element ||= self.name.split("::").last.underscore.to_sym
140
- end
133
+ @_her_root_element ||= if json_api_format?
134
+ name.split("::").last.pluralize.underscore.to_sym
135
+ else
136
+ name.split("::").last.underscore.to_sym
137
+ end
141
138
  else
142
139
  @_her_root_element = value.to_sym
143
140
  end
@@ -145,7 +142,8 @@ module Her
145
142
 
146
143
  # @private
147
144
  def root_element_included?(data)
148
- data.keys.to_s.include? @_her_root_element.to_s
145
+ element = data[parsed_root_element]
146
+ element.is_a?(Hash) || element.is_a?(Array)
149
147
  end
150
148
 
151
149
  # @private
@@ -19,7 +19,6 @@ module Her
19
19
  end
20
20
 
21
21
  module ClassMethods
22
-
23
22
  # Define the primary key field that will be used to find and save records
24
23
  #
25
24
  # @example
@@ -88,13 +87,13 @@ module Her
88
87
  # Return a custom path based on the collection path and variable parameters
89
88
  #
90
89
  # @private
91
- def build_request_path(path=nil, parameters={})
90
+ def build_request_path(path = nil, parameters = {})
92
91
  parameters = parameters.try(:with_indifferent_access)
93
92
 
94
93
  unless path.is_a?(String)
95
94
  parameters = path.try(:with_indifferent_access) || parameters
96
95
  path =
97
- if parameters.include?(primary_key) && parameters[primary_key] && !parameters[primary_key].kind_of?(Array)
96
+ if parameters.include?(primary_key) && parameters[primary_key] && !parameters[primary_key].is_a?(Array)
98
97
  resource_path.dup
99
98
  else
100
99
  collection_path.dup
@@ -117,7 +116,7 @@ module Her
117
116
  end
118
117
 
119
118
  # @private
120
- def build_request_path_from_string_or_symbol(path, params={})
119
+ def build_request_path_from_string_or_symbol(path, params = {})
121
120
  path.is_a?(Symbol) ? "#{build_request_path(params)}/#{path}" : path
122
121
  end
123
122
  end
@@ -1,6 +1,7 @@
1
1
  module Her
2
2
  module Model
3
3
  class Relation
4
+
4
5
  # @private
5
6
  attr_accessor :params
6
7
  attr_writer :parent
@@ -32,7 +33,7 @@ module Her
32
33
  # # Fetched via GET "/users?approved=1"
33
34
  def where(params = {})
34
35
  return self if params.blank? && !@_fetch.nil?
35
- self.clone.tap do |r|
36
+ clone.tap do |r|
36
37
  r.params = r.params.merge(params)
37
38
  r.clear_fetch_cache!
38
39
  end
@@ -58,7 +59,7 @@ module Her
58
59
 
59
60
  # @private
60
61
  def kind_of?(thing)
61
- fetch.kind_of?(thing)
62
+ fetch.is_a?(thing)
62
63
  end
63
64
 
64
65
  # Fetch a collection of resources
@@ -68,7 +69,7 @@ module Her
68
69
  @_fetch ||= begin
69
70
  path = @parent.build_request_path(@parent.collection_path, @params)
70
71
  method = @parent.method_for(:find)
71
- @parent.request(@params.merge(:_method => method, :_path => path)) do |parsed_data, response|
72
+ @parent.request(@params.merge(:_method => method, :_path => path)) do |parsed_data, _|
72
73
  @parent.new_collection(parsed_data)
73
74
  end
74
75
  end
@@ -106,7 +107,7 @@ module Her
106
107
  resource
107
108
  end
108
109
 
109
- ids.length > 1 || ids.first.kind_of?(Array) ? results : results.first
110
+ ids.length > 1 || ids.first.is_a?(Array) ? results : results.first
110
111
  end
111
112
 
112
113
  # Fetch first resource with the given attributes.
data/lib/her/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Her
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.1"
3
3
  end
data/spec/api_spec.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "spec_helper.rb")
3
4
 
4
5
  describe Her::API do
@@ -32,6 +33,7 @@ describe Her::API do
32
33
  describe "#request" do
33
34
  before do
34
35
  class SimpleParser < Faraday::Response::Middleware
36
+
35
37
  def on_complete(env)
36
38
  env[:body] = { data: env[:body] }
37
39
  end
@@ -85,6 +87,7 @@ describe Her::API do
85
87
  let(:parsed_data) { subject.request(_method: :get, _path: "users/1")[:parsed_data] }
86
88
  before do
87
89
  class CustomParser < Faraday::Response::Middleware
90
+
88
91
  def on_complete(env)
89
92
  json = MultiJson.load(env[:body], symbolize_keys: true)
90
93
  errors = json.delete(:errors) || []
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require "spec_helper"
3
4
 
4
5
  describe Her::Middleware::AcceptJSON do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require "spec_helper"
3
4
 
4
5
  describe Her::Middleware::FirstLevelParseJSON do
@@ -31,7 +32,7 @@ describe Her::Middleware::FirstLevelParseJSON do
31
32
  end
32
33
 
33
34
  it "ensures the errors are a hash if there are no errors" do
34
- expect(subject.parse(body_with_errors)[:errors]).to eq(name: %w(not_valid should_be_present))
35
+ expect(subject.parse(body_with_errors)[:errors]).to eq(name: %w[not_valid should_be_present])
35
36
  end
36
37
 
37
38
  it "ensures that malformed JSON throws an exception" do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require "spec_helper"
3
4
 
4
5
  describe Her::Middleware::JsonApiParser do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require "spec_helper"
3
4
 
4
5
  describe Her::Middleware::SecondLevelParseJSON do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require "spec_helper"
3
4
 
4
5
  describe Her::Model::Associations::AssociationProxy do
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require File.join(File.dirname(__FILE__), "../spec_helper.rb")
3
4
 
4
5
  describe Her::Model::Associations do
@@ -111,8 +112,7 @@ describe Her::Model::Associations do
111
112
  data_key: :organization,
112
113
  default: nil,
113
114
  class_name: "Organization",
114
- foreign_key: "organization_id",
115
- path: "/organizations/:id"
115
+ foreign_key: "organization_id"
116
116
  }
117
117
  end
118
118
  before { Foo::User.belongs_to :organization }
@@ -120,7 +120,8 @@ describe Her::Model::Associations do
120
120
  it { is_expected.to eql [organization_association] }
121
121
  end
122
122
 
123
- context "multiple" do
123
+ context "specifying non-default path" do
124
+ let(:path) { 'my_special_path' }
124
125
  let(:organization_association) do
125
126
  {
126
127
  name: :organization,
@@ -128,7 +129,22 @@ describe Her::Model::Associations do
128
129
  default: nil,
129
130
  class_name: "Organization",
130
131
  foreign_key: "organization_id",
131
- path: "/organizations/:id"
132
+ path: path
133
+ }
134
+ end
135
+ before { Foo::User.belongs_to :organization, path: path }
136
+
137
+ it { is_expected.to eql [organization_association] }
138
+ end
139
+
140
+ context "multiple" do
141
+ let(:organization_association) do
142
+ {
143
+ name: :organization,
144
+ data_key: :organization,
145
+ default: nil,
146
+ class_name: "Organization",
147
+ foreign_key: "organization_id"
132
148
  }
133
149
  end
134
150
  let(:family_association) do
@@ -137,8 +153,7 @@ describe Her::Model::Associations do
137
153
  data_key: :family,
138
154
  default: nil,
139
155
  class_name: "Family",
140
- foreign_key: "family_id",
141
- path: "/families/:id"
156
+ foreign_key: "family_id"
142
157
  }
143
158
  end
144
159
  before do
@@ -215,8 +230,7 @@ describe Her::Model::Associations do
215
230
  data_key: :org,
216
231
  default: true,
217
232
  class_name: "Business",
218
- foreign_key: "org_id",
219
- path: "/organizations/:id"
233
+ foreign_key: "org_id"
220
234
  }
221
235
  end
222
236
  before do
@@ -296,7 +310,7 @@ describe Her::Model::Associations do
296
310
  stub.get("/users/1/comments") { [200, {}, [{ comment: { id: 4, body: "They're having a FIRESALE?" } }].to_json] }
297
311
  stub.get("/users/1/role") { [200, {}, { id: 3, body: "User" }.to_json] }
298
312
  stub.get("/users/1/posts") { [200, {}, [{ id: 1, body: "blogging stuff", admin_id: 1 }].to_json] }
299
- stub.get("/organizations/1") { [200, {}, { organization: { id: 1, name: "Bluth Company Foo" } }.to_json] }
313
+ stub.get("/organizations/1") { [200, {}, { organization: { id: 1, name: "Bluth Company Foo" } }.to_json] }
300
314
  end
301
315
  end
302
316
  end
@@ -446,6 +460,9 @@ describe Her::Model::Associations do
446
460
  Her::API.setup url: "https://api.example.com" do |builder|
447
461
  builder.use Her::Middleware::FirstLevelParseJSON
448
462
  builder.use Faraday::Request::UrlEncoded
463
+ builder.adapter :test do |stub|
464
+ stub.get("/users/1") { [200, {}, { id: 1, name: "Lindsay Fünke", organization_id: 2 }.to_json] }
465
+ end
449
466
  end
450
467
  end
451
468
 
@@ -526,6 +543,74 @@ describe Her::Model::Associations do
526
543
  end
527
544
  end
528
545
 
546
+ context "handling associations with collection_path" do
547
+ before do
548
+ spawn_model "Foo::Organization" do
549
+ has_many :users
550
+ parse_root_in_json true
551
+ collection_path '/special/organizations'
552
+ end
553
+ spawn_model "Foo::User" do
554
+ belongs_to :organization
555
+ end
556
+ end
557
+
558
+ context "without included data" do
559
+ before(:context) do
560
+ Her::API.setup url: "https://api.example.com" do |builder|
561
+ builder.use Her::Middleware::FirstLevelParseJSON
562
+ builder.use Faraday::Request::UrlEncoded
563
+ builder.adapter :test do |stub|
564
+ stub.get("/users/2") { [200, {}, { id: 2, name: "Lindsay Fünke", organization_id: 2 }.to_json] }
565
+ stub.get("/special/organizations/2") { [200, {}, { organization: { id: 2, name: "Bluth Company" } }.to_json] }
566
+ end
567
+ end
568
+ end
569
+
570
+ let(:user) { Foo::User.find(2) }
571
+
572
+ it "fetches data that was not included through belongs_to" do
573
+ expect(user.organization).to be_a(Foo::Organization)
574
+ expect(user.organization.id).to eq(2)
575
+ expect(user.organization.name).to eq("Bluth Company")
576
+ end
577
+ end
578
+ end
579
+
580
+ context "handling associations with path_prefix" do
581
+ before do
582
+ spawn_model "Foo::Organization" do
583
+ has_many :users
584
+ parse_root_in_json true
585
+ end
586
+ spawn_model "Foo::User" do
587
+ belongs_to :organization
588
+ end
589
+ end
590
+
591
+ context "without included data" do
592
+ before(:context) do
593
+ Her::API.setup url: "https://api.example.com" do |builder|
594
+ builder.use Her::Middleware::FirstLevelParseJSON
595
+ builder.use Faraday::Request::UrlEncoded
596
+ builder.path_prefix = 'special'
597
+ builder.adapter :test do |stub|
598
+ stub.get("/special/users/2") { [200, {}, { id: 2, name: "Lindsay Fünke", organization_id: 2 }.to_json] }
599
+ stub.get("/special/organizations/2") { [200, {}, { organization: { id: 2, name: "Bluth Company" } }.to_json] }
600
+ end
601
+ end
602
+ end
603
+
604
+ let(:user) { Foo::User.find(2) }
605
+
606
+ it "fetches data that was not included through belongs_to" do
607
+ expect(user.organization).to be_a(Foo::Organization)
608
+ expect(user.organization.id).to eq(2)
609
+ expect(user.organization.name).to eq("Bluth Company")
610
+ end
611
+ end
612
+ end
613
+
529
614
  context "handling associations with details in active_model_serializers format" do
530
615
  before do
531
616
  spawn_model "Foo::User" do
@@ -558,7 +643,7 @@ describe Her::Model::Associations do
558
643
  builder.adapter :test do |stub|
559
644
  stub.get("/users/1") { [200, {}, { user: { id: 1, name: "Tobias Fünke", comments: [{ id: 2, body: "Tobias, you blow hard!", user_id: 1 }, { id: 3, body: "I wouldn't mind kissing that man between the cheeks, so to speak", user_id: 1 }], role: { id: 1, body: "Admin" }, organization: { id: 1, name: "Bluth Company" }, organization_id: 1 } }.to_json] }
560
645
  stub.get("/users/1/comments") { [200, {}, { comments: [{ id: 4, body: "They're having a FIRESALE?" }] }.to_json] }
561
- stub.get("/organizations/1") { [200, {}, { organization: { id: 1, name: "Bluth Company Foo" } }.to_json] }
646
+ stub.get("/organizations/1") { [200, {}, { organization: { id: 1, name: "Bluth Company Foo" } }.to_json] }
562
647
  end
563
648
  end
564
649
  end
@@ -616,7 +701,7 @@ describe Her::Model::Associations do
616
701
  stub.get("/users/2") { [200, {}, { user: { id: 2, name: "Lindsay Fünke", organization_id: 1 } }.to_json] }
617
702
  stub.get("/users/2/comments") { [200, {}, { comments: [{ id: 4, body: "They're having a FIRESALE?" }, { id: 5, body: "Is this the tiny town from Footloose?" }] }.to_json] }
618
703
  stub.get("/users/2/comments/5") { [200, {}, { comment: { id: 5, body: "Is this the tiny town from Footloose?" } }.to_json] }
619
- stub.get("/organizations/1") { [200, {}, { organization: { id: 1, name: "Bluth Company Foo" } }.to_json] }
704
+ stub.get("/organizations/1") { [200, {}, { organization: { id: 1, name: "Bluth Company Foo" } }.to_json] }
620
705
  end
621
706
  end
622
707
  end
@@ -661,8 +746,7 @@ describe Her::Model::Associations do
661
746
  builder.adapter :test do |stub|
662
747
  stub.get("/users/1") { [200, {}, { id: 1, name: "Tobias Fünke", organization: { id: 1, name: "Bluth Company Inc." }, organization_id: 1 }.to_json] }
663
748
  stub.get("/users/4") { [200, {}, { id: 1, name: "Tobias Fünke", organization: { id: 1, name: "Bluth Company Inc." } }.to_json] }
664
- stub.get("/users/3") { [200, {}, { id: 2, name: "Lindsay Fünke", company: nil }.to_json] }
665
- stub.get("/companies/1") { [200, {}, { id: 1, name: "Bluth Company" }.to_json] }
749
+ stub.get("/users/3") { [200, {}, { id: 2, name: "Lindsay Fünke", organization: nil }.to_json] }
666
750
  end
667
751
  end
668
752
  end
@@ -699,7 +783,7 @@ describe Her::Model::Associations do
699
783
  builder.use Faraday::Request::UrlEncoded
700
784
  builder.adapter :test do |stub|
701
785
  stub.get("/users/2") { [200, {}, { id: 2, name: "Lindsay Fünke", organization_id: 1 }.to_json] }
702
- stub.get("/companies/1") { [200, {}, { id: 1, name: "Bluth Company" }.to_json] }
786
+ stub.get("/organizations/1") { [200, {}, { id: 1, name: "Bluth Company" }.to_json] }
703
787
  end
704
788
  end
705
789
  end