Sha256: e5cb38c9bac0d45093688ca5cd461a43fab221c9883ed4adfe8272d1295ff8b1
Contents?: true
Size: 1.49 KB
Versions: 3
Compression:
Stored size: 1.49 KB
Contents
require 'spec_helper' require 'volt/models/url' describe Volt::URL do let(:uri) { 'http://voltframework.com:8888/path/1?query=val#fragment' } let(:fake_location) do double( 'Location', host: 'voltframework.com', protocol: 'http:' ) end before do allow(Location).to receive(:new).and_return fake_location subject.parse uri end subject { described_class.new fake_router } describe '#parse' do let(:fake_router) { double('Router', url_to_params: {foo: 'bar'}) } context 'with a valid url' do it 'returns "http" for scheme' do expect(subject.scheme).to eq 'http' end it 'returns "voltframework.com" for #host' do expect(subject.host).to eq 'voltframework.com' end it 'returns 8888 for #port' do expect(subject.port).to eq 8888 end it 'returns "/path/1" for #path' do expect(subject.path).to eq '/path/1' end it 'returns "query=val" for #query' do expect(subject.query).to eq 'query=val' end it 'returns "fragment" for #fragment' do expect(subject.fragment).to eq 'fragment' end end end describe '#url_for' do let(:fake_router) do router = Volt::Routes.new router.define do client '/path/{{ id }}', view: 'blog/show' end end it 'regenerates the URL for the given params' do params = { view: 'blog/show', id: '1', query: 'val' } expect(subject.url_for params).to eq uri end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
volt-0.9.1 | spec/models/url_spec.rb |
volt-0.9.1.pre5 | spec/models/url_spec.rb |
volt-0.9.1.pre4 | spec/models/url_spec.rb |