Skip to content

Instantly share code, notes, and snippets.

@sameera207
Created December 19, 2013 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sameera207/8038652 to your computer and use it in GitHub Desktop.
Save sameera207/8038652 to your computer and use it in GitHub Desktop.
sameeras-mbp:pretty_search sameera$ rspec
pretty search routes
. should route /pretty_search/query/company to pretty_search#search with model_name 'company'
PrettySearch::Query
constants
. check defaults
instance methods
.initialize
if attr presented on initialize
. should eq "matches"
. should eq 2
. should eq :title
. should eq 5
. should eq "query"
if attr is absent on init
. should eq :id
. should eq 10
. should eq 1
. should be nil
. should eq "eq"
PrettySearch::Searcher
instance methods
.initialize
. model_class should be Mug
. field.name should be 'volume'
. field_list should be [:volume]
PrettySearch::Field
.initialize
when field_name present
. instance should set name of field
. instance should set type of field
. PrettySearch#default_search_fields method shouldn't be called
when field_name absent, try find default fields
if default field is found
. instance should set name of field
. instance should set type of field
. PrettySearch#default_search_fields method should be called
if default field isn't found
. instance should return null field type
. instance should return null field name
. PrettySearch#default_search_fields method should be called
PrettySearchController
.search
when user authorised
action should return @options and @results
. options should eq hash of three keys
. results should be an instance variable, equal the result of PrettySearch#handle method
when PrettySearch.authorized is false
and auth_url present
. should redirect to auth url
and auth_url is absent
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
. should raise PrettySearch::NotSpecifiedUrlError
PrettySearch
.available_for_use?
when hash value is an array
but when model presents in both, enabled and disabled hashes, but fields wrote in enabled only
. all fields written on enabled model should be available
when both, enabled and disabled fields are blank
. should be available for search
when both, enabled and disabled fields presents
. disabled option override enabled, and field shouldn't be available for search
when enabled_fields present, and field presents in enabled fields
. should be available for search
when disabled fields present, and field presents in disabled fields
. shouldn't be available for search
when hash value is a :all symbol
when disable all fields in model
. all fields on disabled model shouldn't be available
when enable all fields in model
. all fields on enabled model should be available
Finished in 0.06687 seconds
35 examples, 0 failures
Finished in 0.06687 seconds
35 examples, 0 failures
Randomized with seed 51621
Randomized with seed 51621
sameeras-mbp:pretty_search sameera$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment