patentscope 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,256 @@
1
+ require 'spec_helper'
2
+
3
+ module Patentscope
4
+
5
+ describe PctAppNumber, :core do
6
+
7
+ let(:pct_app_number) { PctAppNumber.new }
8
+
9
+ describe "methods" do
10
+ it "has the right methods" do
11
+ expect(pct_app_number).to respond_to(:valid?)
12
+ expect(pct_app_number).to respond_to(:validate)
13
+ expect(pct_app_number).to respond_to(:to_ia_number)
14
+ end
15
+ end
16
+
17
+ describe "valid? validate methods" do
18
+
19
+ describe "application numbers in acceptable format" do
20
+
21
+ describe "country, year and number run on" do
22
+ let(:pct_app_number) { PctAppNumber.new('SG2012000001') }
23
+
24
+ it "is valid" do
25
+ expect(pct_app_number).to be_valid
26
+ end
27
+
28
+ it "validates" do
29
+ expect { pct_app_number.validate }.to_not raise_error
30
+ end
31
+ end
32
+
33
+ describe "year and number run on separated by a slash" do
34
+ let(:pct_app_number) { PctAppNumber.new('SG2012/000001') }
35
+
36
+ it "is valid" do
37
+ expect(pct_app_number).to be_valid
38
+ end
39
+
40
+ it "validates" do
41
+ expect { pct_app_number.validate }.to_not raise_error
42
+ end
43
+ end
44
+
45
+ describe "leading space before application number" do
46
+ let(:pct_app_number) { PctAppNumber.new(' SG2012000001') }
47
+
48
+ it "is valid" do
49
+ expect(pct_app_number).to be_valid
50
+ end
51
+
52
+ it "validates" do
53
+ expect { pct_app_number.validate }.to_not raise_error
54
+ end
55
+ end
56
+
57
+ describe "trailing space after application number" do
58
+ let(:pct_app_number) { PctAppNumber.new('SG2012000001 ') }
59
+
60
+ it "is valid" do
61
+ expect(pct_app_number).to be_valid
62
+ end
63
+
64
+ it "validates" do
65
+ expect { pct_app_number.validate }.to_not raise_error
66
+ end
67
+ end
68
+
69
+ describe "non-existent applications" do
70
+ let(:pct_app_number) { PctAppNumber.new('SG2012999999') }
71
+
72
+ it "is valid even when application doesn't exist" do
73
+ expect(pct_app_number).to be_valid
74
+ end
75
+
76
+ it "validates" do
77
+ expect { pct_app_number.validate }.to_not raise_error
78
+ end
79
+ end
80
+
81
+ describe "application number prefixed with PCT" do
82
+ let(:pct_app_number) { PctAppNumber.new('PCTSG2012000001') }
83
+
84
+ it "is valid" do
85
+ expect(pct_app_number).to be_valid
86
+ end
87
+
88
+ it "validates" do
89
+ expect { pct_app_number.validate }.to_not raise_error
90
+ end
91
+ end
92
+
93
+ describe "application number prefixed with PCT/" do
94
+ let(:pct_app_number) { PctAppNumber.new('PCT/SG2012000001') }
95
+
96
+ it "is valid" do
97
+ expect(pct_app_number).to be_valid
98
+ end
99
+
100
+ it "validates" do
101
+ expect { pct_app_number.validate }.to_not raise_error
102
+ end
103
+ end
104
+
105
+ describe "application number prefixed with PCT/, slash between year and number" do
106
+ let(:pct_app_number) { PctAppNumber.new('PCT/SG2012/000001') }
107
+
108
+ it "is valid" do
109
+ expect(pct_app_number).to be_valid
110
+ end
111
+
112
+ it "validates" do
113
+ expect { pct_app_number.validate }.to_not raise_error
114
+ end
115
+ end
116
+
117
+ describe "lowercase" do
118
+ let(:pct_app_number) { PctAppNumber.new('pct/sg2012/000001') }
119
+
120
+ it "is valid" do
121
+ expect(pct_app_number).to be_valid
122
+ end
123
+
124
+ it "validates" do
125
+ expect { pct_app_number.validate }.to_not raise_error
126
+ end
127
+ end
128
+
129
+ describe "mixed case" do
130
+ let(:pct_app_number) { PctAppNumber.new('pCt/sG2012000001') }
131
+
132
+ it "is valid" do
133
+ expect(pct_app_number).to be_valid
134
+ end
135
+
136
+ it "validates" do
137
+ expect { pct_app_number.validate }.to_not raise_error
138
+ end
139
+ end
140
+ end
141
+
142
+ describe "application numbers not in acceptable format" do
143
+
144
+ describe "no application number" do
145
+ let(:pct_app_number) { PctAppNumber.new('') }
146
+
147
+ it "is not valid" do
148
+ expect(pct_app_number).to_not be_valid
149
+ end
150
+
151
+ it "does not validate" do
152
+ expect { pct_app_number.validate }.to raise_error
153
+ end
154
+ end
155
+
156
+ describe "blank application number" do
157
+ let(:pct_app_number) { PctAppNumber.new(' ') }
158
+
159
+ it "is not valid" do
160
+ expect(pct_app_number).to_not be_valid
161
+ end
162
+
163
+ it "does not validate" do
164
+ expect { pct_app_number.validate }.to raise_error
165
+ end
166
+ end
167
+
168
+ describe "incorrectly formatted application numbers" do
169
+
170
+ describe "application number is too short" do
171
+ let(:pct_app_number) { PctAppNumber.new('SG201200001') }
172
+
173
+ it "is not valid" do
174
+ expect(pct_app_number).to_not be_valid
175
+ end
176
+
177
+ it "does not validate" do
178
+ expect { pct_app_number.validate }.to raise_error
179
+ end
180
+ end
181
+
182
+ describe "application number is too long" do
183
+ let(:pct_app_number) { PctAppNumber.new('SG20120000011') }
184
+
185
+ it "is not valid" do
186
+ expect(pct_app_number).to_not be_valid
187
+ end
188
+
189
+ it "does not validate" do
190
+ expect { pct_app_number.validate }.to raise_error
191
+ end
192
+ end
193
+
194
+ describe "application number contains non-digits" do
195
+ let(:pct_app_number) { PctAppNumber.new('SG2012A00001') }
196
+
197
+ it "is not valid" do
198
+ expect(pct_app_number).to_not be_valid
199
+ end
200
+
201
+ it "does not validate" do
202
+ expect { pct_app_number.validate }.to raise_error
203
+ end
204
+ end
205
+
206
+ describe "application number has more than one slash" do
207
+ let(:pct_app_number) { PctAppNumber.new('SG2012//000001') }
208
+
209
+ it "is not valid" do
210
+ expect(pct_app_number).to_not be_valid
211
+ end
212
+
213
+ it "does not validate" do
214
+ expect { pct_app_number.validate }.to raise_error
215
+ end
216
+ end
217
+ end
218
+ end
219
+ end
220
+
221
+ describe "to_ia_number method" do
222
+ context "uppercase letters" do
223
+ it "converts to an ia_number" do
224
+ expect(PctAppNumber.new('SG2012000001').to_ia_number).to eq('SG2012000001')
225
+ expect(PctAppNumber.new('SG2012/000001').to_ia_number).to eq('SG2012000001')
226
+ expect(PctAppNumber.new('PCTSG2012000001').to_ia_number).to eq('SG2012000001')
227
+ expect(PctAppNumber.new('PCT/SG2012000001').to_ia_number).to eq('SG2012000001')
228
+ expect(PctAppNumber.new('PCTSG2012/000001').to_ia_number).to eq('SG2012000001')
229
+ expect(PctAppNumber.new('PCT/SG2012/000001').to_ia_number).to eq('SG2012000001')
230
+ end
231
+ end
232
+
233
+ context "lowercase letters" do
234
+ it "converts to an ia_number" do
235
+ expect(PctAppNumber.new('sg2012000001').to_ia_number).to eq('SG2012000001')
236
+ expect(PctAppNumber.new('sg2012/000001').to_ia_number).to eq('SG2012000001')
237
+ expect(PctAppNumber.new('pctsg2012000001').to_ia_number).to eq('SG2012000001')
238
+ expect(PctAppNumber.new('pct/sg2012000001').to_ia_number).to eq('SG2012000001')
239
+ expect(PctAppNumber.new('pctsg2012/000001').to_ia_number).to eq('SG2012000001')
240
+ expect(PctAppNumber.new('pct/sg2012/000001').to_ia_number).to eq('SG2012000001')
241
+ end
242
+ end
243
+
244
+ context "mixed case letters" do
245
+ it "converts to an ia_number" do
246
+ expect(PctAppNumber.new('sG2012000001').to_ia_number).to eq('SG2012000001')
247
+ expect(PctAppNumber.new('sG2012/000001').to_ia_number).to eq('SG2012000001')
248
+ expect(PctAppNumber.new('pCtsG2012000001').to_ia_number).to eq('SG2012000001')
249
+ expect(PctAppNumber.new('pCt/sG2012000001').to_ia_number).to eq('SG2012000001')
250
+ expect(PctAppNumber.new('pCtsG2012/000001').to_ia_number).to eq('SG2012000001')
251
+ expect(PctAppNumber.new('pCt/sG2012/000001').to_ia_number).to eq('SG2012000001')
252
+ end
253
+ end
254
+ end
255
+ end
256
+ end
@@ -0,0 +1,220 @@
1
+ require 'spec_helper'
2
+
3
+ module Patentscope
4
+
5
+ describe PctPubNumber, :core do
6
+
7
+ let(:pct_pub_number) { PctPubNumber.new }
8
+
9
+ describe "methods" do
10
+ it "has the right methods" do
11
+ expect(pct_pub_number).to respond_to(:valid?)
12
+ expect(pct_pub_number).to respond_to(:validate)
13
+ end
14
+ end
15
+
16
+ describe "valid? validate methods" do
17
+
18
+ describe "publication numbers in acceptable format" do
19
+
20
+ describe "prefix, year and number run on" do
21
+ let(:pct_pub_number) { PctPubNumber.new('WO2009105044') }
22
+
23
+ it "is valid" do
24
+ expect(pct_pub_number).to be_valid
25
+ end
26
+
27
+ it "validates" do
28
+ expect { pct_pub_number.validate }.to_not raise_error
29
+ end
30
+ end
31
+
32
+ describe "year and number separated by a slash" do
33
+ let(:pct_pub_number) { PctPubNumber.new('WO2009/105044') }
34
+
35
+ it "is valid" do
36
+ expect(pct_pub_number).to be_valid
37
+ end
38
+
39
+ it "validates" do
40
+ expect { pct_pub_number.validate }.to_not raise_error
41
+ end
42
+ end
43
+
44
+ describe "prefix and year and year and number separated by slashes" do
45
+ let(:pct_pub_number) { PctPubNumber.new('WO/2009/105044') }
46
+
47
+ it "is valid" do
48
+ expect(pct_pub_number).to be_valid
49
+ end
50
+
51
+ it "validates" do
52
+ expect { pct_pub_number.validate }.to_not raise_error
53
+ end
54
+ end
55
+
56
+ describe "leading space before application number" do
57
+ let(:pct_pub_number) { PctPubNumber.new(' WO2009105044') }
58
+
59
+ it "is valid" do
60
+ expect(pct_pub_number).to be_valid
61
+ end
62
+
63
+ it "validates" do
64
+ expect { pct_pub_number.validate }.to_not raise_error
65
+ end
66
+ end
67
+
68
+ describe "trailing space after application number" do
69
+ let(:pct_pub_number) { PctPubNumber.new('WO2009105044 ') }
70
+
71
+ it "is valid" do
72
+ expect(pct_pub_number).to be_valid
73
+ end
74
+
75
+ it "validates" do
76
+ expect { pct_pub_number.validate }.to_not raise_error
77
+ end
78
+ end
79
+
80
+ describe "non-existent applications" do
81
+ let(:pct_pub_number) { PctPubNumber.new('WO2009999999') }
82
+
83
+ it "is valid even when application doesn't exist" do
84
+ expect(pct_pub_number).to be_valid
85
+ end
86
+
87
+ it "validates" do
88
+ expect { pct_pub_number.validate }.to_not raise_error
89
+ end
90
+ end
91
+
92
+ describe "space before year, no slash" do
93
+ let(:pct_pub_number) { PctPubNumber.new('WO 2009105044') }
94
+
95
+ it "is valid" do
96
+ expect(pct_pub_number).to be_valid
97
+ end
98
+
99
+ it "does validates" do
100
+ expect { pct_pub_number.validate }.to_not raise_error
101
+ end
102
+ end
103
+
104
+ describe "space before year, with slash" do
105
+ let(:pct_pub_number) { PctPubNumber.new('WO 2009/105044') }
106
+
107
+ it "is valid" do
108
+ expect(pct_pub_number).to be_valid
109
+ end
110
+
111
+ it "does validates" do
112
+ expect { pct_pub_number.validate }.to_not raise_error
113
+ end
114
+ end
115
+
116
+ describe "lowercase" do
117
+ let(:pct_pub_number) { PctPubNumber.new('wo 2009/105044') }
118
+
119
+ it "is valid" do
120
+ expect(pct_pub_number).to be_valid
121
+ end
122
+
123
+ it "does validates" do
124
+ expect { pct_pub_number.validate }.to_not raise_error
125
+ end
126
+ end
127
+
128
+ describe "mixed case" do
129
+ let(:pct_pub_number) { PctPubNumber.new('wO 2009/105044') }
130
+
131
+ it "is valid" do
132
+ expect(pct_pub_number).to be_valid
133
+ end
134
+
135
+ it "does validates" do
136
+ expect { pct_pub_number.validate }.to_not raise_error
137
+ end
138
+ end
139
+ end
140
+
141
+ describe "publication numbers not in acceptable format" do
142
+
143
+ describe "no application number" do
144
+ let(:pct_pub_number) { PctPubNumber.new('') }
145
+
146
+ it "is not valid" do
147
+ expect(pct_pub_number).to_not be_valid
148
+ end
149
+
150
+ it "does not validate" do
151
+ expect { pct_pub_number.validate }.to raise_error
152
+ end
153
+ end
154
+
155
+ describe "blank application number" do
156
+ let(:pct_pub_number) { PctPubNumber.new(' ') }
157
+
158
+ it "is not valid" do
159
+ expect(pct_pub_number).to_not be_valid
160
+ end
161
+
162
+ it "does not validate" do
163
+ expect { pct_pub_number.validate }.to raise_error
164
+ end
165
+ end
166
+
167
+ describe "incorrectly formatted application numbers" do
168
+
169
+ describe "application number is too short" do
170
+ let(:pct_pub_number) { PctPubNumber.new('WO200910504') }
171
+
172
+ it "is not valid" do
173
+ expect(pct_pub_number).to_not be_valid
174
+ end
175
+
176
+ it "does not validate" do
177
+ expect { pct_pub_number.validate }.to raise_error
178
+ end
179
+ end
180
+
181
+ describe "application number is too long" do
182
+ let(:pct_pub_number) { PctPubNumber.new('WO20091050449') }
183
+
184
+ it "is not valid" do
185
+ expect(pct_pub_number).to_not be_valid
186
+ end
187
+
188
+ it "does not validate" do
189
+ expect { pct_pub_number.validate }.to raise_error
190
+ end
191
+ end
192
+
193
+ describe "application number contains non-digits" do
194
+ let(:pct_pub_number) { PctPubNumber.new('WO2009A05044') }
195
+
196
+ it "is not valid" do
197
+ expect(pct_pub_number).to_not be_valid
198
+ end
199
+
200
+ it "does not validate" do
201
+ expect { pct_pub_number.validate }.to raise_error
202
+ end
203
+ end
204
+
205
+ describe "application number has too many slashes" do
206
+ let(:pct_pub_number) { PctPubNumber.new('WO//2009/105044') }
207
+
208
+ it "is not valid" do
209
+ expect(pct_pub_number).to_not be_valid
210
+ end
211
+
212
+ it "does not validate" do
213
+ expect { pct_pub_number.validate }.to raise_error
214
+ end
215
+ end
216
+ end
217
+ end
218
+ end
219
+ end
220
+ end