Skip to content

Commit 7b176fa

Browse files
authored
Refer to the method call under test with subject
1 parent cd1144e commit 7b176fa

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

README.adoc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ end
323323
describe '#attributes' do
324324
context 'when display name is present' do
325325
before do
326-
subject.display_name = 'something'
326+
article.display_name = 'something'
327327
end
328328
329329
it 'includes the display name' do
@@ -334,18 +334,19 @@ end
334334
335335
# good
336336
describe '#attributes' do
337-
subject { FactoryBot.create(:article) }
337+
let(:article) { FactoryBot.create(:article) }
338+
subject { article.attributes }
338339
339340
specify do
340-
expect(subject.attributes).to include subject.display_name
341-
expect(subject.attributes).to include subject.created_at
341+
expect(subject).to include article.display_name
342+
expect(subject).to include article.created_at
342343
end
343344
end
344345
345346
describe '#attributes' do
346347
context 'when display name is present' do
347348
before do
348-
subject.display_name = 'something'
349+
article.display_name = 'something'
349350
end
350351
351352
it 'includes the display name' do
@@ -355,7 +356,7 @@ describe '#attributes' do
355356
356357
context 'when display name is not present' do
357358
before do
358-
subject.display_name = nil
359+
article.display_name = nil
359360
end
360361
361362
it 'does not include the display name' do
@@ -914,13 +915,13 @@ Always use https://github.com/travisjeffery/timecop[Timecop] instead of stubbing
914915
it 'offsets the time 2 days into the future' do
915916
current_time = Time.now
916917
allow(Time).to receive(:now).and_return(current_time)
917-
expect(subject.get_offset_time).to eq(current_time + 2.days)
918+
expect(subject).to eq(current_time + 2.days)
918919
end
919920
920921
# good
921922
it 'offsets the time 2 days into the future' do
922923
Timecop.freeze(Time.now) do
923-
expect(subject.get_offset_time).to eq 2.days.from_now
924+
expect(subject).to eq 2.days.from_now
924925
end
925926
end
926927
----

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy