cistern 0.11.1 → 0.11.2.pre2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b042d8632a8caf3a3b22b917105d96a08c5a589d
4
- data.tar.gz: d83e62f2b43df0cc5d8043065679e41f5372d7a5
3
+ metadata.gz: 1fd7d5118bf1337d421cb49d37ec448c99a6a348
4
+ data.tar.gz: 3eb9da77dd49b2fdca439c4d0112af1ecf3e0d36
5
5
  SHA512:
6
- metadata.gz: df23a5684addc4f8c446ec88b9b983e4d288b9bd1a09421478658c93f5fd67e88793f6b16ad7fb3191c69216702ce3b20536af7b3565d3db20b64183d9d34234
7
- data.tar.gz: 6cebf42a5df2dfa6602c89d763f5c1d1a07b1b277bb4da34ed5ce682e6d64434815478e7e12a3cee2dc75d7b70ccb4b6cc944b52299e5b158bf01de596e87959
6
+ metadata.gz: 26f8cf18cabc2699cd6b8e1ab18628408254e9ad3dc3d992cf923b322c3fae6bfc5b1406decb255ba969031fd98ea03d7eb39780915d4cd97048d46e9bcbead3
7
+ data.tar.gz: 36f14d5bfbfae722156cd722ddae8fe4b5f4028631d98578f56ab2cef8812153d74fc8130cc98c95ee885b831c371554fdbc5da1c865c2f7ad7684fad78d1aa5
data/README.md CHANGED
@@ -208,7 +208,7 @@ Patient::Mock.store_in(:hash)
208
208
 
209
209
  ### Model
210
210
 
211
- * `connection` represents the associated `Foo::Client` instance.
211
+ * `service` represents the associated `Foo::Client` instance.
212
212
  * `collection` represents the related collection (if applicable)
213
213
 
214
214
  Example
@@ -225,7 +225,7 @@ class Foo::Client::Bar < Cistern::Model
225
225
  params = {
226
226
  "id" => self.identity
227
227
  }
228
- self.connection.destroy_bar(params).body["request"]
228
+ self.service.destroy_bar(params).body["request"]
229
229
  end
230
230
 
231
231
  def save
@@ -239,11 +239,11 @@ class Foo::Client::Bar < Cistern::Model
239
239
  }
240
240
 
241
241
  if new_record?
242
- merge_attributes(connection.create_bar(params).body["bar"])
242
+ merge_attributes(service.create_bar(params).body["bar"])
243
243
  else
244
244
  requires :identity
245
245
 
246
- merge_attributes(connection.update_bar(params).body["bar"])
246
+ merge_attributes(service.update_bar(params).body["bar"])
247
247
  end
248
248
  end
249
249
  end
@@ -286,7 +286,7 @@ class Foo::Client::Bars < Cistern::Collection
286
286
  model Foo::Client::Bar
287
287
 
288
288
  def all(params = {})
289
- response = connection.get_bars(params)
289
+ response = service.get_bars(params)
290
290
 
291
291
  data = response.body
292
292
 
@@ -300,11 +300,11 @@ class Foo::Client::Bars < Cistern::Collection
300
300
  }
301
301
  params.merge!("location" => options[:location]) if options.key?(:location)
302
302
 
303
- connection.requests.new(connection.discover_bar(params).body["request"])
303
+ service.requests.new(service.discover_bar(params).body["request"])
304
304
  end
305
305
 
306
306
  def get(id)
307
- if data = connection.get_bar("id" => id).body["bar"]
307
+ if data = service.get_bar("id" => id).body["bar"]
308
308
  new(data)
309
309
  else
310
310
  nil
@@ -9,6 +9,7 @@ module Cistern
9
9
  Timeout = Class.new(Error)
10
10
 
11
11
  require 'cistern/hash'
12
+ require 'cistern/string'
12
13
  require 'cistern/mock'
13
14
  require 'cistern/wait_for'
14
15
  require 'cistern/attributes'
@@ -16,6 +17,7 @@ module Cistern
16
17
  require 'cistern/model'
17
18
  require 'cistern/service'
18
19
  require 'cistern/singular'
20
+ require 'cistern/request'
19
21
  require 'cistern/data'
20
22
  require 'cistern/data/hash'
21
23
  require 'cistern/data/redis'
@@ -189,7 +189,7 @@ module Cistern::Attributes
189
189
  end
190
190
  end
191
191
 
192
- protected_methods = Cistern::Model.instance_methods - [:connection, :identity, :collection]
192
+ protected_methods = Cistern::Model.instance_methods - [:service, :identity, :collection]
193
193
 
194
194
  if !protected_methods.include?(key) && self.respond_to?("#{key}=", true)
195
195
  send("#{key}=", value)
@@ -236,7 +236,7 @@ module Cistern::Attributes
236
236
  protected
237
237
 
238
238
  def missing_attributes(args)
239
- ([:connection] | args).select{|arg| send("#{arg}").nil?}
239
+ ([:service] | args).select{|arg| send("#{arg}").nil?}
240
240
  end
241
241
 
242
242
  def changed!(attribute, from, to)
@@ -1,6 +1,4 @@
1
- class Cistern::Collection
2
- extend Cistern::Attributes::ClassMethods
3
- include Cistern::Attributes::InstanceMethods
1
+ module Cistern::Collection
4
2
 
5
3
  BLACKLISTED_ARRAY_METHODS = [
6
4
  :compact!, :flatten!, :reject!, :reverse!, :rotate!, :map!,
@@ -8,13 +6,21 @@ class Cistern::Collection
8
6
  :keep_if, :pop, :shift, :delete_at, :compact
9
7
  ].to_set # :nodoc:
10
8
 
11
- attr_accessor :records, :loaded, :connection
9
+ def self.service_collection(service, klass)
10
+ plural_name = Cistern::String.underscore(Cistern::String.demodulize(klass.name))
12
11
 
13
- def self.model(new_model=nil)
14
- if new_model == nil
15
- @model
16
- else
17
- @model = new_model
12
+ service.const_get(:Collections).module_eval <<-EOS, __FILE__, __LINE__
13
+ def #{plural_name}(attributes={})
14
+ #{klass.name}.new(attributes.merge(service: self))
15
+ end
16
+ EOS
17
+ end
18
+
19
+ attr_accessor :records, :loaded, :service
20
+
21
+ module ClassMethods
22
+ def model(new_model=nil)
23
+ @model ||= new_model
18
24
  end
19
25
  end
20
26
 
@@ -73,7 +79,7 @@ class Cistern::Collection
73
79
  model.new(
74
80
  {
75
81
  :collection => self,
76
- :connection => connection,
82
+ :service => service,
77
83
  }.merge(attributes)
78
84
  )
79
85
  end
@@ -1,8 +1,12 @@
1
- class Cistern::Model
2
- extend Cistern::Attributes::ClassMethods
1
+ module Cistern::Model
3
2
  include Cistern::Attributes::InstanceMethods
4
3
 
5
- attr_accessor :collection, :connection
4
+ def self.included(klass)
5
+ klass.send(:extend, Cistern::Attributes::ClassMethods)
6
+ klass.send(:include, Cistern::Attributes::InstanceMethods)
7
+ end
8
+
9
+ attr_accessor :collection, :service
6
10
 
7
11
  def inspect
8
12
  if Cistern.formatter
@@ -52,15 +56,15 @@ class Cistern::Model
52
56
  end
53
57
  end
54
58
 
55
- def service
56
- self.connection ? self.connection.class : Cistern
59
+ def wait_for(timeout = self.service_class.timeout, interval = self.service_class.poll_interval, &block)
60
+ service_class.wait_for(timeout, interval) { reload && block.call(self) }
57
61
  end
58
62
 
59
- def wait_for(timeout = self.service.timeout, interval = self.service.poll_interval, &block)
60
- service.wait_for(timeout, interval) { reload && block.call(self) }
63
+ def wait_for!(timeout = self.service_class.timeout, interval = self.service_class.poll_interval, &block)
64
+ service_class.wait_for!(timeout, interval) { reload && block.call(self) }
61
65
  end
62
66
 
63
- def wait_for!(timeout = self.service.timeout, interval = self.service.poll_interval, &block)
64
- service.wait_for!(timeout, interval) { reload && block.call(self) }
67
+ def service_class
68
+ self.service ? self.service.class : Cistern
65
69
  end
66
70
  end
@@ -0,0 +1,28 @@
1
+ module Cistern::Request
2
+ def self.service_request(service, klass)
3
+ request = klass.request_name || Cistern::String.camelize(klass.name)
4
+
5
+ service::Mock.module_eval <<-EOS, __FILE__, __LINE__
6
+ def #{request}(*args)
7
+ #{klass}.new(self).mock(*args)
8
+ end
9
+ EOS
10
+
11
+ service::Real.module_eval <<-EOS, __FILE__, __LINE__
12
+ def #{request}(*args)
13
+ #{klass}.new(self).real(*args)
14
+ end
15
+ EOS
16
+ end
17
+
18
+ attr_reader :service
19
+
20
+ def initialize(service)
21
+ @service = service
22
+ end
23
+
24
+ module ClassMethods
25
+ def request_name
26
+ end
27
+ end
28
+ end
@@ -42,6 +42,44 @@ class Cistern::Service
42
42
  def initialize(options={})
43
43
  end
44
44
  end
45
+
46
+ class Model
47
+ include Cistern::Model
48
+
49
+ def self.service
50
+ #{klass.name}
51
+ end
52
+ end
53
+
54
+ class Collection
55
+ include Cistern::Collection
56
+
57
+ def self.inherited(klass)
58
+ klass.extend(Cistern::Attributes::ClassMethods)
59
+ klass.extend(Cistern::Collection::ClassMethods)
60
+ klass.include(Cistern::Attributes::InstanceMethods)
61
+
62
+ Cistern::Collection.service_collection(service, klass)
63
+ end
64
+
65
+ def self.service
66
+ #{klass.name}
67
+ end
68
+ end
69
+
70
+ class Request
71
+ include Cistern::Request
72
+
73
+ def self.inherited(klass)
74
+ klass.extend(Cistern::Request::ClassMethods)
75
+
76
+ Cistern::Request.service_request(service, klass)
77
+ end
78
+
79
+ def self.service
80
+ #{klass.name}
81
+ end
82
+ end
45
83
  EOS
46
84
 
47
85
  klass.send(:const_set, :Timeout, Class.new(Cistern::Error))
@@ -57,30 +95,6 @@ class Cistern::Service
57
95
  klass::Real.timeout_error = klass::Timeout
58
96
  end
59
97
 
60
- def collection_path(collection_path = nil)
61
- if collection_path
62
- @collection_path = collection_path
63
- else
64
- @collection_path
65
- end
66
- end
67
-
68
- def model_path(model_path = nil)
69
- if model_path
70
- @model_path = model_path
71
- else
72
- @model_path
73
- end
74
- end
75
-
76
- def request_path(request_path = nil)
77
- if request_path
78
- @request_path = request_path
79
- else
80
- @request_path
81
- end
82
- end
83
-
84
98
  def collections
85
99
  @collections ||= []
86
100
  end
@@ -109,22 +123,10 @@ class Cistern::Service
109
123
  self.recognized_arguments.concat(args)
110
124
  end
111
125
 
112
- def model(model_name, options={})
113
- models << [model_name, options]
114
- end
115
-
116
126
  def mocked_requests
117
127
  @mocked_requests ||= []
118
128
  end
119
129
 
120
- def request(request_name, options={})
121
- requests << [request_name, options]
122
- end
123
-
124
- def collection(collection_name, options={})
125
- collections << [collection_name, options]
126
- end
127
-
128
130
  def validate_options(options={})
129
131
  required_options = Cistern::Hash.slice(options, *required_arguments)
130
132
 
@@ -141,66 +143,8 @@ class Cistern::Service
141
143
  end
142
144
  end
143
145
 
144
- def setup_requirements
145
- @required ||= false
146
- unless @required
147
-
148
- # setup models
149
- models.each do |model, options|
150
- unless options[:require] == false
151
- require(options[:require] || File.join(@model_path, model.to_s))
152
- end
153
-
154
- class_name = options[:class] || model.to_s.split("_").map(&:capitalize).join
155
- singular_name = options[:model] || model.to_s.gsub("/", "_")
156
-
157
- self.const_get(:Collections).module_eval <<-EOS, __FILE__, __LINE__
158
- def #{singular_name}(attributes={})
159
- #{service}::#{class_name}.new({connection: self}.merge(attributes))
160
- end
161
- EOS
162
- end
163
-
164
- # setup requests
165
- requests.each do |request, options|
166
- unless options[:require] == false || service::Real.method_defined?(request.to_s)
167
- require(options[:require] || File.join(@request_path, request.to_s))
168
- end
169
-
170
- if service::Mock.method_defined?(request)
171
- mocked_requests << request
172
- else
173
- service::Mock.module_eval <<-EOS, __FILE__, __LINE__
174
- def #{request}(*args)
175
- Cistern::Mock.not_implemented(request)
176
- end
177
- EOS
178
- end
179
- end
180
-
181
- # setup collections
182
- collections.each do |collection, options|
183
- unless options[:require] == false
184
- require(options[:require] || File.join(@collection_path || @model_path, collection.to_s))
185
- end
186
-
187
- class_name = collection.to_s.split("/").map(&:capitalize).join("::").split("_").map { |s| "#{s[0].upcase}#{s[1..-1]}" }.join
188
- plural_name = options[:collection] || collection.to_s.gsub("/", "_")
189
-
190
- self.const_get(:Collections).module_eval <<-EOS, __FILE__, __LINE__
191
- def #{plural_name}(attributes={})
192
- #{service}::#{class_name}.new({connection: self}.merge(attributes))
193
- end
194
- EOS
195
- end
196
-
197
- @required = true
198
- end
199
- end
200
-
201
146
  def new(options={})
202
147
  validate_options(options)
203
- setup_requirements
204
148
 
205
149
  self.const_get(self.mocking? ? :Mock : :Real).new(options)
206
150
  end
@@ -2,7 +2,7 @@ class Cistern::Singular
2
2
  extend Cistern::Attributes::ClassMethods
3
3
  include Cistern::Attributes::InstanceMethods
4
4
 
5
- attr_accessor :connection
5
+ attr_accessor :service
6
6
 
7
7
  def inspect
8
8
  if Cistern.formatter
@@ -0,0 +1,31 @@
1
+ class Cistern::String
2
+ def self.camelize(string)
3
+ string.gsub(/[A-Z]+/) { |w| "_#{w.downcase}" }.gsub(/^_/, "")
4
+ end
5
+
6
+ # File activesupport/lib/active_support/inflector/methods.rb, line 90
7
+ def self.underscore(camel_cased_word)
8
+ word = camel_cased_word.to_s.gsub('::', '/')
9
+ #word.gsub!(/(?:([A-Za-z\d])|^)(#{inflections.acronym_regex})(?=\b|[^a-z])/) { "#{$1}#{$1 && '_'}#{$2.downcase}" }
10
+ word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
11
+ word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
12
+ word.tr!("-", "_")
13
+ word.downcase!
14
+ word
15
+ end
16
+
17
+ # File activesupport/lib/active_support/inflector/methods.rb, line 168
18
+ def self.demodulize(path)
19
+ path = path.to_s
20
+ if i = path.rindex('::')
21
+ path[(i+2)..-1]
22
+ else
23
+ path
24
+ end
25
+ end
26
+
27
+ # @todo omg so bad
28
+ def self.pluralize(string)
29
+ "#{string}s"
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module Cistern
2
- VERSION = "0.11.1"
2
+ VERSION = "0.11.2.pre2"
3
3
  end
@@ -1,13 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Cistern::Collection" do
4
-
5
- class SampleCollectionModel < Cistern::Model
4
+ class SampleCollectionModel < Sample::Model
6
5
  identity :id
7
6
  attribute :name
8
7
  end
9
8
 
10
- class SampleCollection < Cistern::Collection
9
+ class SampleCollection < Sample::Collection
11
10
  model SampleCollectionModel
12
11
 
13
12
  def all
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Cistern::Model#dirty" do
4
- class DirtySpec < Cistern::Model
4
+ class DirtySpec < Sample::Model
5
5
  identity :id
6
6
 
7
7
  attribute :name
@@ -1,13 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "#inspect" do
4
- class Inspector < Cistern::Model
4
+ class Inspector < Sample::Model
5
5
  identity :id
6
6
  attribute :name
7
7
  end
8
8
 
9
- class Inspectors < Cistern::Collection
10
-
9
+ class Inspectors < Sample::Collection
11
10
  model Inspector
12
11
 
13
12
  def all(options={})
@@ -1,37 +1,31 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'mock data' do
4
- class Patient < Cistern::Service
5
- request :diagnosis
6
- request :treat
7
-
8
- class Real
9
- def diagnosis(options={})
10
- end
4
+ class Diagnosis < Sample::Request
5
+ def real(diagnosis)
6
+ end
11
7
 
12
- def treat(options={})
13
- end
8
+ def mock(diagnosis)
9
+ service.data.store(:diagnosis, service.data.fetch(:diagnosis) + [diagnosis])
14
10
  end
11
+ end
15
12
 
16
- class Mock
17
- def diagnosis(diagnosis)
18
- #self.data[:diagnosis] << rand(2) == 0 ? "sick" : "healthy"
19
- self.data.store(:diagnosis, self.data.fetch(:diagnosis) + [diagnosis])
20
- end
13
+ class Treat < Sample::Request
14
+ def real(treatment)
15
+ end
21
16
 
22
- def treat(treatment)
23
- self.data[:treatments] += [treatment]
24
- end
17
+ def mock(treatment)
18
+ service.data[:treatments] += [treatment]
25
19
  end
26
20
  end
27
21
 
28
22
  shared_examples "mock_data#backend" do |backend, options|
29
23
  it "should store mock data" do
30
- Patient.mock!
31
- Patient::Mock.store_in(backend, options)
32
- Patient.reset!
24
+ Sample.mock!
25
+ Sample::Mock.store_in(backend, options)
26
+ Sample.reset!
33
27
 
34
- p = Patient.new
28
+ p = Sample.new
35
29
  p.diagnosis("sick")
36
30
  expect(p.data[:diagnosis]).to eq(["sick"])
37
31
 
@@ -42,7 +36,7 @@ describe 'mock data' do
42
36
  p.treat("healthy")
43
37
  expect(p.data[:treatments]).to eq(["healthy"])
44
38
 
45
- Patient.reset!
39
+ Sample.reset!
46
40
 
47
41
  expect(p.data[:treatments]).to eq([])
48
42
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe "Cistern::Model" do
4
4
  describe "#update" do
5
- class UpdateSpec < Cistern::Model
5
+ class UpdateSpec < Sample::Model
6
6
  identity :id
7
7
  attribute :name
8
8
  attribute :properties
@@ -21,7 +21,7 @@ describe "Cistern::Model" do
21
21
  end
22
22
 
23
23
  it "should duplicate a model" do
24
- class DupSpec < Cistern::Model
24
+ class DupSpec < Sample::Model
25
25
  identity :id
26
26
  attribute :name
27
27
  attribute :properties
@@ -38,7 +38,7 @@ describe "Cistern::Model" do
38
38
  end
39
39
 
40
40
  context "attribute parsing" do
41
- class TypeSpec < Cistern::Model
41
+ class TypeSpec < Sample::Model
42
42
  identity :id
43
43
  attribute :name, type: :string
44
44
  attribute :created_at, type: :time
@@ -155,17 +155,17 @@ describe "Cistern::Model" do
155
155
 
156
156
  describe "#requires" do
157
157
  it "should raise if attribute not provided" do
158
- expect { TypeSpec.new({"connection" => "fake", "something" => {"id" => "12"}}).save }.to raise_exception(ArgumentError)
158
+ expect { TypeSpec.new({"service" => "fake", "something" => {"id" => "12"}}).save }.to raise_exception(ArgumentError)
159
159
  end
160
160
 
161
161
  it "should raise if attribute is provided and is nil" do
162
- expect { TypeSpec.new({"connection" => "fake", "custom" => nil}).save }.to raise_exception(ArgumentError)
162
+ expect { TypeSpec.new({"service" => "fake", "custom" => nil}).save }.to raise_exception(ArgumentError)
163
163
  end
164
164
  end
165
165
  end
166
166
 
167
167
  context "attribute coverage info collecting", :coverage do
168
- class CoverageSpec < Cistern::Model
168
+ class CoverageSpec < Sample::Model
169
169
  identity :id
170
170
 
171
171
  attribute :used, type: :string
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Cistern::Request" do
4
+ class SampleService < Cistern::Service
5
+ recognizes :key
6
+
7
+ class Real
8
+ attr_reader :service_args
9
+
10
+ def initialize(*args)
11
+ @service_args = args
12
+ end
13
+ end
14
+ end
15
+
16
+ # @todo Sample::Service.request
17
+ class ListSamples < SampleService::Request
18
+ # @todo name
19
+ # name :list_all_samples
20
+ def real(*args)
21
+ service.service_args + args + ["real"]
22
+ end
23
+
24
+ def mock(*args)
25
+ args + ["mock"]
26
+ end
27
+ end
28
+
29
+ it "should execute a new-style request" do
30
+ expect(SampleService.new.list_samples("sample1")).to eq([{}, "sample1", "real"])
31
+ expect(SampleService::Real.new.list_samples("sample2")).to eq(["sample2", "real"])
32
+ expect(SampleService::Mock.new.list_samples("sample3")).to eq(["sample3", "mock"])
33
+
34
+ # service access
35
+ expect(SampleService.new(:key => "value").list_samples("stat")).to eq([{:key => "value"}, "stat", "real"])
36
+ end
37
+ end
File without changes
@@ -6,8 +6,8 @@ describe "Cistern::Singular" do
6
6
  attribute :count, type: :number
7
7
 
8
8
  def fetch_attributes
9
- #test that initialize waits for connection to be defined
10
- raise "missing connection" unless connection
9
+ #test that initialize waits for service to be defined
10
+ raise "missing service" unless service
11
11
 
12
12
  @counter ||= 0
13
13
  @counter += 1
@@ -16,11 +16,11 @@ describe "Cistern::Singular" do
16
16
  end
17
17
 
18
18
  it "should work" do
19
- expect(SampleSingular.new(connection: :fake).name).to eq("amazing")
19
+ expect(SampleSingular.new(service: :fake).name).to eq("amazing")
20
20
  end
21
21
 
22
22
  it "should reload" do
23
- singular = SampleSingular.new(connection: :fake)
23
+ singular = SampleSingular.new(service: :fake)
24
24
  old_count = singular.count
25
25
  expect(singular.count).to eq(old_count)
26
26
  expect(singular.reload.count).to be > old_count
@@ -4,6 +4,7 @@ if ENV["TRAVIS"]
4
4
  end
5
5
 
6
6
  require File.expand_path('../../lib/cistern', __FILE__)
7
+ Dir[File.expand_path("../{support,shared,matchers,fixtures}/*.rb", __FILE__)].each{|f| require(f)}
7
8
 
8
9
  Bundler.require(:test)
9
10
 
@@ -0,0 +1 @@
1
+ class Sample < Cistern::Service; end
@@ -1,23 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
- class WaitForService < Cistern::Service
4
- model :wait_for_model, require: false
5
- collection :wait_for_models, require: false
6
-
7
- class Real
8
- def initialize(*args)
9
- end
10
- end
11
- end
12
-
13
- class WaitForService::WaitForModel < Cistern::Model
3
+ class WaitForModel < Sample::Model
14
4
  identity :id
15
5
 
16
6
  attribute :name
17
7
  end
18
8
 
19
- class WaitForService::WaitForModels < Cistern::Collection
20
- model WaitForService::WaitForModel
9
+ class WaitForModels < Sample::Collection
10
+ model WaitForModel
21
11
 
22
12
  def get(identity)
23
13
  self
@@ -37,17 +27,17 @@ describe 'Cistern#wait_for!' do
37
27
  end
38
28
 
39
29
  describe 'Cistern::Model#wait_for!' do
40
- let(:service) { WaitForService.new }
30
+ let(:service) { Sample.new }
41
31
  let(:model) { service.wait_for_models.new(identity: 1) }
42
32
 
43
33
  it "should raise if timeout exceeded" do
44
- expect { model.wait_for!(0, 0) { false } }.to raise_exception(WaitForService::Timeout)
34
+ expect { model.wait_for!(0, 0) { false } }.to raise_exception(Sample::Timeout)
45
35
  end
46
36
  end
47
37
 
48
38
 
49
39
  describe "WaitForModel#timeout" do
50
- let(:service) { WaitForService.new }
40
+ let(:service) { Sample.new }
51
41
  let(:model) { service.wait_for_models.new(identity: 1) }
52
42
 
53
43
  it "should use service-specific timeout in #wait_for" do
@@ -59,7 +49,7 @@ describe "WaitForModel#timeout" do
59
49
  timeout(2) do
60
50
  expect do
61
51
  model.wait_for! { sleep(0.2); elapsed += 0.2; elapsed > 0.2 }
62
- end.to raise_exception(WaitForService::Timeout)
52
+ end.to raise_exception(Sample::Timeout)
63
53
  end
64
54
  end
65
55
 
@@ -72,7 +62,7 @@ describe "WaitForModel#timeout" do
72
62
  timeout(2) do
73
63
  expect do
74
64
  model.wait_for!(0.1) { sleep(0.2); elapsed += 0.2; elapsed > 0.2 }
75
- end.to raise_exception(WaitForService::Timeout)
65
+ end.to raise_exception(Sample::Timeout)
76
66
  end
77
67
  end
78
68
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cistern
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.11.2.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Lane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-13 00:00:00.000000000 Z
11
+ date: 2014-10-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: API client framework extracted from Fog
14
14
  email:
@@ -39,8 +39,10 @@ files:
39
39
  - lib/cistern/hash.rb
40
40
  - lib/cistern/mock.rb
41
41
  - lib/cistern/model.rb
42
+ - lib/cistern/request.rb
42
43
  - lib/cistern/service.rb
43
44
  - lib/cistern/singular.rb
45
+ - lib/cistern/string.rb
44
46
  - lib/cistern/timeout.rb
45
47
  - lib/cistern/version.rb
46
48
  - lib/cistern/wait_for.rb
@@ -50,8 +52,11 @@ files:
50
52
  - spec/hash_spec.rb
51
53
  - spec/mock_data_spec.rb
52
54
  - spec/model_spec.rb
55
+ - spec/request_spec.rb
56
+ - spec/service_spec.rb
53
57
  - spec/singular_spec.rb
54
58
  - spec/spec_helper.rb
59
+ - spec/support/service.rb
55
60
  - spec/wait_for_spec.rb
56
61
  homepage: http://joshualane.com/cistern
57
62
  licenses:
@@ -68,9 +73,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
73
  version: '0'
69
74
  required_rubygems_version: !ruby/object:Gem::Requirement
70
75
  requirements:
71
- - - ">="
76
+ - - ">"
72
77
  - !ruby/object:Gem::Version
73
- version: '0'
78
+ version: 1.3.1
74
79
  requirements: []
75
80
  rubyforge_project:
76
81
  rubygems_version: 2.2.2
@@ -84,7 +89,10 @@ test_files:
84
89
  - spec/hash_spec.rb
85
90
  - spec/mock_data_spec.rb
86
91
  - spec/model_spec.rb
92
+ - spec/request_spec.rb
93
+ - spec/service_spec.rb
87
94
  - spec/singular_spec.rb
88
95
  - spec/spec_helper.rb
96
+ - spec/support/service.rb
89
97
  - spec/wait_for_spec.rb
90
98
  has_rdoc: