Sha256: d152c966eb90b844053d43573ab95ad2216d9b69f6510cc7b7761ee0ac43cf37
Contents?: true
Size: 1.25 KB
Versions: 21
Compression:
Stored size: 1.25 KB
Contents
require 'rest-core/test' describe RC::DefaultQuery do before do @app = RC::DefaultQuery.new(RC::Dry.new, {}) end env = {RC::REQUEST_QUERY => {}} describe 'when given query' do would 'do nothing' do @app.call(env){ |r| r[RC::REQUEST_QUERY].should.eq({}) } end would 'merge query' do @app.instance_eval{@query = {'q' => 'uery'}} @app.call(env){ |r| r.should.eq({RC::REQUEST_QUERY => {'q' => 'uery'}}) } format = {'format' => 'json'} e = {RC::REQUEST_QUERY => format} @app.call(e){ |r| r.should.eq({RC::REQUEST_QUERY => {'q' => 'uery'}.merge(format)}) } end would 'string_keys in query' do e = {'query' => {:symbol => 'value'}} @app.call(env.merge(e)){ |r| r.should.eq({RC::REQUEST_QUERY => {'symbol' => 'value'}}.merge(e)) } end would 'also merge the very default query' do @app.query = {'a' => 'b'} @app.call('query' => {'b' => 'c'}, RC::REQUEST_QUERY => {'c' => 'd'}) do |r| r[RC::REQUEST_QUERY].should.eq 'a' => 'b', 'b' => 'c', 'c' => 'd' end end end describe 'when not given query' do would 'merge query with {}' do @app.call(env){ |r| r.should.eq(RC::REQUEST_QUERY => {}) } end end end
Version data entries
21 entries across 21 versions & 1 rubygems