File: uri_spec.rb

package info (click to toggle)
ruby-dataobjects 0.10.17-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 608 kB
  • sloc: ruby: 2,984; makefile: 4
file content (125 lines) | stat: -rw-r--r-- 3,133 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))

describe DataObjects::URI do
  subject { described_class.parse(uri) }

  context 'parsing parts' do
    let(:uri) { 'mock://username:password@localhost:12345/path?encoding=utf8#fragment'  }

    describe '#scheme' do
      subject { super().scheme }
      it { is_expected.to eq('mock')      }
    end

    describe '#user' do
      subject { super().user }
      it { is_expected.to eq('username')  }
    end

    describe '#password' do
      subject { super().password }
      it { is_expected.to eq('password')  }
    end

    describe '#host' do
      subject { super().host }
      it { is_expected.to eq('localhost') }
    end

    describe '#port' do
      subject { super().port }
      it { is_expected.to eq(12345)       }
    end

    describe '#path' do
      subject { super().path }
      it { is_expected.to eq('/path')     }
    end

    describe '#query' do
      subject { super().query }
      it { is_expected.to eq({ 'encoding' => 'utf8' }) }
    end

    describe '#fragment' do
      subject { super().fragment }
      it { is_expected.to eq('fragment')  }
    end

    it 'should provide a correct string representation' do
      expect(subject.to_s).to eq('mock://username@localhost:12345/path?encoding=utf8#fragment')
    end
  end

  context 'parsing JDBC URL parts' do
    let(:uri) { 'jdbc:mock://username:password@localhost:12345/path?encoding=utf8#fragment'  }

    describe '#scheme' do
      subject { super().scheme }
      it { is_expected.to eq('jdbc')      }
    end

    describe '#subscheme' do
      subject { super().subscheme }
      it { is_expected.to eq('mock')      }
    end

    describe '#user' do
      subject { super().user }
      it { is_expected.to eq('username')  }
    end

    describe '#password' do
      subject { super().password }
      it { is_expected.to eq('password')  }
    end

    describe '#host' do
      subject { super().host }
      it { is_expected.to eq('localhost') }
    end

    describe '#port' do
      subject { super().port }
      it { is_expected.to eq(12345)       }
    end

    describe '#path' do
      subject { super().path }
      it { is_expected.to eq('/path')     }
    end

    describe '#query' do
      subject { super().query }
      it { is_expected.to eq({ 'encoding' => 'utf8' }) }
    end

    describe '#fragment' do
      subject { super().fragment }
      it { is_expected.to eq('fragment')  }
    end

    it 'should provide a correct string representation' do
      expect(subject.to_s).to eq('jdbc:mock://username@localhost:12345/path?encoding=utf8#fragment')
    end
  end

  context 'parsing parts' do
    let(:uri) { 'java:comp/env/jdbc/TestDataSource'  }

    describe '#scheme' do
      subject { super().scheme }
      it { is_expected.to eq('java') }
    end

    describe '#path' do
      subject { super().path }
      it { is_expected.to eq('comp/env/jdbc/TestDataSource')     }
    end

    it 'should provide a correct string representation' do
      expect(subject.to_s).to eq('java:comp/env/jdbc/TestDataSource')
    end
  end

end