Sha256: 04e295c74f66086389b0edd81230cb201cd8b611c523c8927b4865a6d3ee3f36
Contents?: true
Size: 563 Bytes
Versions: 1
Compression:
Stored size: 563 Bytes
Contents
require 'spec_helper' require 'sinatra/base' require 'json' class SinatraMixin < Sinatra::Base class Artist < Sequel::Model plugin :json_serializer extend Rack::Reducer reduces dataset, filters: [ ->(genre:) { grep(:genre, "%#{genre}%", case_insensitive: true) }, ->(name:) { grep(:name, "%#{name}%", case_insensitive: true) }, ->(order:) { order(order.to_sym) } ] end get '/artists' do @artists = Artist.reduce(params) @artists.all.to_json end end describe SinatraMixin do it_behaves_like Rack::Reducer end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-reducer-0.1.1 | spec/sinatra_mixin_spec.rb |