Skip to content

Instantly share code, notes, and snippets.

@mikezter
Created October 22, 2012 18:03
Show Gist options
  • Select an option

  • Save mikezter/3933032 to your computer and use it in GitHub Desktop.

Select an option

Save mikezter/3933032 to your computer and use it in GitHub Desktop.
I love how good specs read like an instruction manual!
mokbook:ethon mike$ rspec
Starting 1 test servers
Waiting for servers to start...
Servers are up!
Ethon::Easy::Form
.new
defines finalizer
assigns attribute to @params
#first
returns a pointer
#multipart?
when query_pairs contains string values
returns false
when query_pairs contains file
returns true
#last
returns a pointer
#materialize
when query_pairs contains file
adds file to form
when query_pairs contains nil
adds params to form
when query_pairs contains string values
adds params to form
Ethon::Easy::ResponseCallbacks
#on_complete
responds
when multiple blocks given
stores
when block given
stores
when no block given
returns @on_complete
#complete
executes blocks and passes self
Ethon::Multi::Stack
#add
when multi cleaned up before
raises multi add error
when multi_add_handle fails
raises multi add error
when easy new
adds easy to multi
adds easy to easy_handles
when easy already added
returns nil
#delete
when multi_remove_handle fails
raises multi remove error
when easy is not in easy_handles
does nothing
adds easy to easy_handles
when easy in easy_handles
deletes easy from multi
deletes easy from easy_handles
Ethon::Loggable
#logger=
sets the logger
Ethon::Multi::Operations
#handle
returns a pointer
#running_count
when hydra has more easys
returns 2
when hydra has easy
returns 1
when hydra has no easy
returns nil
#reset_fds
resets @fd_excep
resets @fd_write
resets @fd_read
#check
example at ./spec/ethon/multi/operations_spec.rb:277 (PENDING: untested)
#init_vars
sets @timeout
sets @timeval
sets @fd_excep
sets @fd_read
sets @max_fd
sets @fd_write
#get_timeout
when code ok
doesn't raise
when timeout smaller zero
returns 1
when timeout bigger or equal zero
returns timeout
when code not ok
raises MultiTimeout error
#ongoing?
when easy_handles
when running_count not greater 0
returns true
when running_count greater 0
returns true
when no easy_handles
when running_count not greater 0
returns false
when running_count greater 0
returns true
#trigger
returns multi perform code
sets running count
calls multi perform
#run
example at ./spec/ethon/multi/operations_spec.rb:281 (PENDING: untested)
#set_fds
when code ok
doesn't raise
when max_fd -1
waits 100ms
when max_fd not -1
when code smaller zero
raises Select error
when code bigger or equal zero
doesn't raise
when code not ok
raises MultiFdset error
#perform
when four easy handles
sets response codes
when easy handle
requests
sets easy
when no easy handles
returns nil
logs
Ethon::Easy::Http::Post
#setup
when params and body
when requesting
url contains params
body contains form
when body
when string
when requesting
returns ok
sends string
when not multipart
sets escaped copypostfields
sets postfieldsize
when requesting
returns ok
is a post
submits a body
uses multipart/form-data content type
submits the data
when multipart
sets httppost
when requesting
returns ok
is a post
submits a body
uses multipart/form-data content type
submits the data
when params
sets copy_postfields
sets postfield_size
attaches escaped to url
when requesting
requests parameterized url
uses application/x-www-form-urlencoded content type
is a post
when nothing
makes a post request
sets copy_postfields
sets postfield_size
sets url
Ethon::Easy::Http::Head
#setup
when body
when requesting
returns ok
when params
sets nobody
attaches escaped to url
when requesting
requests parameterized url
has no body
returns ok
when nothing
sets nobody
sets url
Ethon::Easy::Informations
#httpauth_avail
returns
#total_time
returns float
#response_code
returns 200
#primary_ip
returns localhost
#redirect_count
returns 0
#appconnect_time
returns float
#effective_url
returns url
#supports_zlib?
returns true
#namelookup_time
returns float
#pretransfer_time
returns float
#starttransfer_time
returns float
#connect_time
returns float
Ethon::Easy::Header
#header_list
when no set_headers
returns nil
when set_headers
returns pointer to header list
#compose_header
has space in between
when value is a symbol
works
#set_headers
sets header
when requesting
sends
when header value has traiing whitespace
removes
when header value has leading whitespace
removes
when header value contains null byte
escapes
Ethon::Easy::Http
#http_request
instanciates action
Ethon::Easy::Queryable
#empty?
when params empty
returns true
when params not empty
returns false
#build_query_pairs
when params is empty
returns empty array
when params is string
wraps it in an array
when params contains something nested in an array
when file
transforms
when hash
transforms
when string
transforms
when params contains file
transforms
when params contains an array
transforms
when params is a nested hash
transforms
when params is simple hash
transforms
when params value contains a null byte
escapes
when params key contains a null byte
escapes
#to_s
when query_pairs contains a string
returns correct string
when query_pairs not empty
when escape
turns "&" into %26
turns "\"" into %22
turns "$" into %24
turns ";" into %3B
turns ">" into %3E
turns ")" into %29
turns ":" into %3A
turns "*" into %2A
turns "|" into %7C
turns "`" into %60
turns "[" into %5B
leaves "_" instead of turning into %5F
turns "\\" into %5C
turns "(" into %28
turns "?" into %3F
leaves "-" instead of turning into %2D
turns "=" into %3D
turns "%" into %25
turns "," into %2C
turns "{" into %7B
turns "}" into %7D
turns " " into %20
turns "#" into %23
leaves "~" instead of turning into %7E
turns "まつもと" into %E3%81%BE%E3%81%A4%E3%82%82%E3%81%A8
turns "^" into %5E
turns "'" into %27
turns "@" into %40
turns "<" into %3C
leaves "." instead of turning into %2E
turns "]" into %5D
turns "!" into %21
turns "+" into %2B
turns "/" into %2F
when no escape
returns concatenated query string
when query_pairs empty
returns empty string
Ethon::Easy::Http::Put
#setup
when body
sets upload
sets readfunction
sets infilesize
when requesting
makes a put request
submits a body
when params
sets infilesize
sets upload
attaches escaped to url
when requesting
makes a put request
when nothing
sets infilesize
sets upload
sets url
when requesting
makes a put request
Ethon::Easy::Http::Get
#setup
sets url
when requesting
when params and no body
requests parameterized url
is a get request
returns ok
when params and body
requests parameterized url
is a get request
returns ok
when no body
doesn't set customrequest
when body
sets customrequest
Ethon::Easy::Operations
#handle
returns a pointer
#perform
calls Curl.easy_perform
when no url
returns url_malformat
when auth url
when basic auth
when valid user_pwd
returns 200
when invalid user_pwd
returns 401
when no user_pwd
returns 401
when ntlm
when no user_pwd
returns 401
when user_pwd
returns 200
when url
sets response header
sets response body
returns ok
when request timed out
returns operation_timedout
when connection timed out
returns couldnt_connect
when follow location
follows
when infinite redirect loop
when max redirect set
follows only x times
when no follow location
doesn't follow
when user agent
sets
Ethon::Easy::Http::Delete
when requesting
makes a delete request
Ethon::Multi
.new
inits curl
defines finalizer
when options not empty
when pipelining is set
sets pipelining
.finalizer
calls multi_cleanup
works
Ethon::Easy::Options
when requesting
when timeout
when request takes longer
times out
when connecttimeout
when cannot connect
times out
#value_for
when value in unspecific_options
when value a string
returns zero byte escaped string
when value not a string
returns value
when value in int_options
returns value casted to int
when value in enum_options
returns value from struct
when option in bool_options
when value true
returns 1
when value false
returns 0
#set_options
when option
sets curl option
when options contains a null byte
doesn't fail
when no option
sets nothing
options
have read accessors
have write accessors
when option unspecific
sets
when option in int_options
sets
when option in enum_options
when invalid value
raises invalid value error
when valid value
sets
when option in bool_options
when value true
sets
when value false
sets
Ethon::Easy
.new
inits curl
defines finalizer
when options are empty
sets nothing
when options not empty
when verbose is set
sets verbose
#set_attributes
when options are empty
sets nothing
when options aren't empty
when valid key
sets
when invalid key
raises invalid option error
#to_hash
contains return_code
contains response_code
contains namelookup_time
contains connect_time
contains effective_url
contains response_body
contains pretransfer_time
contains redirect_count
contains primary_ip
contains total_time
contains appconnect_time
contains response_header
contains starttransfer_time
#reset
sets instance variables to nil
resets easy handle
.finalizer
calls easy_cleanup
when header_list
calls slist_free_all
Ethon::Curl
.init
when global_init fails
raises global init error
when global_init works
doesn't raises global init error
logs
Ethon::Easy::Http::Patch
#setup
sets customrequest
sets url
when requesting
requests parameterized url
is a patch request
returns ok
Ethon::Easy::Callbacks
#set_callbacks
resets @response_header
resets @response_body
sets write- and headerfunction
Ethon::Multi::Options
options
have read accessors
have write accessors
when option unspecific
sets
when option in int_options
sets
when option in bool_options
when value true
sets
when value false
sets
#set_options
when option
sets curl option
when options contains a null byte
doesn't fail
when no option
sets nothing
Ethon::Easy::Http::Options
#setup
sets customrequest
sets url
when requesting
requests parameterized url
is a options request
returns ok
Ethon::Easy::Util
escape_zero_byte
when value has no zero byte
returns same value
when value has zero byte
returns escaped
Pending:
Ethon::Multi::Operations#check
# untested
# ./spec/ethon/multi/operations_spec.rb:277
Ethon::Multi::Operations#run
# untested
# ./spec/ethon/multi/operations_spec.rb:281
Finished in 18.97 seconds
283 examples, 0 failures, 2 pending
Randomized with seed 44024
Killing pid 55767
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment