Skip to content

Instantly share code, notes, and snippets.

@pete
Created January 7, 2009 23:47
Show Gist options
  • Save pete/44507 to your computer and use it in GitHub Desktop.
Save pete/44507 to your computer and use it in GitHub Desktop.
rake test
(in /home/pete/proj/waves)
/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/gempackagetask.rb:13:Warning: Gem::manage_gems is deprecated and will be removed on or after March 2009.
Matching The Accepts Header
- Match an implied accept header using the file extension
- Match against an array of options
- Match against a Mime type (rather than subtype)
Matching Request Methods
- Match the 'get' method
- Match the 'put' method
- Match the 'post' method
- Match the 'delete' method
- Match the 'head' method
A resource that has matched a request
- makes parameters captured from the path available as #captured
- makes http query parameters available as #query
- provides access to all derived parameters using #params
Matching Query Parameters
- Test for a query parameter using true
- Test that a query parameter matches a regexp
- Test that a query parameter matches a string
- Test that a query parameter satisfies a lambda condition
Matching Request URIs
- By default, we match an arbitrary path.
- A path of true matches an arbitrary path.
- An empty path matches root.
- A string path component matches that string.
- A symbol path component captures that component using the symbol as a key.
- A regexp path component matches the any component that matches the regexp.
- A path component of true matches the remaining path.
- A Range path component can match one or more components
- A Range path component can match zero or more components
- A Range path component can match one to N (N=2) components
- A Range path component can match one to N (N=3) components
- A path component can use a hash with a value of true to capture the remaining path.
- A Range path component can match one or more components
- A Range path component can match zero or more components
- A Range path component can match one to N (N=2) components
- A Range path component can match one to N (N=3) components
- A path component can use a hash with a string value to provide a default.
- A path component can use a hash with a regexp value to match and capture.
- Path components match against unescaped values
Request Object
- Access the request method, scheme, url, host, port, path, referer, and query
- Access the request method as a boolean
- Access HTTP headers as accessor methods
- Access accept headers as Waves::Request::Accept objects
- Access custom headers as methods
- Initiate redirect using #redirect
- Raise NotFoundError using #not_found
- Access to content_type, media_type, and content_length
- Read / write traits to the request
- The Rack request is frozen and cannot be modified
Application Context
- Provide acccess to request, response, and session objects
- Shortcuts to the path, url, domain, and session
- Access to path and associated helpers
- Access to the application object and name
Object#cache_method_missing
- defines the missing method
- passes along the args
- passes along the block
Object#instance_exec
- works like instance_eval, but it takes args and gives them to the block
Waves::Ext::String
- defines / as syntactic sugar for File.join
A monkeypatch to Symbol
- defines / as syntactic sugar for File.join
Waves::Ext::Hash
- adds a non-destructive method for converting all hash keys to strings
- adds a destructive method for converting hash keys to symbols
Waves::Ext::Integer
- has an absolutely pedantic amount of helpers
Waves::Ext::Module
- defines a basename method
- defines [] for easy access to namespaced constants
- defines a method for obtaining the outermost constant name
- defines a method for obtaining the outermost constant
A path generation method
- turns an empty template into '/'
- reproduces strings from the path template
- treats symbols as locations for arg interpolation
- treats a hash with string or symbol value as location for arg interpolations
- interpolates for a hash-with-regex only when the arg matches the regex
- appends all arguments to the path when it encounters a true
- uses hash element value as default in absence of argument
- uses regexes for argument interpolation if the arg matches
given an (implicit) array of args
- interpolates its arguments in order
- raises an ArgumentError if given more args than interpolables
given an argument hash
- interpolates arg pairs that match symbols in the template
- interpolates arg pairs that match the keys of hashes in the template
- interpolates an arg pair for a hash-with-regex only when the arg matches the regex
- uses hash element value as default in absence of an arg pair
- raises when not all necessary interpolations can be performed
- raises an ArgumentError if the template contains a regex
- appends value/s of arg pair matching a template hash-with-true
- raises an ArgumentError if the template contains a true
A path template
- is compilable when it contains Strings, Symbols, and Hashes with Strings or Symbols
- is not compilable if it contains Regexps, true, or Hashes with Regexp or true
Configuration attributes
- can be declared by developers
- must be declared before use
A Waves request instance
- has session, response, and blackboard objects
- provides an accessor to the Rack request
- wraps some useful Rack data in more elegant methods
The HTTP request method
- is determined in a straightforward manner for straightforward requests
- can be set with the '_method' query param on a POST
- can be set with the '_method' body param on a POST
An instance of Waves::Response
- has a Rack::Response
- has a Waves::Request
- can access the session for the current request
- provides setter methods for commonly used headers
- delegates unknown methods to the Rack response
Waves::Response#finish
- saves the request session and calls Rack::Response#finish
A class which has included Waves::Views::Mixin
- works [ERROR: Waves::Views::NoTemplateError]
- new stuff works [ERROR: Waves::Views::NoTemplateError]
Waves::Views::NoTemplateError: /
./lib/views/mixin.rb:40:in `template_file': A class which has included Waves::Views::Mixin - works
./lib/views/mixin.rb:52:in `render'
./test/views/views.rb:21
/usr/lib/ruby/gems/1.8/gems/facon-0.4.1/lib/facon/baconize.rb:56:in `it'
./test/views/views.rb:20
./test/views/views.rb:14
./test/views/views.rb:6:in `chdir'
./test/views/views.rb:6
Waves::Views::NoTemplateError: /
./lib/views/mixin.rb:40:in `template_file': A class which has included Waves::Views::Mixin - new stuff works
./test/views/views.rb:26
/usr/lib/ruby/gems/1.8/gems/facon-0.4.1/lib/facon/baconize.rb:56:in `it'
./test/views/views.rb:25
./test/views/views.rb:14
./test/views/views.rb:6:in `chdir'
./test/views/views.rb:6
97 specifications (184 requirements), 0 failures, 2 errors
pete@aku:~/proj/waves$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment