cistern 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module Cistern
2
- VERSION = '2.3.0'
2
+ VERSION = '2.4.0'
3
3
  end
@@ -75,7 +75,7 @@ describe Cistern::Attributes, 'parsing' do
75
75
  it 'should parse string' do
76
76
  expect(TypeSpec.new(name: 1).name).to eq('1')
77
77
  expect(TypeSpec.new(name: "b").name).to eq('b')
78
- expect(TypeSpec.new(name: nil).name).to eq("")
78
+ expect(TypeSpec.new(name: nil).name).to eq(nil)
79
79
  end
80
80
 
81
81
  it 'should allow nils in string types' do
@@ -30,6 +30,6 @@ describe 'coverage', :coverage do
30
30
 
31
31
  it "should store how many times an attribute's reader is called" do
32
32
  expect(CoverageSpec.attributes[:used][:coverage_hits]).to eq(2)
33
- expect(CoverageSpec.attributes[:unused][:coverage_hits]).to eq(0)
33
+ expect(CoverageSpec.attributes[:unused][:coverage_hits]).to eq(3)
34
34
  end
35
35
  end
@@ -49,3 +49,38 @@ describe 'Cistern::Hash' do
49
49
  end
50
50
  end
51
51
  end
52
+
53
+ shared_examples_for 'hash_support' do
54
+ it { should respond_to(:hash_except) }
55
+ it { should respond_to(:hash_except!) }
56
+ it { should respond_to(:hash_slice) }
57
+ it { should respond_to(:hash_stringify_keys) }
58
+ end
59
+
60
+ describe Cistern::Model do
61
+ subject { Class.new(Sample::Model).new }
62
+
63
+ include_examples 'hash_support'
64
+ end
65
+
66
+ describe Cistern::Collection do
67
+ subject { Class.new(Sample::Collection).new }
68
+
69
+ include_examples 'hash_support'
70
+ end
71
+
72
+ describe Cistern::Singular do
73
+ subject { Class.new(Sample::Singular) do
74
+ def reload
75
+ attributes
76
+ end
77
+ end.new({}) }
78
+
79
+ include_examples 'hash_support'
80
+ end
81
+
82
+ describe Cistern::Request do
83
+ subject { Class.new(Sample::Request).new({}) }
84
+
85
+ include_examples 'hash_support'
86
+ end
@@ -1,6 +1,20 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'Cistern::Model' do
4
+ describe 'inheritance' do
5
+ it 'provides the child with the attributes of the parent' do
6
+ parent = Class.new(Sample::Model) do
7
+ attribute :parent
8
+ end
9
+
10
+ child = Class.new(parent) do
11
+ attribute :child
12
+ end
13
+
14
+ expect(parent.attributes.keys).to contain_exactly(:parent)
15
+ expect(child.attributes.keys).to contain_exactly(:parent, :child)
16
+ end
17
+ end
4
18
  describe '#update' do
5
19
  class UpdateSpec < Sample::Model
6
20
  identity :id
@@ -1,35 +1,43 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'Cistern::Singular' do
4
- class SampleSingular < Sample::Singular
5
- attribute :name
4
+ class Settings < Sample::Singular
5
+ attribute :name, type: :string
6
6
  attribute :count, type: :number
7
7
 
8
- def fetch_attributes
9
- # test that initialize waits for cistern to be defined
10
- fail 'missing cistern' unless cistern
8
+ def save
9
+ result = @@settings = attributes.merge(dirty_attributes)
11
10
 
12
- @counter ||= 0
13
- @counter += 1
14
- { name: 'amazing', count: @counter }
11
+ merge_attributes(result)
15
12
  end
16
- end
17
13
 
18
- it 'should work' do
19
- expect(Sample.new.sample_singular.name).to eq('amazing')
14
+ def get
15
+ settings = @@settings ||= {}
16
+ settings[:count] ||= 0
17
+ settings[:count] += 1
18
+
19
+ merge_attributes(settings)
20
+ end
20
21
  end
21
22
 
23
+ let!(:service) { Sample.new }
24
+
22
25
  describe 'deprecation', :deprecated do
23
26
  it 'responds to #service' do
24
- sample = Sample.new.sample_singular
27
+ sample = service.settings.load
28
+
25
29
  expect(sample.service).to eq(sample.cistern)
26
30
  end
27
31
  end
28
32
 
29
- it 'should reload' do
30
- singular = Sample.new.sample_singular
31
- old_count = singular.count
32
- expect(singular.count).to eq(old_count)
33
- expect(singular.reload.count).to be > old_count
33
+ it 'reloads' do
34
+ singular = service.settings(count: 0)
35
+
36
+ expect { singular.reload }.to change(singular, :count).by(1)
37
+ end
38
+
39
+ it 'updates' do
40
+ service.settings.update(name: 6)
41
+ expect(service.settings.load.name).to eq('6')
34
42
  end
35
43
  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: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Lane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-17 00:00:00.000000000 Z
11
+ date: 2016-07-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: API client framework extracted from Fog
14
14
  email:
@@ -20,6 +20,7 @@ files:
20
20
  - ".gemrelease"
21
21
  - ".gitignore"
22
22
  - ".travis.yml"
23
+ - Appraisals
23
24
  - CHANGELOG.md
24
25
  - Gemfile
25
26
  - Guardfile
@@ -28,6 +29,7 @@ files:
28
29
  - Rakefile
29
30
  - TODO.md
30
31
  - cistern.gemspec
32
+ - gemfiles/ruby_lt_2.0.gemfile
31
33
  - lib/cistern.rb
32
34
  - lib/cistern/attributes.rb
33
35
  - lib/cistern/client.rb
@@ -41,6 +43,7 @@ files:
41
43
  - lib/cistern/formatter/default.rb
42
44
  - lib/cistern/formatter/formatador.rb
43
45
  - lib/cistern/hash.rb
46
+ - lib/cistern/hash_support.rb
44
47
  - lib/cistern/mock.rb
45
48
  - lib/cistern/model.rb
46
49
  - lib/cistern/request.rb
@@ -105,3 +108,4 @@ test_files:
105
108
  - spec/spec_helper.rb
106
109
  - spec/support/service.rb
107
110
  - spec/wait_for_spec.rb
111
+ has_rdoc: