draftsman 0.3.1 → 0.3.2

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.
@@ -4,7 +4,7 @@ describe Parent do
4
4
  let(:parent) { Parent.new(:name => 'Marge') }
5
5
  let(:child) { Child.new(:name => 'Lisa', :parent => parent) }
6
6
 
7
- describe :publish! do
7
+ describe 'publish!' do
8
8
  context 'parent `create` draft with child `create` draft' do
9
9
  before do
10
10
  parent.draft_creation
@@ -13,24 +13,24 @@ describe Parent do
13
13
 
14
14
  subject { parent.draft.publish! }
15
15
 
16
- its 'parent should be published' do
16
+ it 'publishes the parent' do
17
17
  subject
18
- parent.reload.should be_published
18
+ expect(parent.reload.published?).to eql true
19
19
  end
20
20
 
21
- its 'parent should not be a draft' do
21
+ it "removes the parent's draft" do
22
22
  subject
23
- parent.reload.should_not be_draft
23
+ expect(parent.reload.draft?).to eql false
24
24
  end
25
25
 
26
- its 'child should be a draft' do
26
+ it 'keeps the child as a draft' do
27
27
  subject
28
- child.reload.should be_draft
28
+ expect(child.reload.draft?).to eql true
29
29
  end
30
30
 
31
- its 'child should not be published' do
31
+ it 'does not publish the child' do
32
32
  subject
33
- child.reload.should_not be_published
33
+ expect(child.reload.published?).to eql false
34
34
  end
35
35
 
36
36
  it 'destroys 1 draft' do
@@ -65,7 +65,7 @@ describe Parent do
65
65
  end
66
66
  end
67
67
 
68
- describe :revert! do
68
+ describe 'revert!' do
69
69
  context 'parent `create` draft with child `create` draft' do
70
70
  before do
71
71
  parent.draft_creation
@@ -100,9 +100,17 @@ describe Parent do
100
100
  parent.reload
101
101
  end
102
102
 
103
- it { should be_persisted }
104
- it { should_not be_draft }
105
- it { should_not be_trashed }
103
+ it 'is persisted to the database' do
104
+ expect(subject).to be_persisted
105
+ end
106
+
107
+ it 'is no longer a draft' do
108
+ expect(subject.draft?).to eql false
109
+ end
110
+
111
+ it 'is no longer trashed' do
112
+ expect(subject.trashed?).to eql false
113
+ end
106
114
 
107
115
  it "keeps the child's draft" do
108
116
  expect { subject }.to_not change(Draftsman::Draft.where(:item_type => 'Child'), :count)
@@ -112,24 +120,24 @@ describe Parent do
112
120
  expect { subject }.to change(Draftsman::Draft.where(:item_type => 'Parent'), :count).by(-1)
113
121
  end
114
122
 
115
- its 'child should remain a draft' do
123
+ it "keeps the child's draft" do
116
124
  subject
117
- child.should be_draft
125
+ expect(child.draft?).to eql true
118
126
  end
119
127
 
120
- its 'child should still be a `destroy` draft' do
128
+ it "keeps the child as a `destroy` draft" do
121
129
  subject
122
- child.draft.reload.should be_destroy
130
+ expect(child.draft.reload.destroy?).to eql true
123
131
  end
124
132
 
125
- its 'child should still be trashed' do
133
+ it 'keeps the child trashed' do
126
134
  subject
127
- child.should be_trashed
135
+ expect(child.trashed?).to eql true
128
136
  end
129
137
  end
130
138
  end
131
139
 
132
- describe :draft_publication_dependencies do
140
+ describe 'draft_publication_dependencies' do
133
141
  context 'parent `create` draft with child `create` draft' do
134
142
  before do
135
143
  parent.draft_creation
@@ -137,7 +145,10 @@ describe Parent do
137
145
  end
138
146
 
139
147
  subject { parent.draft }
140
- its(:draft_publication_dependencies) { should be_empty }
148
+
149
+ it 'does not have publication dependencies' do
150
+ expect(subject.draft_publication_dependencies).to be_empty
151
+ end
141
152
  end
142
153
 
143
154
  context 'parent `update` draft with child `create` draft' do
@@ -149,7 +160,10 @@ describe Parent do
149
160
  end
150
161
 
151
162
  subject { parent.draft }
152
- its(:draft_publication_dependencies) { should be_empty }
163
+
164
+ it 'does not have publication dependencies' do
165
+ expect(subject.draft_publication_dependencies).to be_empty
166
+ end
153
167
  end
154
168
 
155
169
  context 'parent `destroy` draft with child `destroy` draft' do
@@ -160,12 +174,18 @@ describe Parent do
160
174
  end
161
175
 
162
176
  subject { parent.draft }
163
- its(:draft_publication_dependencies) { should be_present }
164
- its(:draft_publication_dependencies) { should include child.draft }
177
+
178
+ it 'has publication dependencies' do
179
+ expect(subject.draft_publication_dependencies).to be_present
180
+ end
181
+
182
+ it "has the child's draft as a publication dependency" do
183
+ expect(subject.draft_publication_dependencies).to include child.draft
184
+ end
165
185
  end
166
186
  end
167
187
 
168
- describe :draft_reversion_dependencies do
188
+ describe 'draft_reversion_dependencies' do
169
189
  context 'parent `create` draft with child `create` draft' do
170
190
  before do
171
191
  parent.draft_creation
@@ -173,8 +193,14 @@ describe Parent do
173
193
  end
174
194
 
175
195
  subject { parent.draft }
176
- its(:draft_reversion_dependencies) { should be_present }
177
- its(:draft_reversion_dependencies) { should include child.draft }
196
+
197
+ it 'has reversion dependencies' do
198
+ expect(subject.draft_reversion_dependencies).to be_present
199
+ end
200
+
201
+ it "has the child's draft as a reversion dependency" do
202
+ expect(subject.draft_reversion_dependencies).to include child.draft
203
+ end
178
204
  end
179
205
 
180
206
  context 'parent `destroy` draft with child `destroy` draft' do
@@ -185,7 +211,10 @@ describe Parent do
185
211
  end
186
212
 
187
213
  subject { parent.draft }
188
- its(:draft_reversion_dependencies) { should be_empty }
214
+
215
+ it 'does not have reversion dependencies' do
216
+ expect(subject.draft_reversion_dependencies).to be_empty
217
+ end
189
218
  end
190
219
  end
191
220
  end
@@ -2,24 +2,47 @@ require 'spec_helper'
2
2
 
3
3
  describe Skipper do
4
4
  let(:skipper) { Skipper.new :name => 'Bob', :skip_me => 'Skipped 1' }
5
- it { should be_draftable }
6
5
 
7
- describe :draft_creation do
6
+ it 'is draftable' do
7
+ expect(subject.class.draftable?).to eql true
8
+ end
9
+
10
+ describe 'draft_creation' do
8
11
  subject do
9
12
  skipper.draft_creation
10
13
  skipper.reload
11
14
  end
12
15
 
13
- it { should be_persisted }
14
- it { should be_draft }
15
- its(:draft_id) { should be_present }
16
- its(:draft) { should be_present }
17
- its(:draft) { should be_create }
18
- its(:name) { should eql 'Bob' }
19
- its(:skip_me) { should eql 'Skipped 1' }
16
+ it 'is persisted' do
17
+ expect(subject).to be_persisted
18
+ end
19
+
20
+ it 'is a draft' do
21
+ expect(subject.draft?).to eql true
22
+ end
23
+
24
+ it 'has a `draft_id`' do
25
+ expect(subject.draft_id).to be_present
26
+ end
27
+
28
+ it 'has a draft' do
29
+ expect(subject.draft).to be_present
30
+ end
31
+
32
+ it 'has a `create` draft' do
33
+ expect(subject.draft.create?).to eql true
34
+ end
35
+
36
+ it 'has a `name`' do
37
+ expect(subject.name).to eql 'Bob'
38
+ end
39
+
40
+ it 'has a value for `skip_me`' do
41
+ expect(subject.skip_me).to eql 'Skipped 1'
42
+ end
20
43
  end
21
44
 
22
- describe :draft_update do
45
+ describe 'draft_update' do
23
46
  subject do
24
47
  skipper.draft_update
25
48
  skipper.reload
@@ -32,13 +55,33 @@ describe Skipper do
32
55
  skipper.skip_me = 'Skipped 2'
33
56
  end
34
57
 
35
- it { should be_persisted }
36
- it { should be_draft }
37
- its(:draft_id) { should be_present }
38
- its(:draft) { should be_present }
39
- its(:draft) { should be_update }
40
- its(:name) { should eql 'Bob' }
41
- its(:skip_me) { should eql 'Skipped 2' }
58
+ it 'is persisted' do
59
+ expect(subject).to be_persisted
60
+ end
61
+
62
+ it 'is a draft' do
63
+ expect(subject.draft?).to eql true
64
+ end
65
+
66
+ it 'has a `draft_id`' do
67
+ expect(subject.draft_id).to be_present
68
+ end
69
+
70
+ it 'has a `draft`' do
71
+ expect(subject.draft).to be_present
72
+ end
73
+
74
+ it 'identifies as an `update` draft' do
75
+ expect(subject.draft.update?).to eql true
76
+ end
77
+
78
+ it 'has the original name' do
79
+ expect(subject.name).to eql 'Bob'
80
+ end
81
+
82
+ it 'has the updated skipped attribute' do
83
+ expect(subject.skip_me).to eql 'Skipped 2'
84
+ end
42
85
 
43
86
  it 'creates a new draft' do
44
87
  expect { subject }.to change(Draftsman::Draft, :count).by(1)
@@ -56,11 +99,25 @@ describe Skipper do
56
99
  skipper.skip_me = 'Skipped 2'
57
100
  end
58
101
 
59
- it { should_not be_draft }
60
- its(:draft_id) { should be_nil }
61
- its(:draft) { should be_nil }
62
- its(:name) { should eql 'Bob' }
63
- its(:skip_me) { should eql 'Skipped 2' }
102
+ it 'is no longer a draft' do
103
+ expect(subject.draft?).to eql false
104
+ end
105
+
106
+ it 'no longer has a `draft_id`' do
107
+ expect(subject.draft_id).to be_nil
108
+ end
109
+
110
+ it 'no longer has a `draft`' do
111
+ expect(subject.draft).to be_nil
112
+ end
113
+
114
+ it 'has its original `name`' do
115
+ expect(subject.name).to eql 'Bob'
116
+ end
117
+
118
+ it "retains the updated skipped attribute's value" do
119
+ expect(subject.skip_me).to eql 'Skipped 2'
120
+ end
64
121
 
65
122
  it 'destroys the draft' do
66
123
  expect { subject }.to change(Draftsman::Draft.where(:id => skipper.draft_id), :count).by(-1)
@@ -76,31 +133,71 @@ describe Skipper do
76
133
  skipper.skip_me = 'Skipped 2'
77
134
  end
78
135
 
79
- it { should be_persisted }
80
- it { should be_draft }
81
- its(:draft_id) { should be_present }
82
- its(:draft) { should be_present }
83
- its(:draft) { should be_create }
84
- its(:name) { should eql 'Sam' }
85
- its(:skip_me) { should eql 'Skipped 2' }
136
+ it 'is persisted' do
137
+ expect(subject).to be_persisted
138
+ end
139
+
140
+ it 'is a draft' do
141
+ expect(subject.draft?).to eql true
142
+ end
143
+
144
+ it 'has a `draft_id`' do
145
+ expect(subject.draft_id).to be_present
146
+ end
147
+
148
+ it 'has a `draft`' do
149
+ expect(subject.draft).to be_present
150
+ end
151
+
152
+ it 'has a `create` draft' do
153
+ expect(subject.draft.create?).to eql true
154
+ end
155
+
156
+ it 'has the updated `name`' do
157
+ expect(subject.name).to eql 'Sam'
158
+ end
159
+
160
+ it "retains the updated skipped attribute's value" do
161
+ expect(subject.skip_me).to eql 'Skipped 2'
162
+ end
86
163
 
87
164
  it 'updates the existing draft' do
88
165
  expect { subject }.to_not change(Draftsman::Draft.where(:id => skipper.draft_id), :count)
89
166
  end
90
167
 
91
- its "draft's `name` is updated" do
92
- subject.draft.reify.name.should eql 'Sam'
168
+ it "updates the draft's `name`" do
169
+ expect(subject.draft.reify.name).to eql 'Sam'
93
170
  end
94
171
  end
95
172
 
96
173
  context 'with no changes' do
97
- it { should be_persisted }
98
- it { should be_draft }
99
- its(:draft_id) { should be_present }
100
- its(:draft) { should be_present }
101
- its(:draft) { should be_create }
102
- its(:name) { should eql 'Bob' }
103
- its(:skip_me) { should eql 'Skipped 1' }
174
+ it 'is persisted' do
175
+ expect(subject).to be_persisted
176
+ end
177
+
178
+ it 'is a draft' do
179
+ expect(subject.draft?).to eql true
180
+ end
181
+
182
+ it 'has a `draft_id`' do
183
+ expect(subject.draft_id).to be_present
184
+ end
185
+
186
+ it 'has a `draft`' do
187
+ expect(subject.draft).to be_present
188
+ end
189
+
190
+ it 'has a `create` draft' do
191
+ expect(subject.draft.create?).to eql true
192
+ end
193
+
194
+ it 'has the original `name`' do
195
+ expect(subject.name).to eql 'Bob'
196
+ end
197
+
198
+ it "has the original skipped attribute's value" do
199
+ expect(subject.skip_me).to eql 'Skipped 1'
200
+ end
104
201
 
105
202
  it "doesn't change the number of drafts" do
106
203
  expect { subject }.to_not change(Draftsman::Draft.where(:id => skipper.draft_id), :count)
@@ -120,45 +217,86 @@ describe Skipper do
120
217
 
121
218
  context 'with changes' do
122
219
  before { skipper.name = 'Steve' }
123
- it { should be_persisted }
124
- it { should be_draft }
125
- its(:draft_id) { should be_present }
126
- its(:draft) { should be_present }
127
- its(:draft) { should be_update }
128
- its(:name) { should eql 'Bob' }
129
- its(:skip_me) { should eql 'Skipped 2' }
220
+
221
+ it 'is persisted' do
222
+ expect(subject).to be_persisted
223
+ end
224
+
225
+ it 'is a draft' do
226
+ expect(subject.draft?).to eql true
227
+ end
228
+
229
+ it 'has a `draft_id`' do
230
+ expect(subject.draft_id).to be_present
231
+ end
232
+
233
+ it 'has a `draft`' do
234
+ expect(subject.draft).to be_present
235
+ end
236
+
237
+ it 'has an `update` draft' do
238
+ expect(subject.draft.update?).to eql true
239
+ end
240
+
241
+ it 'has the original `name`' do
242
+ expect(subject.name).to eql 'Bob'
243
+ end
244
+
245
+ it "has the updated skipped attribute's value" do
246
+ expect(subject.skip_me).to eql 'Skipped 2'
247
+ end
130
248
 
131
249
  it 'updates the existing draft' do
132
250
  expect { subject }.to_not change(Draftsman::Draft.where(:id => skipper.draft_id), :count)
133
251
  end
134
252
 
135
- its "draft's `name` is updated" do
136
- subject.draft.reify.name.should eql 'Steve'
253
+ it "updates the draft's `name`" do
254
+ expect(subject.draft.reify.name).to eql 'Steve'
137
255
  end
138
256
  end
139
257
 
140
258
  context 'with no changes' do
141
- it { should be_persisted }
142
- it { should be_draft }
143
- its(:draft_id) { should be_present }
144
- its(:draft) { should be_present }
145
- its(:draft) { should be_update }
146
- its(:name) { should eql 'Bob' }
147
- its(:skip_me) { should eql 'Skipped 2' }
259
+ it 'is persisted' do
260
+ expect(subject).to be_persisted
261
+ end
262
+
263
+ it 'is a draft' do
264
+ expect(subject.draft?).to eql true
265
+ end
266
+
267
+ it 'has a `draft_id`' do
268
+ expect(subject.draft_id).to be_present
269
+ end
270
+
271
+ it 'has a `draft`' do
272
+ expect(subject.draft).to be_present
273
+ end
274
+
275
+ it 'has an `update` draft' do
276
+ expect(subject.draft.update?).to eql true
277
+ end
278
+
279
+ it 'has the original `name`' do
280
+ expect(subject.name).to eql 'Bob'
281
+ end
282
+
283
+ it "has the updated skipped attributes' value" do
284
+ expect(subject.skip_me).to eql 'Skipped 2'
285
+ end
148
286
 
149
287
  it "doesn't change the number of drafts" do
150
288
  expect { subject }.to_not change(Draftsman::Draft.where(:id => skipper.draft_id), :count)
151
289
  end
152
290
 
153
- its "draft's `name` is not updated" do
154
- subject.draft.reify.name.should eql 'Sam'
291
+ it "does not update the draft's `name`" do
292
+ expect(subject.draft.reify.name).to eql 'Sam'
155
293
  end
156
294
  end
157
295
  end
158
296
  end
159
297
 
160
298
  # Not applicable to this customization
161
- describe :draft_destroy do
299
+ describe 'draft_destroy' do
162
300
  end
163
301
 
164
302
  # Not applicable to this customization