acfs 1.6.0 → 1.7.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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -0
  3. data/README.md +16 -19
  4. data/acfs.gemspec +2 -0
  5. data/lib/acfs/adapter/typhoeus.rb +6 -4
  6. data/lib/acfs/configuration.rb +13 -3
  7. data/lib/acfs/errors.rb +1 -1
  8. data/lib/acfs/global.rb +2 -2
  9. data/lib/acfs/location.rb +1 -1
  10. data/lib/acfs/operation.rb +1 -1
  11. data/lib/acfs/request/callbacks.rb +1 -1
  12. data/lib/acfs/request.rb +1 -1
  13. data/lib/acfs/resource/attributes/uuid.rb +1 -1
  14. data/lib/acfs/resource/locatable.rb +2 -2
  15. data/lib/acfs/resource/query_methods.rb +2 -2
  16. data/lib/acfs/runner.rb +15 -15
  17. data/lib/acfs/stub.rb +34 -29
  18. data/lib/acfs/version.rb +2 -2
  19. data/spec/acfs/adapter/typhoeus_spec.rb +1 -1
  20. data/spec/acfs/collection_spec.rb +66 -41
  21. data/spec/acfs/configuration_spec.rb +22 -12
  22. data/spec/acfs/global_spec.rb +9 -7
  23. data/spec/acfs/middleware/json_spec.rb +8 -8
  24. data/spec/acfs/middleware/{msgpack_spec.rb → message_pack_spec.rb} +6 -6
  25. data/spec/acfs/operation_spec.rb +3 -2
  26. data/spec/acfs/request/callbacks_spec.rb +19 -10
  27. data/spec/acfs/request_spec.rb +15 -19
  28. data/spec/acfs/resource/attributes/boolean_spec.rb +32 -32
  29. data/spec/acfs/resource/attributes/date_time_spec.rb +16 -8
  30. data/spec/acfs/resource/attributes/dict_spec.rb +15 -9
  31. data/spec/acfs/resource/attributes/float_spec.rb +20 -10
  32. data/spec/acfs/resource/attributes/integer_spec.rb +10 -5
  33. data/spec/acfs/resource/attributes/list_spec.rb +13 -8
  34. data/spec/acfs/resource/attributes/uuid_spec.rb +12 -6
  35. data/spec/acfs/resource/attributes_spec.rb +33 -32
  36. data/spec/acfs/resource/dirty_spec.rb +6 -3
  37. data/spec/acfs/resource/initialization_spec.rb +4 -5
  38. data/spec/acfs/resource/loadable_spec.rb +3 -1
  39. data/spec/acfs/resource/locatable_spec.rb +24 -18
  40. data/spec/acfs/resource/{persistance_spec.rb → persistence_spec.rb} +114 -82
  41. data/spec/acfs/resource/query_methods_spec.rb +143 -110
  42. data/spec/acfs/resource/validation_spec.rb +34 -27
  43. data/spec/acfs/response/formats_spec.rb +8 -8
  44. data/spec/acfs/response/status_spec.rb +16 -9
  45. data/spec/acfs/runner_spec.rb +10 -8
  46. data/spec/acfs/service/middleware_spec.rb +3 -3
  47. data/spec/acfs/service_spec.rb +5 -4
  48. data/spec/acfs/singleton_resource_spec.rb +2 -1
  49. data/spec/acfs/stub_spec.rb +57 -53
  50. data/spec/acfs_spec.rb +111 -93
  51. data/spec/spec_helper.rb +1 -1
  52. data/spec/support/response.rb +2 -2
  53. data/spec/support/service.rb +1 -1
  54. data/spec/support/shared/find_callbacks.rb +14 -10
  55. metadata +9 -8
@@ -3,56 +3,56 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Acfs::Resource::Attributes::Boolean do
6
- subject { Acfs::Resource::Attributes::Boolean.new }
6
+ subject(:type) { Acfs::Resource::Attributes::Boolean.new }
7
7
 
8
8
  describe '#cast' do
9
9
  it 'casts nil' do
10
- expect(subject.cast(nil)).to eq nil
10
+ expect(type.cast(nil)).to eq nil
11
11
  end
12
12
 
13
13
  it 'casts empty string to false' do
14
- expect(subject.cast('')).to eq nil
14
+ expect(type.cast('')).to eq nil
15
15
  end
16
16
 
17
17
  it 'casts blank string to false' do
18
- expect(subject.cast(" \t")).to eq nil
18
+ expect(type.cast(" \t")).to eq nil
19
19
  end
20
20
 
21
21
  it 'preserves boolean values' do
22
- expect(subject.cast(false)).to eq false
23
- expect(subject.cast(true)).to eq true
22
+ expect(type.cast(false)).to eq false
23
+ expect(type.cast(true)).to eq true
24
24
  end
25
25
 
26
26
  it 'casts falsy values to false' do
27
- expect(subject.cast(false)).to eq false
28
- expect(subject.cast(0)).to eq false
29
- expect(subject.cast('0')).to eq false
30
- expect(subject.cast('no')).to eq false
31
- expect(subject.cast('NO')).to eq false
32
- expect(subject.cast('off')).to eq false
33
- expect(subject.cast('OFF')).to eq false
34
- expect(subject.cast('false')).to eq false
35
- expect(subject.cast('FALSE')).to eq false
36
- expect(subject.cast('f')).to eq false
37
- expect(subject.cast('F')).to eq false
27
+ expect(type.cast(false)).to eq false
28
+ expect(type.cast(0)).to eq false
29
+ expect(type.cast('0')).to eq false
30
+ expect(type.cast('no')).to eq false
31
+ expect(type.cast('NO')).to eq false
32
+ expect(type.cast('off')).to eq false
33
+ expect(type.cast('OFF')).to eq false
34
+ expect(type.cast('false')).to eq false
35
+ expect(type.cast('FALSE')).to eq false
36
+ expect(type.cast('f')).to eq false
37
+ expect(type.cast('F')).to eq false
38
38
  end
39
39
 
40
40
  it 'casts any other value to true' do
41
- expect(subject.cast(true)).to eq true
42
- expect(subject.cast(1)).to eq true
43
- expect(subject.cast('1')).to eq true
44
- expect(subject.cast('yes')).to eq true
45
- expect(subject.cast('YES')).to eq true
46
- expect(subject.cast('on')).to eq true
47
- expect(subject.cast('ON')).to eq true
48
- expect(subject.cast('true')).to eq true
49
- expect(subject.cast('TRUE')).to eq true
50
- expect(subject.cast('t')).to eq true
51
- expect(subject.cast('T')).to eq true
52
-
53
- expect(subject.cast(2)).to eq true
54
- expect(subject.cast('wrong')).to eq true
55
- expect(subject.cast('random')).to eq true
41
+ expect(type.cast(true)).to eq true
42
+ expect(type.cast(1)).to eq true
43
+ expect(type.cast('1')).to eq true
44
+ expect(type.cast('yes')).to eq true
45
+ expect(type.cast('YES')).to eq true
46
+ expect(type.cast('on')).to eq true
47
+ expect(type.cast('ON')).to eq true
48
+ expect(type.cast('true')).to eq true
49
+ expect(type.cast('TRUE')).to eq true
50
+ expect(type.cast('t')).to eq true
51
+ expect(type.cast('T')).to eq true
52
+
53
+ expect(type.cast(2)).to eq true
54
+ expect(type.cast('wrong')).to eq true
55
+ expect(type.cast('random')).to eq true
56
56
  end
57
57
  end
58
58
  end
@@ -6,45 +6,53 @@ describe Acfs::Resource::Attributes::DateTime do
6
6
  let(:type) { Acfs::Resource::Attributes::DateTime.new }
7
7
 
8
8
  describe '#cast' do
9
- subject { -> { type.cast value } }
9
+ subject(:cast) { -> { type.cast value } }
10
10
 
11
11
  context 'with nil' do
12
12
  let(:value) { nil }
13
- it { expect(subject.call).to eq nil }
13
+
14
+ it { expect(cast.call).to eq nil }
14
15
  end
15
16
 
16
17
  context 'with empty string' do
17
18
  let(:value) { '' }
18
- it { expect(subject.call).to eq nil }
19
+
20
+ it { expect(cast.call).to eq nil }
19
21
  end
20
22
 
21
23
  context 'with blank string' do
22
24
  let(:value) { " \t" }
23
- it { expect(subject.call).to eq nil }
25
+
26
+ it { expect(cast.call).to eq nil }
24
27
  end
25
28
 
26
29
  context 'with DateTime' do
27
30
  let(:value) { DateTime.now }
28
- it { expect(subject.call).to eq value }
31
+
32
+ it { expect(cast.call).to eq value }
29
33
  end
30
34
 
31
35
  context 'with Time' do
32
36
  let(:value) { Time.now }
33
- it { expect(subject.call).to eq value.to_datetime }
37
+
38
+ it { expect(cast.call).to eq value.to_datetime }
34
39
  end
35
40
 
36
41
  context 'with Date' do
37
42
  let(:value) { Date.today }
38
- it { expect(subject.call).to eq value.to_datetime }
43
+
44
+ it { expect(cast.call).to eq value.to_datetime }
39
45
  end
40
46
 
41
47
  context 'with ISO8601' do
42
48
  let(:value) { DateTime.now.iso8601 }
43
- it { expect(subject.call.iso8601).to eq value }
49
+
50
+ it { expect(cast.call.iso8601).to eq value }
44
51
  end
45
52
 
46
53
  context 'with invalid string' do
47
54
  let(:value) { 'qwe123' }
55
+
48
56
  it { is_expected.to raise_error ArgumentError }
49
57
  end
50
58
  end
@@ -6,30 +6,35 @@ describe Acfs::Resource::Attributes::Dict do
6
6
  let(:type) { Acfs::Resource::Attributes::Dict.new }
7
7
 
8
8
  describe '#cast' do
9
- subject { -> { type.cast value } }
9
+ subject(:cast) { -> { type.cast value } }
10
10
 
11
11
  context 'with nil' do
12
12
  let(:value) { nil }
13
- it { expect(subject.call).to eq nil }
13
+
14
+ it { expect(cast.call).to eq nil }
14
15
  end
15
16
 
16
17
  context 'with blank string (I)' do
17
18
  let(:value) { '' }
18
- it { expect(subject.call).to eq({}) }
19
+
20
+ it { expect(cast.call).to eq({}) }
19
21
  end
20
22
 
21
23
  context 'with blank string (II)' do
22
24
  let(:value) { " \t" }
23
- it { expect(subject.call).to eq({}) }
25
+
26
+ it { expect(cast.call).to eq({}) }
24
27
  end
25
28
 
26
29
  context 'with hash' do
27
30
  let(:value) { {3 => true, abc: 4} }
28
- it { expect(subject.call).to eq value }
31
+
32
+ it { expect(cast.call).to eq value }
29
33
  end
30
34
 
31
35
  context 'with non hashable object' do
32
36
  let(:value) { Object.new }
37
+
33
38
  it { is_expected.to raise_error TypeError }
34
39
  end
35
40
 
@@ -42,7 +47,7 @@ describe Acfs::Resource::Attributes::Dict do
42
47
  end.new
43
48
  end
44
49
 
45
- it { expect(subject.call).to eq id: value.object_id }
50
+ it { expect(cast.call).to eq id: value.object_id }
46
51
  end
47
52
 
48
53
  context 'with hashable object (II)' do
@@ -54,7 +59,7 @@ describe Acfs::Resource::Attributes::Dict do
54
59
  end.new
55
60
  end
56
61
 
57
- it { expect(subject.call).to eq id: value.object_id }
62
+ it { expect(cast.call).to eq id: value.object_id }
58
63
  end
59
64
 
60
65
  context 'with serializable object' do
@@ -66,12 +71,13 @@ describe Acfs::Resource::Attributes::Dict do
66
71
  end.new
67
72
  end
68
73
 
69
- it { expect(subject.call).to eq id: value.object_id }
74
+ it { expect(cast.call).to eq id: value.object_id }
70
75
  end
71
76
 
72
77
  context 'with hash subclass object' do
73
78
  let(:value) { HashWithIndifferentAccess.new test: :foo }
74
- it { expect(subject.call).to be value }
79
+
80
+ it { expect(cast.call).to be value }
75
81
  end
76
82
  end
77
83
  end
@@ -6,55 +6,65 @@ describe Acfs::Resource::Attributes::Float do
6
6
  let(:type) { Acfs::Resource::Attributes::Float.new }
7
7
 
8
8
  describe '#cast' do
9
- subject { -> { type.cast value } }
9
+ subject(:cast) { -> { type.cast value } }
10
10
 
11
11
  context 'with nil' do
12
12
  let(:value) { nil }
13
- it { expect(subject.call).to eq nil }
13
+
14
+ it { expect(cast.call).to eq nil }
14
15
  end
15
16
 
16
17
  context 'with blank string (I)' do
17
18
  let(:value) { '' }
18
- it { expect(subject.call).to eq 0.0 }
19
+
20
+ it { expect(cast.call).to eq 0.0 }
19
21
  end
20
22
 
21
23
  context 'with blank string (II)' do
22
24
  let(:value) { " \t" }
23
- it { expect(subject.call).to eq 0.0 }
25
+
26
+ it { expect(cast.call).to eq 0.0 }
24
27
  end
25
28
 
26
29
  context 'with float' do
27
30
  let(:value) { 1.7 }
28
- it { expect(subject.call).to eq 1.7 }
31
+
32
+ it { expect(cast.call).to eq 1.7 }
29
33
  end
30
34
 
31
35
  context 'with Infinity' do
32
36
  let(:value) { 'Infinity' }
33
- it { expect(subject.call).to eq ::Float::INFINITY }
37
+
38
+ it { expect(cast.call).to eq ::Float::INFINITY }
34
39
  end
35
40
 
36
41
  context 'with -Infinity' do
37
42
  let(:value) { '-Infinity' }
38
- it { expect(subject.call).to eq(-::Float::INFINITY) }
43
+
44
+ it { expect(cast.call).to eq(-::Float::INFINITY) }
39
45
  end
40
46
 
41
47
  context 'with NaN' do
42
48
  let(:value) { 'NaN' }
43
- it { expect(subject.call).to be_nan }
49
+
50
+ it { expect(cast.call).to be_nan }
44
51
  end
45
52
 
46
53
  context 'with fixnum' do
47
54
  let(:value) { 1 }
48
- it { expect(subject.call).to eq 1.0 }
55
+
56
+ it { expect(cast.call).to eq 1.0 }
49
57
  end
50
58
 
51
59
  context 'with valid string' do
52
60
  let(:value) { '1.7' }
53
- it { expect(subject.call).to eq 1.7 }
61
+
62
+ it { expect(cast.call).to eq 1.7 }
54
63
  end
55
64
 
56
65
  context 'with invalid string (I)' do
57
66
  let(:value) { '1.7a' }
67
+
58
68
  it { is_expected.to raise_error ArgumentError }
59
69
  end
60
70
  end
@@ -6,30 +6,35 @@ describe Acfs::Resource::Attributes::Integer do
6
6
  let(:type) { Acfs::Resource::Attributes::Integer.new }
7
7
 
8
8
  describe '#cast' do
9
- subject { -> { type.cast value } }
9
+ subject(:cast) { -> { type.cast value } }
10
10
 
11
11
  context 'with nil' do
12
12
  let(:value) { nil }
13
- it { expect(subject.call).to eq nil }
13
+
14
+ it { expect(cast.call).to eq nil }
14
15
  end
15
16
 
16
17
  context 'with empty string' do
17
18
  let(:value) { '' }
18
- it { expect(subject.call).to eq 0 }
19
+
20
+ it { expect(cast.call).to eq 0 }
19
21
  end
20
22
 
21
23
  context 'with blank string' do
22
24
  let(:value) { " \t" }
23
- it { expect(subject.call).to eq 0 }
25
+
26
+ it { expect(cast.call).to eq 0 }
24
27
  end
25
28
 
26
29
  context 'with string' do
27
30
  let(:value) { '123' }
28
- it { expect(subject.call).to eq 123 }
31
+
32
+ it { expect(cast.call).to eq 123 }
29
33
  end
30
34
 
31
35
  context 'with invalid string' do
32
36
  let(:value) { '123a' }
37
+
33
38
  it { is_expected.to raise_error ArgumentError }
34
39
  end
35
40
  end
@@ -6,26 +6,30 @@ describe Acfs::Resource::Attributes::List do
6
6
  let(:type) { Acfs::Resource::Attributes::List.new }
7
7
 
8
8
  describe '#cast' do
9
- subject { -> { type.cast value } }
9
+ subject(:cast) { -> { type.cast value } }
10
10
 
11
11
  context 'with nil' do
12
12
  let(:value) { nil }
13
- it { expect(subject.call).to eq nil }
13
+
14
+ it { expect(cast.call).to eq nil }
14
15
  end
15
16
 
16
17
  context 'with blank string (I)' do
17
18
  let(:value) { '' }
18
- it { expect(subject.call).to eq [] }
19
+
20
+ it { expect(cast.call).to eq [] }
19
21
  end
20
22
 
21
23
  context 'with blank string (II)' do
22
24
  let(:value) { " \t" }
23
- it { expect(subject.call).to eq [] }
25
+
26
+ it { expect(cast.call).to eq [] }
24
27
  end
25
28
 
26
29
  context 'with array' do
27
30
  let(:value) { %w[abc cde efg] }
28
- it { expect(subject.call).to eq value }
31
+
32
+ it { expect(cast.call).to eq value }
29
33
  end
30
34
 
31
35
  context 'with convertable object (I)' do
@@ -37,7 +41,7 @@ describe Acfs::Resource::Attributes::List do
37
41
  end.new
38
42
  end
39
43
 
40
- it { expect(subject.call).to eq [1, 2, 3] }
44
+ it { expect(cast.call).to eq [1, 2, 3] }
41
45
  end
42
46
 
43
47
  context 'with convertable object (II)' do
@@ -49,12 +53,13 @@ describe Acfs::Resource::Attributes::List do
49
53
  end.new
50
54
  end
51
55
 
52
- it { expect(subject.call).to eq [1, 2, 3] }
56
+ it { expect(cast.call).to eq [1, 2, 3] }
53
57
  end
54
58
 
55
59
  context 'with non castable object' do
56
60
  let(:value) { Object.new }
57
- it { expect(subject.call).to eq [value] }
61
+
62
+ it { expect(cast.call).to eq [value] }
58
63
  end
59
64
  end
60
65
  end
@@ -6,36 +6,42 @@ describe Acfs::Resource::Attributes::UUID do
6
6
  let(:type) { Acfs::Resource::Attributes::UUID.new }
7
7
 
8
8
  describe '#cast' do
9
- subject { -> { type.cast(value) } }
9
+ subject(:cast) { -> { type.cast(value) } }
10
10
 
11
11
  context 'with nil' do
12
12
  let(:value) { nil }
13
- it { expect(subject.call).to eq nil }
13
+
14
+ it { expect(cast.call).to eq nil }
14
15
  end
15
16
 
16
17
  context 'with empty string' do
17
18
  let(:value) { '' }
18
- it { expect(subject.call).to eq nil }
19
+
20
+ it { expect(cast.call).to eq nil }
19
21
  end
20
22
 
21
23
  context 'with blank string' do
22
24
  let(:value) { " \t" }
23
- it { expect(subject.call).to eq nil }
25
+
26
+ it { expect(cast.call).to eq nil }
24
27
  end
25
28
 
26
29
  context 'with string UUID' do
27
30
  let(:value) { '450b7a40-94ad-11e3-baa8-0800200c9a66' }
28
- it { expect(subject.call).to be_a String }
29
- it { expect(subject.call).to eq value }
31
+
32
+ it { expect(cast.call).to be_a String }
33
+ it { expect(cast.call).to eq value }
30
34
  end
31
35
 
32
36
  context 'with invalid string' do
33
37
  let(:value) { 'invalid string' }
38
+
34
39
  it { is_expected.to raise_error TypeError, /invalid UUID/i }
35
40
  end
36
41
 
37
42
  context 'with invalid UUID' do
38
43
  let(:value) { 'xxxxxxxx-yyyy-11e3-baa8-0800200c9a66' }
44
+
39
45
  it { is_expected.to raise_error TypeError, /invalid UUID/i }
40
46
  end
41
47
  end
@@ -9,12 +9,12 @@ describe Acfs::Resource::Attributes do
9
9
  describe '#initialize' do
10
10
  before { model.attribute :name, :string, default: 'John' }
11
11
 
12
- it 'should have attribute list' do
12
+ it 'has attribute list' do
13
13
  expect(model.new.attributes).to include(:name)
14
14
  end
15
15
 
16
- it 'should set default attributes' do
17
- expect(model.new.name).to be == 'John'
16
+ it 'sets default attributes' do
17
+ expect(model.new.name).to eq 'John'
18
18
  end
19
19
 
20
20
  context 'with dynamic default value' do
@@ -23,8 +23,8 @@ describe Acfs::Resource::Attributes do
23
23
  model.attribute :mail, :string, default: -> { "#{name}@srv.tld" }
24
24
  end
25
25
 
26
- it 'should set dynamic default attributes' do
27
- expect(model.new.mail).to be == 'John@srv.tld'
26
+ it 'sets dynamic default attributes' do
27
+ expect(model.new.mail).to eq 'John@srv.tld'
28
28
  end
29
29
  end
30
30
  end
@@ -35,12 +35,14 @@ describe Acfs::Resource::Attributes do
35
35
  model.attribute :age, :integer, default: 25
36
36
  end
37
37
 
38
- it 'should return hash of all attributes' do
38
+ it 'returns hash of all attributes' do
39
39
  expect(model.new.attributes).to eq(name: 'John', age: 25)
40
40
  end
41
41
  end
42
42
 
43
43
  describe '#write_attributes' do
44
+ subject(:action) { -> { m.write_attributes(params, **opts) } }
45
+
44
46
  before do
45
47
  model.attribute :name, :string, default: 'John'
46
48
  model.attribute :age, :integer, default: 25
@@ -48,14 +50,13 @@ describe Acfs::Resource::Attributes do
48
50
  write_attribute :name, "The Great #{name}"
49
51
  end
50
52
  end
53
+
51
54
  let(:params) { {name: 'James'} }
52
55
  let(:opts) { {} }
53
56
  let(:m) { model.new }
54
- let(:action) { -> { m.write_attributes(params, **opts) } }
55
- subject { action }
56
57
 
57
- it 'should update attributes' do
58
- should change(m, :attributes)
58
+ it 'updates attributes' do
59
+ expect(action).to change(m, :attributes)
59
60
  .from(name: 'The Great John', age: 25)
60
61
  .to(name: 'The Great James', age: 25)
61
62
  end
@@ -63,17 +64,17 @@ describe Acfs::Resource::Attributes do
63
64
  context 'without non-hash params' do
64
65
  let(:params) { 'James' }
65
66
 
66
- it { should_not change(m, :attributes) }
67
- its(:call) { should eq false }
67
+ it { expect(action).not_to change(m, :attributes) }
68
+ it { expect(action.call).to eq false }
68
69
  end
69
70
 
70
71
  context 'with unknown attributes' do
71
72
  let(:params) { {name: 'James', born_at: 'today'} }
72
73
 
73
- it { should_not raise_error }
74
+ it { expect(action).not_to raise_error }
74
75
 
75
- it 'should update known attributes and store unknown' do
76
- should change(m, :attributes)
76
+ it 'updates known attributes and store unknown' do
77
+ expect(action).to change(m, :attributes)
77
78
  .from(name: 'The Great John', age: 25)
78
79
  .to(name: 'The Great James', age: 25, born_at: 'today')
79
80
  end
@@ -81,14 +82,14 @@ describe Acfs::Resource::Attributes do
81
82
  context 'with unknown: :raise option' do
82
83
  let(:opts) { {unknown: :raise} }
83
84
 
84
- it { should raise_error(ArgumentError, /unknown attribute/i) }
85
+ it { expect(action).to raise_error(ArgumentError, /unknown attribute/i) }
85
86
 
86
87
  it do
87
88
  expect do
88
- subject.call
89
+ action.call
89
90
  rescue StandardError
90
91
  true
91
- end.to_not change(m, :attributes)
92
+ end.not_to change(m, :attributes)
92
93
  end
93
94
  end
94
95
  end
@@ -97,15 +98,15 @@ describe Acfs::Resource::Attributes do
97
98
  describe '#_getter_' do
98
99
  before { model.attribute :name, :string, default: 'John' }
99
100
 
100
- it 'should return value' do
101
+ it 'returns value' do
101
102
  mo = model.new
102
103
  mo.name = 'Paul'
103
104
 
104
- expect(mo.name).to be == 'Paul'
105
+ expect(mo.name).to eq 'Paul'
105
106
  end
106
107
 
107
- it 'should return default value' do
108
- expect(model.new.name).to be == 'John'
108
+ it 'returns default value' do
109
+ expect(model.new.name).to eq 'John'
109
110
  end
110
111
  end
111
112
 
@@ -115,49 +116,49 @@ describe Acfs::Resource::Attributes do
115
116
  model.attribute :age, :integer, default: '25'
116
117
  end
117
118
 
118
- it 'should set value' do
119
+ it 'sets value' do
119
120
  o = model.new
120
121
  o.name = 'Paul'
121
122
 
122
- expect(o.name).to be == 'Paul'
123
+ expect(o.name).to eq 'Paul'
123
124
  end
124
125
 
125
- it 'should update attributes hash' do
126
+ it 'updates attributes hash' do
126
127
  o = model.new
127
128
  o.name = 'Johannes'
128
129
 
129
- expect(o.attributes['name']).to be == 'Johannes'
130
+ expect(o.attributes['name']).to eq 'Johannes'
130
131
  end
131
132
 
132
- it 'should cast values' do
133
+ it 'casts values' do
133
134
  o = model.new
134
135
  o.age = '28'
135
136
 
136
- expect(o.age).to be == 28
137
+ expect(o.age).to eq 28
137
138
  end
138
139
  end
139
140
 
140
141
  describe 'class' do
141
142
  describe '#attributes' do
142
- it 'should add an attribute to model attribute list' do
143
+ it 'adds an attribute to model attribute list' do
143
144
  model.send :attribute, :name, :string
144
145
 
145
146
  expect(model.attributes.symbolize_keys).to eq name: nil
146
147
  end
147
148
 
148
- it 'should accept a default value' do
149
+ it 'accepts a default value' do
149
150
  model.send :attribute, :name, :string, default: 'John'
150
151
 
151
152
  expect(model.attributes.symbolize_keys).to eq name: 'John'
152
153
  end
153
154
 
154
- it 'should accept a symbolic type' do
155
+ it 'accepts a symbolic type' do
155
156
  model.send :attribute, :age, :integer, default: '12'
156
157
 
157
158
  expect(model.attributes.symbolize_keys).to eq age: 12
158
159
  end
159
160
 
160
- it 'should accept a class type' do
161
+ it 'accepts a class type' do
161
162
  model.send :attribute, :age, Acfs::Resource::Attributes::Integer,
162
163
  default: '12'
163
164
 
@@ -4,6 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe Acfs::Resource::Dirty do
6
6
  let(:model) { MyUser.new }
7
+
7
8
  before do
8
9
  stub_request(:get, 'http://users.example.org/users/1')
9
10
  .to_return response id: 1, name: 'Anon', age: 12
@@ -23,21 +24,23 @@ describe Acfs::Resource::Dirty do
23
24
 
24
25
  context 'and saving' do
25
26
  before { user.save }
26
- it { expect(user).to_not be_changed }
27
+
28
+ it { expect(user).not_to be_changed }
27
29
  end
28
30
  end
29
31
 
30
32
  context 'after model load' do
31
33
  let(:user) { MyUser.find 1 }
34
+
32
35
  before { user && Acfs.run }
33
36
 
34
- it { expect(user).to_not be_changed }
37
+ it { expect(user).not_to be_changed }
35
38
  end
36
39
 
37
40
  context 'after model new without attrs' do
38
41
  let(:user) { MyUser.new }
39
42
 
40
- it { expect(user).to_not be_changed }
43
+ it { expect(user).not_to be_changed }
41
44
  end
42
45
 
43
46
  context 'after model new with attrs' do