brand2csv 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +117 -93
- data/.gemtest +0 -0
- data/.gitignore +0 -10
- data/.rspec +0 -1
- data/.travis.yml +0 -14
- data/Gemfile +0 -14
- data/Gemfile.lock +0 -76
- data/History.txt +0 -111
- data/LICENCE.txt +0 -515
- data/Manifest.txt +0 -54
- data/README.md +0 -27
- data/Rakefile +0 -25
- data/bin/brand2csv +0 -100
- data/lib/brand2csv.rb +0 -590
- data/lib/brand2csv/version.rb +0 -3
- data/logs/aspen_08_08_1986.html +0 -598
- data/logs/post.rohdaten.httpfox +0 -1
- data/logs/post.rohdaten.mechanize +0 -1
- data/logs/protocol_swissreg.log +0 -86
- data/logs/result_01.10.2005.jsp +0 -598
- data/logs/sr1.jsp +0 -449
- data/logs/sr3.jsp +0 -598
- data/logs/start.jsp +0 -350
- data/logs/start2.jsp +0 -434
- data/protocol.2013.05.12.textile +0 -56
- data/protocol.2013.05.15.textile +0 -49
- data/protocol.2013.05.21.textile +0 -84
- data/spec/brand2csv_spec.rb +0 -62
- data/spec/csv_spec.rb +0 -27
- data/spec/data/aspectra/detail_00001_P-480296.html +0 -531
- data/spec/data/aspectra/detail_00002_P-482236.html +0 -531
- data/spec/data/aspectra/detail_00003_641074.html +0 -539
- data/spec/data/aspectra/first_results.html +0 -600
- data/spec/data/einfache_suche.html +0 -434
- data/spec/data/erweiterte_suche.html +0 -446
- data/spec/data/main.html +0 -350
- data/spec/data/result_short.html +0 -606
- data/spec/data/resultate_1.html +0 -446
- data/spec/data/resultate_2.html +0 -446
- data/spec/data/urner_wildheu/detail_00001_57862.2013.html +0 -516
- data/spec/data/urner_wildheu/first_results.html +0 -598
- data/spec/data/vereinfachte_1.html +0 -847
- data/spec/data/vereinfachte_detail_33.html +0 -516
- data/spec/detail_spec.rb +0 -28
- data/spec/short_spec.rb +0 -55
- data/spec/simple_search.rb +0 -43
- data/spec/spec_helper.rb +0 -34
- data/spec/support/core_ext/kernel.rb +0 -26
- data/spec/support/server_mock_helper.rb +0 -142
- data/spec/swissreg_spec.rb +0 -44
- data/spec/trademark_numbers_spec.rb +0 -21
- data/spec/utilities_spec.rb +0 -83
- data/spike.rb +0 -491
- data/spike_mechanize_swissreg.rb +0 -312
- data/spike_watir.rb +0 -58
- data/swissreg.rb +0 -75
data/spec/detail_spec.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
#encoding : utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
include Brand2csv
|
5
|
-
|
6
|
-
describe 'Detail' do
|
7
|
-
before :each do
|
8
|
-
dataDir = File.expand_path(File.join(File.dirname(__FILE__), 'data'))
|
9
|
-
session = Swissreg.new("01.01.1990", 'Branding')
|
10
|
-
filename = "#{dataDir}/vereinfachte_detail_33.html"
|
11
|
-
File.exists?(filename).should be_true
|
12
|
-
doc = Nokogiri::Slop(File.open(filename))
|
13
|
-
@marke = Swissreg::getMarkenInfoFromDetail(doc)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "collected trademark information must be correct" do
|
17
|
-
@marke.should_not be_nil
|
18
|
-
@marke.zeile_1.should == "Peter Löcker Bauart"
|
19
|
-
@marke.zeile_2.should == "Trollstrasse 20"
|
20
|
-
@marke.zeile_3.should be_nil
|
21
|
-
@marke.plz.should == '8400'
|
22
|
-
@marke.ort.should == 'Winterthur'
|
23
|
-
@marke.markennummer.should == '00135/2013'
|
24
|
-
@marke.inhaber.should == "Peter Löcker Bauart, Trollstrasse 20, 8400 Winterthur"
|
25
|
-
@marke.name.should == 'https://www.swissreg.ch/srclient/images/loadImage?Action=LoadImg&ItemType=tm&ImageType=print&ImageHash=F431E13A9D8F363BD06604796634142A18A5BA7C.jpeg'
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
data/spec/short_spec.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
include Brand2csv
|
4
|
-
|
5
|
-
describe 'Short (e.g. corvatsch*)' do
|
6
|
-
TrademarkSearch = 'TRADEMARK REGISTER SEARCH TIMES: QUERY=[10] SELECT=[70] SERVER=[80] DELEGATE=[93] (HITS=[9])'
|
7
|
-
before :each do
|
8
|
-
dataDir = File.expand_path(File.join(File.dirname(__FILE__), 'data'))
|
9
|
-
session = Swissreg.new("01.01.1990", 'Branding')
|
10
|
-
filename = "#{dataDir}/result_short.html"
|
11
|
-
File.exists?(filename).should be_true
|
12
|
-
doc = Nokogiri::Slop(File.open(filename))
|
13
|
-
@einfach = Swissreg::Vereinfachte.new(doc)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "short search must return info about trademark search" do
|
17
|
-
Swissreg::inputValue(@einfach.inputData, 'id_swissreg:mainContent:vivian').should == TrademarkSearch
|
18
|
-
end
|
19
|
-
|
20
|
-
it "short search must return hit information" do
|
21
|
-
@einfach.firstHit.should == 1
|
22
|
-
@einfach.nrHits.should == 9
|
23
|
-
end
|
24
|
-
|
25
|
-
it "short search must return details" do
|
26
|
-
@einfach.links2details.should_not be_nil
|
27
|
-
@einfach.links2details.size.should == 9
|
28
|
-
@einfach.links2details.index(901614).should_not be_nil
|
29
|
-
end
|
30
|
-
|
31
|
-
it "short search must return information about (sub-)pages" do
|
32
|
-
@einfach.pageNr.should == 1
|
33
|
-
@einfach.nrSubPages.should == 1
|
34
|
-
end
|
35
|
-
|
36
|
-
it "short search getPostDataForSubpage" do
|
37
|
-
@einfach.pageNr.should == 1
|
38
|
-
data = @einfach.getPostDataForSubpage(2)
|
39
|
-
data.should_not be_nil
|
40
|
-
Swissreg::inputValue(data, 'tmMainId').should == ""
|
41
|
-
Swissreg::inputValue(data, 'id_swissreg:mainContent:scroll_1').should == "idx2"
|
42
|
-
Swissreg::inputValue(data, 'id_swissreg:_idcl').should == 'id_swissreg:mainContent:scroll_1idx2'
|
43
|
-
end
|
44
|
-
|
45
|
-
it "short search getPostDataForDetail" do
|
46
|
-
@einfach.pageNr.should == 1
|
47
|
-
position = 3
|
48
|
-
id = 937439
|
49
|
-
data = @einfach.getPostDataForDetail(position, id)
|
50
|
-
data.should_not be_nil
|
51
|
-
Swissreg::inputValue(data, 'tmMainId').should == "#{id}"
|
52
|
-
Swissreg::inputValue(data, 'id_swissreg:mainContent:scroll_1').should == ''
|
53
|
-
Swissreg::inputValue(data, 'id_swissreg:_idcl').should == "id_swissreg:mainContent:data:#{position}:tm_no_detail:id_detail"
|
54
|
-
end
|
55
|
-
end
|
data/spec/simple_search.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
include Brand2csv
|
4
|
-
|
5
|
-
describe 'simple search with > 500 results' do
|
6
|
-
TrademarkSearch = 'TRADEMARK REGISTER SEARCH TIMES: QUERY=[530] SELECT=[1456] SERVER=[1991] DELEGATE=[2088] (HITS=[6349])'
|
7
|
-
|
8
|
-
before :each do
|
9
|
-
dataDir = File.expand_path(File.join(File.dirname(__FILE__), 'data'))
|
10
|
-
session = Swissreg.new("01.01.1990", 'Branding')
|
11
|
-
filename = "#{dataDir}/vereinfachte_1.html"
|
12
|
-
File.exists?(filename).should be_true
|
13
|
-
doc = Nokogiri::Slop(File.open(filename))
|
14
|
-
@einfach = Swissreg::Vereinfachte.new(doc)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "simple search must contain inputData with vivian" do
|
18
|
-
data = @einfach.inputData
|
19
|
-
data.class.should == Array
|
20
|
-
data.size.should == 9
|
21
|
-
end
|
22
|
-
|
23
|
-
it "simple search must return info about trademark search" do
|
24
|
-
Swissreg::inputValue(@einfach.inputData, 'id_swissreg:mainContent:vivian').should == TrademarkSearch
|
25
|
-
end
|
26
|
-
|
27
|
-
it "simple search must return hit information" do
|
28
|
-
@einfach.firstHit.should == 1
|
29
|
-
@einfach.nrHits.should == 6349
|
30
|
-
end
|
31
|
-
|
32
|
-
it "simple search must return details" do
|
33
|
-
@einfach.links2details.should_not be_nil
|
34
|
-
@einfach.links2details.size.should == 250
|
35
|
-
@einfach.links2details.index(940377).should_not be_nil
|
36
|
-
end
|
37
|
-
|
38
|
-
it "simple search must return information about (sub-)pages" do
|
39
|
-
@einfach.pageNr.should == 1
|
40
|
-
@einfach.nrSubPages.should == 26
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
3
|
-
$:.unshift File.dirname(__FILE__)
|
4
|
-
|
5
|
-
require 'bundler/setup'
|
6
|
-
Bundler.require
|
7
|
-
|
8
|
-
require 'rspec'
|
9
|
-
require "webmock/rspec"
|
10
|
-
|
11
|
-
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each { |f| require f }
|
12
|
-
|
13
|
-
require 'brand2csv'
|
14
|
-
begin
|
15
|
-
capture(:stdout) { load File.expand_path("../../bin/brand2csv", __FILE__) }
|
16
|
-
rescue LoadError
|
17
|
-
end
|
18
|
-
|
19
|
-
RSpec.configure do |config|
|
20
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
21
|
-
config.run_all_when_everything_filtered = true
|
22
|
-
config.filter_run :focus
|
23
|
-
config.filter_run_excluding :slow
|
24
|
-
#config.exclusion_filter = {:slow => true}
|
25
|
-
|
26
|
-
# Run specs in random order to surface order dependencies. If you find an
|
27
|
-
# order dependency and want to debug it, you can fix the order by providing
|
28
|
-
# the seed, which is printed after each run.
|
29
|
-
# --seed 1234
|
30
|
-
config.order = 'random'
|
31
|
-
|
32
|
-
# Helper
|
33
|
-
config.include(ServerMockHelper)
|
34
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'stringio'
|
4
|
-
require 'ostruct'
|
5
|
-
|
6
|
-
module Kernel
|
7
|
-
# for stdout/stderr
|
8
|
-
def capture(stream)
|
9
|
-
begin
|
10
|
-
stream = stream.to_s
|
11
|
-
eval "$#{stream} = StringIO.new"
|
12
|
-
yield
|
13
|
-
result = eval("$#{stream}").string
|
14
|
-
ensure
|
15
|
-
eval "$#{stream} = #{stream.upcase}"
|
16
|
-
end
|
17
|
-
result
|
18
|
-
end
|
19
|
-
|
20
|
-
alias :original_exit :exit
|
21
|
-
# for load executable file
|
22
|
-
def exit(status=false)
|
23
|
-
(status == 1) ? raise(LoadError) : original_exit
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
@@ -1,142 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
module ServerMockHelper
|
5
|
-
|
6
|
-
def setup_swissreg_ch_server(trademark, timespan, result_folder, trademark_ids)
|
7
|
-
# main
|
8
|
-
stub_html_url = "https://www.swissreg.ch/srclient/faces/jsp/start.jsp"
|
9
|
-
stub_response = File.read(File.expand_path("../../data/main.html", __FILE__))
|
10
|
-
stub_request(:get, stub_html_url).
|
11
|
-
with(
|
12
|
-
:headers => {
|
13
|
-
"Accept" => "*/*",
|
14
|
-
"Host" => "www.swissreg.ch",
|
15
|
-
}).
|
16
|
-
to_return(
|
17
|
-
:status => 200,
|
18
|
-
:headers => {"Content-Type" => 'text/html; charset=utf-8'},
|
19
|
-
:body => stub_response)
|
20
|
-
# erweiterte
|
21
|
-
stub_html_url = "https://www.swissreg.ch/srclient/faces/jsp/start.jsp"
|
22
|
-
stub_response = File.read(File.expand_path("../../data/erweiterte_suche.html", __FILE__))
|
23
|
-
stub_request(:post, stub_html_url).
|
24
|
-
with(
|
25
|
-
:headers => {
|
26
|
-
"Accept" => "*/*",
|
27
|
-
"Host" => "www.swissreg.ch",
|
28
|
-
},
|
29
|
-
:body => {
|
30
|
-
"autoScroll" => "",
|
31
|
-
"id_swissreg:_idcl" => "id_swissreg_sub_nav_ipiNavigation_item0",
|
32
|
-
"id_swissreg:_link_hidden_" => "",
|
33
|
-
"id_swissreg_SUBMIT" => "1",
|
34
|
-
"javax.faces.ViewState" =>"rO0ABXVyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAAN0AAExcHQADi9qc3Avc3RhcnQuanNw"
|
35
|
-
}).
|
36
|
-
to_return(
|
37
|
-
:status => 200,
|
38
|
-
:headers => {"Content-Type" => 'text/html; charset=utf-8'},
|
39
|
-
:body => stub_response)
|
40
|
-
# result page 1
|
41
|
-
stub_html_url = "https://www.swissreg.ch/srclient/faces/jsp/trademark/sr3.jsp"
|
42
|
-
stub_response = File.read(File.expand_path("../../data/#{result_folder}/first_results.html", __FILE__))
|
43
|
-
stub_request(:post, stub_html_url).
|
44
|
-
with(
|
45
|
-
:headers => {
|
46
|
-
"Accept" => "*/*",
|
47
|
-
"Host" => "www.swissreg.ch",
|
48
|
-
},
|
49
|
-
:body => {
|
50
|
-
"autoScroll" => "0,829",
|
51
|
-
"id_swissreg:_idcl" => "",
|
52
|
-
"id_swissreg:_link_hidden_" => "",
|
53
|
-
"id_swissreg:mainContent:id_cbxCountry" => "_ALL",
|
54
|
-
"id_swissreg:mainContent:id_cbxFormatChoice" => "1",
|
55
|
-
"id_swissreg:mainContent:id_cbxHitsPerPage" => "250",
|
56
|
-
"id_swissreg:mainContent:id_cbxTMColorClaim" => "_ALL",
|
57
|
-
"id_swissreg:mainContent:id_cbxTMForm" => "_ALL",
|
58
|
-
"id_swissreg:mainContent:id_cbxTMTypeGrp" => "_ALL",
|
59
|
-
"id_swissreg:mainContent:id_ckbTMChoice" => "tm_lbl_app_date",
|
60
|
-
"id_swissreg:mainContent:id_ckbTMPubReason" => "8",
|
61
|
-
"id_swissreg:mainContent:id_ckbTMState" => "3",
|
62
|
-
"id_swissreg:mainContent:id_txf_agent" => "",
|
63
|
-
"id_swissreg:mainContent:id_txf_appDate" => "#{timespan}",
|
64
|
-
"id_swissreg:mainContent:id_txf_app_no" => "",
|
65
|
-
"id_swissreg:mainContent:id_txf_applicant" => "",
|
66
|
-
"id_swissreg:mainContent:id_txf_expiryDate" => "",
|
67
|
-
"id_swissreg:mainContent:id_txf_licensee" => "",
|
68
|
-
"id_swissreg:mainContent:id_txf_nizza_class" => "",
|
69
|
-
"id_swissreg:mainContent:id_txf_pub_date" => "",
|
70
|
-
"id_swissreg:mainContent:id_txf_tm_no" => "",
|
71
|
-
"id_swissreg:mainContent:id_txf_tm_text" => "#{trademark}",
|
72
|
-
"id_swissreg:mainContent:sub_fieldset:id_submit" => "suchen",
|
73
|
-
"id_swissreg_SUBMIT" => "1",
|
74
|
-
"javax.faces.ViewState" => "rO0ABXVyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAAN0AAExcHQADi9qc3Avc3RhcnQuanNw"
|
75
|
-
}).
|
76
|
-
to_return(
|
77
|
-
:status => 200,
|
78
|
-
:headers => {"Content-Type" => 'text/html; charset=utf-8'},
|
79
|
-
:body => stub_response)
|
80
|
-
# result page 2
|
81
|
-
stub_html_url = "https://www.swissreg.ch/srclient/faces/jsp/trademark/sr3.jsp"
|
82
|
-
stub_response = File.read(File.expand_path("../../data/#{result_folder}/first_results.html", __FILE__))
|
83
|
-
stub_request(:post, stub_html_url).
|
84
|
-
with(
|
85
|
-
:headers => {
|
86
|
-
"Accept" => "*/*",
|
87
|
-
"Host" => "www.swissreg.ch",
|
88
|
-
},
|
89
|
-
:body => {
|
90
|
-
"autoScroll" => "",
|
91
|
-
"id_swissreg:_idcl" => "id_swissreg_sub_nav_ipiNavigation_item0_item3",
|
92
|
-
"id_swissreg:_link_hidden_" => "",
|
93
|
-
"id_swissreg:mainContent:id_cbxCountry" => "_ALL",
|
94
|
-
"id_swissreg:mainContent:id_cbxFormatChoice" => "1",
|
95
|
-
"id_swissreg:mainContent:id_cbxHitsPerPage" => "25",
|
96
|
-
"id_swissreg:mainContent:id_cbxTMColorClaim" => "_ALL",
|
97
|
-
"id_swissreg:mainContent:id_cbxTMForm" => "_ALL",
|
98
|
-
"id_swissreg:mainContent:id_cbxTMTypeGrp" => "_ALL",
|
99
|
-
"id_swissreg:mainContent:id_ckbTMChoice" => "tm_lbl_applicant",
|
100
|
-
"id_swissreg:mainContent:id_ckbTMPubReason" => "8",
|
101
|
-
"id_swissreg:mainContent:id_ckbTMState" => "3",
|
102
|
-
"id_swissreg:mainContent:id_txf_agent" => "",
|
103
|
-
"id_swissreg:mainContent:id_txf_appDate" => "",
|
104
|
-
"id_swissreg:mainContent:id_txf_app_no" => "",
|
105
|
-
"id_swissreg:mainContent:id_txf_applicant" => "",
|
106
|
-
"id_swissreg:mainContent:id_txf_expiryDate" => "",
|
107
|
-
"id_swissreg:mainContent:id_txf_licensee" => "",
|
108
|
-
"id_swissreg:mainContent:id_txf_nizza_class" => "",
|
109
|
-
"id_swissreg:mainContent:id_txf_pub_date" => "",
|
110
|
-
"id_swissreg:mainContent:id_txf_tm_no" => "",
|
111
|
-
"id_swissreg:mainContent:id_txf_tm_text" => "",
|
112
|
-
"id_swissreg_SUBMIT" => "1",
|
113
|
-
"javax.faces.ViewState" => "rO0ABXVyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAAN0AAEzcHQAFi9qc3AvdHJhZGVtYXJrL3NyMy5qc3A="
|
114
|
-
}).
|
115
|
-
to_return(
|
116
|
-
:status => 200,
|
117
|
-
:headers => {"Content-Type" => 'text/html; charset=utf-8'},
|
118
|
-
:body => stub_response)
|
119
|
-
|
120
|
-
counter = 0
|
121
|
-
trademark_ids.each{
|
122
|
-
|trademark_id|
|
123
|
-
counter += 1
|
124
|
-
# https://www.swissreg.ch/srclient/faces/jsp/trademark/sr300.jsp?language=de§ion=tm&id=57862/2013
|
125
|
-
stub_html_url = "https://www.swissreg.ch/srclient/faces/jsp/trademark/sr300.jsp?language=de§ion=tm&id=#{trademark_id}"
|
126
|
-
filename = File.expand_path("../../data/#{result_folder}/detail_#{sprintf('%05i',counter)}_#{trademark_id.sub('/','.')}.html", __FILE__)
|
127
|
-
stub_response = File.read(filename)
|
128
|
-
stub_request(:get, stub_html_url).
|
129
|
-
with(
|
130
|
-
:headers => {
|
131
|
-
"Accept" => "*/*",
|
132
|
-
"Host" => "www.swissreg.ch",
|
133
|
-
}).
|
134
|
-
to_return(
|
135
|
-
:status => 200,
|
136
|
-
:headers => {"Content-Type" => 'text/html; charset=utf-8'},
|
137
|
-
:body => stub_response)
|
138
|
-
|
139
|
-
}
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
data/spec/swissreg_spec.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
#encoding : utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe 'Get some simple example from swissreg' do
|
5
|
-
|
6
|
-
HasVertreterPos = 4
|
7
|
-
|
8
|
-
it "should get correct results from swissreg" do
|
9
|
-
marke = 'aspectra*'
|
10
|
-
timespan = '01.01.2012-31.12.2012'
|
11
|
-
setup_swissreg_ch_server(marke, timespan, 'aspectra', ["P-480296", "P-482236", "641074"])
|
12
|
-
results = nil
|
13
|
-
capture(:stdout) { results = Brand2csv::run(timespan, marke) }
|
14
|
-
results.should_not be_nil
|
15
|
-
results.size.should == 3
|
16
|
-
results[0].zeile_1.should == 'Aspectra AG'
|
17
|
-
results[0].plz.should == '8004'
|
18
|
-
results[0].ort.should == 'Zürich'
|
19
|
-
csv = "#{timespan}.csv"
|
20
|
-
csv_lines = IO.readlines(csv)
|
21
|
-
csv_lines[1].split(';')[HasVertreterPos].should == "Ja"
|
22
|
-
csv_lines[2].split(';')[HasVertreterPos].should == "Ja"
|
23
|
-
csv_lines[3].split(';')[HasVertreterPos].should == "Nein"
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should get correct results from swissreg when owner has two postal addresses" do
|
27
|
-
marke = 'Urner Wildheu'
|
28
|
-
timespan = '01.05.2013-30.06.2013'
|
29
|
-
setup_swissreg_ch_server(marke, timespan, 'urner_wildheu', ["57862/2013"])
|
30
|
-
results = nil
|
31
|
-
capture(:stdout) { results = Brand2csv::run(timespan, marke) }
|
32
|
-
results.should_not be_nil
|
33
|
-
results.size.should == 1
|
34
|
-
results[0].zeile_1.should == 'Philipp Arnold'
|
35
|
-
results[0].zeile_2.should == 'Seestrasse 37a'
|
36
|
-
results[0].plz.should == '6454'
|
37
|
-
results[0].ort.should == 'Flüelen'
|
38
|
-
csv = "#{timespan}.csv"
|
39
|
-
csv_lines = IO.readlines(csv)
|
40
|
-
csv_lines[1].split(';')[2].should == 'Philipp Arnold, Seestrasse 37a, 6454 Flüelen'
|
41
|
-
csv_lines[1].split(';')[HasVertreterPos].should == "Ja"
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
include Brand2csv
|
4
|
-
|
5
|
-
describe 'trademark number search' do
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
dataDir = File.expand_path(File.join(File.dirname(__FILE__), 'data'))
|
9
|
-
filename = "#{dataDir}/result_short.html"
|
10
|
-
File.exists?(filename).should be_true
|
11
|
-
@doc = Nokogiri::Slop(File.open(filename))
|
12
|
-
end
|
13
|
-
|
14
|
-
it "trademark number search must contain 9 numbers" do
|
15
|
-
numbers = Swissreg::getTrademarkNumbers(@doc)
|
16
|
-
numbers.should_not be_nil
|
17
|
-
numbers.size.should == 9
|
18
|
-
numbers.index('00127/2011').should_not be_nil
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
data/spec/utilities_spec.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
#encoding : utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
include Brand2csv
|
5
|
-
|
6
|
-
describe 'Tests for utility procedure' do
|
7
|
-
|
8
|
-
before :each do
|
9
|
-
@data = [
|
10
|
-
["autoScroll", ""],
|
11
|
-
["id_swissreg:mainContent:id_show_simple_view_hitlist", "Vereinfachte Trefferliste anzeigen"],
|
12
|
-
["id_swissreg_SUBMIT", "1"],
|
13
|
-
["id_swissreg:_idcl", "id_swissreg_sub_nav_ipiNavigation_item0"],
|
14
|
-
["id_swissreg:_link_hidden_", ""],
|
15
|
-
["javax.faces.ViewState", 'xzy' ],
|
16
|
-
]
|
17
|
-
end
|
18
|
-
|
19
|
-
it "inputValue should return nil for not existing key " do
|
20
|
-
Swissreg::inputValue(@data, 'xxx').should be_nil
|
21
|
-
end
|
22
|
-
|
23
|
-
it "inputValue should return correct value for existing key " do
|
24
|
-
Swissreg::inputValue(@data, 'autoScroll').should == ''
|
25
|
-
Swissreg::inputValue(@data, 'id_swissreg:mainContent:id_show_simple_view_hitlist').should == "Vereinfachte Trefferliste anzeigen"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "HitsPerPage must be 250" do
|
29
|
-
Swissreg::HitsPerPage.should == 250
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
describe 'Tests parsing adress line' do
|
35
|
-
|
36
|
-
it "must handle correctly Via San Salvatore, 2" do
|
37
|
-
full_address_line = 'Ideal Hobby Sagl, Via San Salvatore, 2, 6902 Paradiso'
|
38
|
-
number = 'for_debugging'
|
39
|
-
zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, full_address_line)
|
40
|
-
zeile_1.should == 'Ideal Hobby Sagl'
|
41
|
-
zeile_2.should == 'Via San Salvatore, 2'
|
42
|
-
zeile_3.should be_nil
|
43
|
-
plz.should == '6902'
|
44
|
-
ort.should == 'Paradiso'
|
45
|
-
end
|
46
|
-
|
47
|
-
it "must handle correctly 90, route de Frontenex" do
|
48
|
-
full_address_line = 'Olivier Karim Wasem, 90, route de Frontenex, 1208 Genève'
|
49
|
-
number = 'for_debugging'
|
50
|
-
zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, full_address_line)
|
51
|
-
zeile_1.should == 'Olivier Karim Wasem'
|
52
|
-
zeile_2.should == '90, route de Frontenex'
|
53
|
-
zeile_3.should be_nil
|
54
|
-
plz.should == '1208'
|
55
|
-
ort.should == 'Genève'
|
56
|
-
end
|
57
|
-
|
58
|
-
it "must handle ampersands correctly" do
|
59
|
-
full_address_line = 'Schweiz. Serum- & Impfinstitut, und Institut zur Erforschung der, Infektionskrankheiten, Rehhagstrasse 79, 3018 Bern'
|
60
|
-
number = 'for_debugging'
|
61
|
-
zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, full_address_line)
|
62
|
-
zeile_1.should == 'Schweiz. Serum- & Impfinstitut'
|
63
|
-
zeile_2.should == 'und Institut zur Erforschung der'
|
64
|
-
zeile_3.should == 'Infektionskrankheiten'
|
65
|
-
zeile_4.should == 'Rehhagstrasse 79'
|
66
|
-
zeile_5.should be_nil
|
67
|
-
plz.should == '3018'
|
68
|
-
ort.should == 'Bern'
|
69
|
-
end
|
70
|
-
|
71
|
-
it "must handle several postal addresses correctly" do
|
72
|
-
full_address_line = 'Philipp Arnold, Seestrasse 37a, 6454 Flüelen, , Peter Tresoldi, c/o Xitix GmbH, Rathausplatz 4, 6460 Altdorf'
|
73
|
-
number = 'for_debugging'
|
74
|
-
zeile_1, zeile_2, zeile_3, zeile_4, zeile_5, plz, ort = Swissreg::parseAddress(number, full_address_line)
|
75
|
-
zeile_1.should == 'Philipp Arnold'
|
76
|
-
zeile_2.should == 'Seestrasse 37a'
|
77
|
-
zeile_3.should be_nil
|
78
|
-
zeile_4.should be_nil
|
79
|
-
zeile_5.should be_nil
|
80
|
-
plz.should == '6454'
|
81
|
-
ort.should == 'Flüelen'
|
82
|
-
end
|
83
|
-
end
|