-
-
Save lenny/2829549 to your computer and use it in GitHub Desktop.
BDD example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe ResubmissionsController do | |
... | |
# Probably not the most ideal start-off point | |
# since it is fairly rare un-RESTFul action, but.... | |
describe '#mark_as_processed' do | |
it 'responds with 404:not_found when no matching resubmissions were found' do | |
Resubmission.should_receive(:mark_as_processed).with('aa1001').and_return(0) | |
do_get('aa1001') | |
response.status.should == 404 | |
end | |
it 'responds with 200:ok when at least one resubmission was found' do | |
Resubmission.should_receive(:mark_as_processed).with('aa1001').and_return(1) | |
do_get('aa1001') | |
response.status.should == 200 | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe Resubmission do | |
.... | |
describe '.mark_as_processed(accode)' do | |
context 'with no unprocessed' do | |
it 'returns 0' | |
end | |
context 'with at least one unprocessed' do | |
it 'marks each unprocessed resubmission for manuscript as processed' | |
it 'returns number of resubmissions marked' | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe '.mark_as_processed(accode)' do | |
context 'with no unprocessed' do | |
it 'returns 0' do | |
# note :find_all_unprocessed_by_accode doesn't exist at this point, but is what I'd like | |
Resubmission.should_receive(:find_all_unprocessed_by_accode).with('AA1001').and_return([]) | |
Resubmission.mark_as_processed('AA1001').should == 0 | |
end | |
end | |
context 'with at least one unprocessed' do | |
it 'marks each unprocessed resubmission for manuscript as processed' | |
it 'returns number of resubmissions marked' | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe '.mark_as_processed(accode)' do | |
context 'with no unprocessed' do | |
it 'returns 0' do | |
Resubmission.should_receive(:find_all_unprocessed_by_accode).with('AA1001').and_return([]) | |
Resubmission.mark_as_processed('AA1001').should == 0 | |
end | |
end | |
context 'with at least one unprocessed' do | |
it 'marks each unprocessed resubmission for manuscript as processed' do | |
r1 = Resubmission.new | |
r2 = Resubmission.new | |
Resubmission.stub(:find_all_unprocessed_by_accode).and_return([r1, r2]) | |
r1.should_receive(:mark_as_processed) | |
r2.should_receive(:mark_as_processed) | |
Resubmission.mark_as_processed('AA1001') | |
end | |
it 'returns number of resubmissions marked' | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe '.mark_as_processed(accode)' do | |
context 'with no unprocessed' do | |
it 'returns 0' do | |
Resubmission.should_receive(:find_all_unprocessed_by_accode).with('AA1001').and_return([]) | |
Resubmission.mark_as_processed('AA1001').should == 0 | |
end | |
end | |
context 'with at least one unprocessed' do | |
it 'marks each unprocessed resubmission for manuscript as processed' do | |
r1 = Resubmission.new | |
r2 = Resubmission.new | |
Resubmission.stub(:find_all_unprocessed_by_accode).and_return([r1, r2]) | |
r1.should_receive(:mark_as_processed) | |
r2.should_receive(:mark_as_processed) | |
Resubmission.mark_as_processed('AA1001') | |
end | |
it 'returns number of resubmissions marked' do | |
resubmissions = [] | |
5.times { resubmissions << double(Resubmission).as_null_object } | |
Resubmission.stub(:find_all_unprocessed_by_accode).and_return(resubmissions) | |
Resubmission.mark_as_processed('AA1001').should == 5 | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Resubmission.mark_as_processed(accode) | |
with no unprocessed | |
returns 0 | |
with at least one unprocessed | |
marks each unprocessed resubmission for manuscript as processed | |
returns number of resubmissions marked |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment