restpack_serializer 0.6.7 → 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,7 @@ describe RestPack::Serializer::SideLoading do
12
12
  message = ":wrong is not a valid include for MyApp::Song"
13
13
 
14
14
  expect do
15
- MyApp::SongSerializer.side_loads([MyApp::Song.first], RestPack::Serializer::Options.new(MyApp::SongSerializer, { "include" => "wrong" }))
15
+ MyApp::SongSerializer.side_loads([MyApp::Song.first], RestPack::Serializer::Options.new(MyApp::SongSerializer, "include" => "wrong"))
16
16
  end.to raise_error(exception, message)
17
17
  end
18
18
  end
@@ -24,7 +24,7 @@ describe RestPack::Serializer::SideLoading do
24
24
  message = ":payments is not a valid include for MyApp::Artist"
25
25
 
26
26
  expect do
27
- MyApp::ArtistSerializer.side_loads([payment.artist], RestPack::Serializer::Options.new(MyApp::ArtistSerializer, { "include" => "payments" }))
27
+ MyApp::ArtistSerializer.side_loads([payment.artist], RestPack::Serializer::Options.new(MyApp::ArtistSerializer, "include" => "payments"))
28
28
  end.to raise_error(exception, message)
29
29
  end
30
30
  end
@@ -36,7 +36,7 @@ describe RestPack::Serializer::SideLoading do
36
36
  attributes :a, :b, :c
37
37
  end
38
38
  it "defaults to empty array" do
39
- CustomSerializer.can_includes.should == []
39
+ expect(CustomSerializer.can_includes).to eq([])
40
40
  end
41
41
 
42
42
  it "allows includes to be specified" do
@@ -45,33 +45,35 @@ describe RestPack::Serializer::SideLoading do
45
45
  can_include :model2, :model3
46
46
  end
47
47
 
48
- CustomSerializer.can_includes.should == [:model1, :model2, :model3]
48
+ expect(CustomSerializer.can_includes).to eq([:model1, :model2, :model3])
49
49
  end
50
50
  end
51
51
 
52
52
  describe "#links" do
53
- MyApp::AlbumSerializer.links.should == {
54
- "albums.artist" => {
55
- :href => "/artists/{albums.artist}",
56
- :type => :artists
57
- },
58
- "albums.songs" => {
59
- :href => "/songs?album_id={albums.id}",
60
- :type => :songs
61
- }
62
- }
53
+ it do
54
+ expect(MyApp::AlbumSerializer.links).to eq(
55
+ "albums.artist" => {
56
+ href: "/artists/{albums.artist}",
57
+ type: :artists
58
+ },
59
+ "albums.songs" => {
60
+ href: "/songs?album_id={albums.id}",
61
+ type: :songs
62
+ }
63
+ )
64
+ end
63
65
 
64
66
  it "applies custom RestPack::Serializer.config.href_prefix" do
65
67
  original = RestPack::Serializer.config.href_prefix
66
68
  RestPack::Serializer.config.href_prefix = "/api/v1"
67
- MyApp::AlbumSerializer.links["albums.artist"][:href].should == "/api/v1/artists/{albums.artist}"
69
+ expect(MyApp::AlbumSerializer.links["albums.artist"][:href]).to eq("/api/v1/artists/{albums.artist}")
68
70
  RestPack::Serializer.config.href_prefix = original
69
71
  end
70
72
 
71
73
  it "applies custom serializer href_prefix" do
72
74
  original = RestPack::Serializer.config.href_prefix
73
75
  MyApp::AlbumSerializer.href_prefix = '/api/v2'
74
- MyApp::AlbumSerializer.links["albums.artist"][:href].should == "/api/v2/artists/{albums.artist}"
76
+ expect(MyApp::AlbumSerializer.links["albums.artist"][:href]).to eq("/api/v2/artists/{albums.artist}")
75
77
  MyApp::AlbumSerializer.href_prefix = original
76
78
  end
77
79
  end
@@ -79,17 +81,17 @@ describe RestPack::Serializer::SideLoading do
79
81
  describe "#filterable_by" do
80
82
  context "a model with no :belongs_to relations" do
81
83
  it "is filterable by :id only" do
82
- MyApp::ArtistSerializer.filterable_by.should == [:id]
84
+ expect(MyApp::ArtistSerializer.filterable_by).to eq([:id])
83
85
  end
84
86
  end
85
87
  context "a model with a single :belongs_to relations" do
86
88
  it "is filterable by primary key and foreign keys" do
87
- MyApp::AlbumSerializer.filterable_by.should =~ [:id, :artist_id, :year]
89
+ expect(MyApp::AlbumSerializer.filterable_by).to eq([:id, :artist_id, :year])
88
90
  end
89
91
  end
90
92
  context "a model with multiple :belongs_to relations" do
91
93
  it "is filterable by primary key and foreign keys" do
92
- MyApp::SongSerializer.filterable_by.should =~ [:id, :artist_id, :album_id, :title]
94
+ expect(MyApp::SongSerializer.filterable_by).to eq([:id, :artist_id, :album_id, :title])
93
95
  end
94
96
  end
95
97
  end
@@ -12,15 +12,15 @@ describe RestPack::Serializer::Single do
12
12
  let(:context) { { } }
13
13
 
14
14
  it "returns a resource by id" do
15
- resource[:id].should == @song.id.to_s
16
- resource[:title].should == @song.title
15
+ expect(resource[:id]).to eq(@song.id.to_s)
16
+ expect(resource[:title]).to eq(@song.title)
17
17
  end
18
18
 
19
19
  context "with context" do
20
20
  let(:context) { { reverse_title?: true } }
21
21
 
22
22
  it "returns reversed titles" do
23
- resource[:title].should == @song.title.reverse
23
+ expect(resource[:title]).to eq(@song.title.reverse)
24
24
  end
25
25
  end
26
26
 
@@ -28,7 +28,7 @@ describe RestPack::Serializer::Single do
28
28
  let(:params) { { id: @song.id + 100 } }
29
29
 
30
30
  it "returns nil" do
31
- resource.should == nil
31
+ expect(resource).to eq(nil)
32
32
  end
33
33
  end
34
34
  end
@@ -9,6 +9,6 @@ describe RestPack::Serializer::Sortable do
9
9
  end
10
10
 
11
11
  it 'captures the specified sorting attributes' do
12
- CustomSerializer.serializable_sorting_attributes.should == [:a, :c]
12
+ expect(CustomSerializer.serializable_sorting_attributes).to eq([:a, :c])
13
13
  end
14
14
  end
@@ -10,6 +10,7 @@ FactoryGirl.find_definitions
10
10
 
11
11
  RSpec.configure do |config|
12
12
  config.include FactoryGirl::Syntax::Methods
13
+ config.raise_errors_for_deprecations!
13
14
 
14
15
  config.before(:suite) do
15
16
  DatabaseCleaner.clean_with(:truncation)
@@ -1,14 +1,12 @@
1
1
  require 'factory_girl'
2
2
 
3
3
  FactoryGirl.define do
4
- factory :artist, :class => MyApp::Artist do
5
- sequence(:name) {|n| "Artist ##{n}" }
6
- sequence(:website) {|n| "http://website#{n}.com/" }
4
+ factory :artist, class: MyApp::Artist do
5
+ sequence(:name) { |n| "Artist ##{n}" }
6
+ sequence(:website) { |n| "http://website#{n}.com/" }
7
7
 
8
8
  factory :artist_with_albums do
9
- ignore do
10
- album_count 3
11
- end
9
+ transient { album_count 3 }
12
10
 
13
11
  after(:create) do |artist, evaluator|
14
12
  create_list(:album_with_songs, evaluator.album_count, artist: artist)
@@ -16,33 +14,29 @@ FactoryGirl.define do
16
14
  end
17
15
 
18
16
  factory :artist_with_fans do
19
- ignore do
20
- fans_count 3
21
- end
17
+ transient { fans_count 3 }
18
+
22
19
  after(:create) do |artist, evaluator|
23
20
  create_list(:payment, evaluator.fans_count, artist: artist)
24
21
  end
25
22
  end
26
23
 
27
24
  factory :artist_with_stalkers do
28
- ignore do
29
- stalker_count 2
30
- end
25
+ transient { stalker_count 2 }
26
+
31
27
  after(:create) do |artist, evaluator|
32
- create_list(:stalker, evaluator.stalker_count, artists: [ artist ])
28
+ create_list(:stalker, evaluator.stalker_count, artists: [artist])
33
29
  end
34
30
  end
35
31
  end
36
32
 
37
- factory :album, :class => MyApp::Album do
38
- sequence(:title) {|n| "Album ##{n}" }
39
- sequence(:year) {|n| 1960 + n }
33
+ factory :album, class: MyApp::Album do
34
+ sequence(:title) { |n| "Album ##{n}" }
35
+ sequence(:year) { |n| 1960 + n }
40
36
  artist
41
37
 
42
38
  factory :album_with_songs do
43
- ignore do
44
- song_count 10
45
- end
39
+ transient { song_count 10 }
46
40
 
47
41
  after(:create) do |album, evaluator|
48
42
  create_list(:song, evaluator.song_count, album: album, artist: album.artist)
@@ -50,23 +44,23 @@ FactoryGirl.define do
50
44
  end
51
45
  end
52
46
 
53
- factory :song, :class => MyApp::Song do
54
- sequence(:title) {|n| "Song ##{n}" }
47
+ factory :song, class: MyApp::Song do
48
+ sequence(:title) { |n| "Song ##{n}" }
55
49
  artist
56
50
  album
57
51
  end
58
52
 
59
- factory :payment, :class => MyApp::Payment do
53
+ factory :payment, class: MyApp::Payment do
60
54
  amount 999
61
55
  artist
62
56
  fan
63
57
  end
64
58
 
65
- factory :fan, :class => MyApp::Fan do
66
- sequence(:name) {|n| "Fan ##{n}"}
59
+ factory :fan, class: MyApp::Fan do
60
+ sequence(:name) { |n| "Fan ##{n}" }
67
61
  end
68
62
 
69
- factory :stalker, :class => MyApp::Stalker do
70
- sequence(:name) {|n| "Stalker ##{n}"}
63
+ factory :stalker, class: MyApp::Stalker do
64
+ sequence(:name) { |n| "Stalker ##{n}" }
71
65
  end
72
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restpack_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.7
4
+ version: 0.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Joyce
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-31 00:00:00.000000000 Z
11
+ date: 2016-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 4.0.3
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5.0'
22
+ version: '6.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 4.0.3
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5.0'
32
+ version: '6.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activerecord
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: 4.0.3
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '5.0'
42
+ version: '6.0'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,21 +49,35 @@ dependencies:
49
49
  version: 4.0.3
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '5.0'
52
+ version: '6.0'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: kaminari
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: 0.16.1
59
+ version: 0.17.0
60
60
  type: :runtime
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: 0.16.1
66
+ version: 0.17.0
67
+ - !ruby/object:Gem::Dependency
68
+ name: kaminari-mongoid
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '0.1'
74
+ type: :runtime
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '0.1'
67
81
  - !ruby/object:Gem::Dependency
68
82
  name: restpack_gem
69
83
  requirement: !ruby/object:Gem::Requirement
@@ -84,70 +98,70 @@ dependencies:
84
98
  requirements:
85
99
  - - "~>"
86
100
  - !ruby/object:Gem::Version
87
- version: 11.1.2
101
+ version: '11.3'
88
102
  type: :development
89
103
  prerelease: false
90
104
  version_requirements: !ruby/object:Gem::Requirement
91
105
  requirements:
92
106
  - - "~>"
93
107
  - !ruby/object:Gem::Version
94
- version: 11.1.2
108
+ version: '11.3'
95
109
  - !ruby/object:Gem::Dependency
96
110
  name: guard-rspec
97
111
  requirement: !ruby/object:Gem::Requirement
98
112
  requirements:
99
113
  - - "~>"
100
114
  - !ruby/object:Gem::Version
101
- version: 4.6.4
115
+ version: '4.7'
102
116
  type: :development
103
117
  prerelease: false
104
118
  version_requirements: !ruby/object:Gem::Requirement
105
119
  requirements:
106
120
  - - "~>"
107
121
  - !ruby/object:Gem::Version
108
- version: 4.6.4
122
+ version: '4.7'
109
123
  - !ruby/object:Gem::Dependency
110
124
  name: factory_girl
111
125
  requirement: !ruby/object:Gem::Requirement
112
126
  requirements:
113
127
  - - "~>"
114
128
  - !ruby/object:Gem::Version
115
- version: 4.7.0
129
+ version: '4.7'
116
130
  type: :development
117
131
  prerelease: false
118
132
  version_requirements: !ruby/object:Gem::Requirement
119
133
  requirements:
120
134
  - - "~>"
121
135
  - !ruby/object:Gem::Version
122
- version: 4.7.0
136
+ version: '4.7'
123
137
  - !ruby/object:Gem::Dependency
124
138
  name: sqlite3
125
139
  requirement: !ruby/object:Gem::Requirement
126
140
  requirements:
127
141
  - - "~>"
128
142
  - !ruby/object:Gem::Version
129
- version: 1.3.7
143
+ version: '1.3'
130
144
  type: :development
131
145
  prerelease: false
132
146
  version_requirements: !ruby/object:Gem::Requirement
133
147
  requirements:
134
148
  - - "~>"
135
149
  - !ruby/object:Gem::Version
136
- version: 1.3.7
150
+ version: '1.3'
137
151
  - !ruby/object:Gem::Dependency
138
152
  name: database_cleaner
139
153
  requirement: !ruby/object:Gem::Requirement
140
154
  requirements:
141
155
  - - "~>"
142
156
  - !ruby/object:Gem::Version
143
- version: 1.5.3
157
+ version: '1.5'
144
158
  type: :development
145
159
  prerelease: false
146
160
  version_requirements: !ruby/object:Gem::Requirement
147
161
  requirements:
148
162
  - - "~>"
149
163
  - !ruby/object:Gem::Version
150
- version: 1.5.3
164
+ version: '1.5'
151
165
  - !ruby/object:Gem::Dependency
152
166
  name: rspec
153
167
  requirement: !ruby/object:Gem::Requirement
@@ -177,19 +191,19 @@ dependencies:
177
191
  - !ruby/object:Gem::Version
178
192
  version: '0'
179
193
  - !ruby/object:Gem::Dependency
180
- name: protected_attributes
194
+ name: protected_attributes_continued
181
195
  requirement: !ruby/object:Gem::Requirement
182
196
  requirements:
183
197
  - - "~>"
184
198
  - !ruby/object:Gem::Version
185
- version: 1.1.3
199
+ version: '1.2'
186
200
  type: :development
187
201
  prerelease: false
188
202
  version_requirements: !ruby/object:Gem::Requirement
189
203
  requirements:
190
204
  - - "~>"
191
205
  - !ruby/object:Gem::Version
192
- version: 1.1.3
206
+ version: '1.2'
193
207
  description: Model serialization, paging, side-loading and filtering
194
208
  email:
195
209
  - gavinjoyce@gmail.com
@@ -285,4 +299,3 @@ test_files:
285
299
  - spec/serializable/sortable_spec.rb
286
300
  - spec/spec_helper.rb
287
301
  - spec/support/factory.rb
288
- has_rdoc: