Skip to content

Instantly share code, notes, and snippets.

@svs
Created October 5, 2012 06:23
Show Gist options
  • Save svs/3838391 to your computer and use it in GitHub Desktop.
Save svs/3838391 to your computer and use it in GitHub Desktop.
Painful RSpec
ReceiptsController
unauthenticated user
should not be able to access index page
POST create
does not create a new Receipt
customer user
GET index
assigns all users documents as @documents
searches properly
gets the right document
GET show
assigns the requested document as @document
GET new
assigns a new document as @document
GET edit
assigns the requested document as @document
POST create
with valid params
creates a new Receipt
assigns a newly created document as @document
redirects to the show page of the created document
with attached scan
assigns the new receipt the scan
marks the scan as attached
also does vice versa
puts the receipt in state editing
with invalid params
assigns a newly created but unsaved document as @document
re-renders the 'new' template
hacking attempt
does not create a new Receipt for other user
PUT update
with valid params
updates the requested document
assigns the requested document as @document
logs a state transition
redirects to the document
DELETE destroy
marks the receipt as deleted
logs to the audit trail
tagger user
GET index
redirects to /
GET
show
assigns the requested document as @document if it is scanned
assigns the requested document as @document if it is incomplete
assigns the requested document as @document if it is checker rejected
does not assign the requested document as @document if it is complete
does not assign the requested document as @document if it is checker_accepted
does not assign the requested document as @document if it is user_rejected
does not assign the requested document as @document if it is user_accepted
new
assigns a new document as @document
edit
assigns the requested document as @document if it is scanned
assigns the requested document as @document if it is incomplete
assigns the requested document as @document if it is checker rejected
does not assign the requested document as @document if it is complete
does not assign the requested document as @document if it is checker_accepted
does not assign the requested document as @document if it is user_rejected
does not assign the requested document as @document if it is user_accepted
PUT update
with valid params
updates the requested document
assigns the requested document as @document
redirects to the next scans index
POST create
with valid params
creates a new Receipt
redirects to show after creation
with invalid params
does not assign a newly created but unsaved document as @document
redirects to /
Finished in 6.83 seconds
47 examples, 0 failures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment