Correct usage of `subject` in specs

This commit is contained in:
Robert Speicher 2015-04-16 16:25:25 -04:00
parent 2dace3679f
commit dee52393b5
6 changed files with 11 additions and 7 deletions

View File

@ -69,8 +69,9 @@ eos
end
it_behaves_like 'a mentionable' do
let(:subject) { commit }
let(:mauthor) { create :user, email: commit.author_email }
subject { commit }
let(:backref_text) { "commit #{subject.id}" }
let(:set_mentionable_text) { ->(txt){ subject.stub(safe_message: txt) } }

View File

@ -56,7 +56,8 @@ describe Issue do
end
it_behaves_like 'an editable mentionable' do
let(:subject) { create :issue, project: mproject }
subject { create(:issue, project: project) }
let(:backref_text) { "issue ##{subject.iid}" }
let(:set_mentionable_text) { ->(txt){ subject.description = txt } }
end

View File

@ -116,12 +116,13 @@ describe MergeRequest do
end
it_behaves_like 'an editable mentionable' do
let(:subject) { create :merge_request, source_project: mproject, target_project: mproject }
subject { create(:merge_request, source_project: project, target_project: project) }
let(:backref_text) { "merge request !#{subject.iid}" }
let(:set_mentionable_text) { ->(txt){ subject.title = txt } }
end
it_behaves_like 'a Taskable' do
let(:subject) { create :merge_request, :simple }
subject { create :merge_request, :simple }
end
end

View File

@ -629,8 +629,9 @@ describe Note do
end
it_behaves_like 'an editable mentionable' do
subject { create :note, noteable: issue, project: project }
let(:issue) { create :issue, project: project }
let(:subject) { create :note, noteable: issue, project: project }
let(:backref_text) { issue.gfm_reference }
let(:set_mentionable_text) { ->(txt) { subject.note = txt } }
end

View File

@ -1,6 +1,6 @@
# Specifications for behavior common to all Mentionable implementations.
# Requires a shared context containing:
# - let(:subject) { "the mentionable implementation" }
# - subject { "the mentionable implementation" }
# - let(:backref_text) { "the way that +subject+ should refer to itself in backreferences " }
# - let(:set_mentionable_text) { lambda { |txt| "block that assigns txt to the subject's mentionable_text" } }

View File

@ -1,7 +1,7 @@
# Specs for task state functionality for issues and merge requests.
#
# Requires a context containing:
# let(:subject) { Issue or MergeRequest }
# subject { Issue or MergeRequest }
shared_examples 'a Taskable' do
before do
subject.description = <<EOT.gsub(/ {6}/, '')