p2ruby 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ require 'rspec'
4
4
  describe 'RSpec' do
5
5
  it 'correctly outputs Windows Cyrillics' do
6
6
  pending 'RSpec does NOT output Windows Cyrillics, unless `chcp 1251` is run in console'
7
+
7
8
  Encoding.default_internal, Encoding.default_external = ['cp1251'] * 2
8
9
  lit = "������� �������������� ����� �������� ���� ������ ������ ������� �����"
9
10
  puts "Source encoding: #{__ENCODING__}"
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # encoding: CP1251
2
2
  require 'spec_helper'
3
3
 
4
4
  describe P2::Application, "singleton app object" do
@@ -15,7 +15,7 @@ describe P2::Application, "singleton app object" do
15
15
  its(:opts) { should have_key :ini }
16
16
  its(:ini) { should == CLIENT_INI }
17
17
  its(:ole) { should be_a WIN32OLE }
18
- its(:ParserType) { should == 2 } # � 1 � Plaza; � 2 � Plaza-II (default)
18
+ its(:ParserType) { should == 2 } # � 1 � Plaza; � 2 � Plaza-II (default)
19
19
 
20
20
  it 'is a Singleton' do
21
21
  a1 = P2::Application.instance
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # encoding: CP1251
2
2
  require 'spec_helper'
3
3
 
4
4
  def random_name
@@ -16,15 +16,9 @@ shared_examples_for 'new connection' do
16
16
 
17
17
  it 'raises on NodeName access' do
18
18
  expect { subject.NodeName }.to raise_error /Couldn't get MQ node name/
19
- # its(:NodeName) { should == "??" }
20
19
  end
21
20
 
22
21
  it 'is possible to set settable properties' do
23
- # Notes: �������� AppName, NodeName, Host, Port, Password � Timeout ������ ����
24
- # ������ �� ������� ������ ������ Connect. � ������ ��������� ������ ������� ���
25
- # ����, ����� ��������� �������� � ���� ���������� �������� ���������������� �����
26
- # ������� Disconnect � Connect. ��������� �������������� ������� (LoginStr) ������
27
- # ���� ������ �� ������� ������ ������ Login.
28
22
  subject.AppName ='REASSIGNED'
29
23
  subject.Host ='REASSIGNED_HOST'
30
24
  subject.Port =1313
@@ -159,40 +153,40 @@ describe P2::Connection do
159
153
 
160
154
  describe '#Connect2 '
161
155
  # Connect2 ( [in] BSTR connStr, [out, retval] ULONG* errClass);
162
- # �������� ���������� ���������� ���������� � ��������. ���������� � ������ Connect.
156
+ # �������� ���������� ���������� ���������� � ��������. ���������� � ������ Connect.
163
157
 
164
158
  describe '#ProcessMessage'
165
159
  # ProcessMessage ( [out] ULONG* cookie, [in] ULONG pollTimeout);
166
- # ����� � ��������� ���������, � ��� ����� � ��������������.
167
- # ���������
168
- # � pollTimeout � ������� � �������������, � ������� �������� ��������� ��������� ���������;
169
- # � cookie � ���������� ������������� ����������.
160
+ # ����� � ��������� ���������, � ��� ����� � ��������������.
161
+ # ���������
162
+ # � pollTimeout � ������� � �������������, � ������� �������� ��������� ��������� ���������;
163
+ # � cookie � ���������� ������������� ����������.
170
164
 
171
165
  describe '#ProcessMessage2'
172
166
  # ProcessMessage2 ( [in] ULONG pollTimeout, [out, retval] ULONG* cookie);
173
- # ����� � ��������� ���������. ������� � ���������� � ������ Connection.ProcessMessage,
174
- # ��� ��� ��� �� �������� � ������������������ ������ (JScript) �������� ���������
175
- # ������ ������� (cookie).
167
+ # ����� � ��������� ���������. ������� � ���������� � ������ Connection.ProcessMessage,
168
+ # ��� ��� ��� �� �������� � ������������������ ������ (JScript) �������� ���������
169
+ # ������ ������� (cookie).
176
170
 
177
171
  describe '#RegisterReceiver'
178
172
  # RegisterReceiver ( [in] IP2MessageReceiver* newReceiver, [out,retval] ULONG* cookie);
179
- # ����������� ����������.
180
- # ���������
181
- # � newReceiver � ��������� �� ��������� ��������� ������;
182
- # � cookie � ���������� ������������� ����������. ������������ ��� ����, ����� �����
183
- # ���� �������� ��������, � ����� ������ �� ���� � ������ Connection.ProcessMessage
184
- # ������������ ���������� ���������.
173
+ # ����������� ����������.
174
+ # ���������
175
+ # � newReceiver � ��������� �� ��������� ��������� ������;
176
+ # � cookie � ���������� ������������� ����������. ������������ ��� ����, ����� �����
177
+ # ���� �������� ��������, � ����� ������ �� ���� � ������ Connection.ProcessMessage
178
+ # ������������ ���������� ���������.
185
179
 
186
180
  describe '#UnRegisterReceiver'
187
181
  # UnRegisterReceiver ([in] ULONG cookie);
188
- # ������ ����������� ����������.
182
+ # ������ ����������� ����������.
189
183
 
190
184
  describe '#ResolveService' do
191
185
  # ResolveService ( [in] BSTR service, [out,retval] BSTR* address);
192
- # ��������� ������� ������ ���������� �� ����� �������, ������� ��� �������������.
193
- # ���������
194
- # � service � ��� �������;
195
- # � address � ������ ����� ����������.
186
+ # ��������� ������� ������ ���������� �� ����� �������, ������� ��� �������������.
187
+ # ���������
188
+ # � service � ��� �������;
189
+ # � address � ������ ����� ����������.
196
190
 
197
191
  before(:all) do
198
192
  @conn = P2::Connection.new :app_name => random_name,
@@ -205,20 +199,20 @@ describe P2::Connection do
205
199
  it 'returns full server address, given a service name' do
206
200
  @conn.ResolveService('FORTS_OPTINFO_REPL').should == "FINTER_FORTS3.inter_info"
207
201
  @conn.ResolveService('FORTS_FUTINFO_REPL').should == "FINTER_FORTS3.inter_info"
208
- @conn.ResolveService('FORTS_POS_REPL').should == "FINTER_FORTS3.inter_pos"
209
- @conn.ResolveService('FORTS_FUTCOMMON_REPL').should== "FINTER_FORTS3.inter_futcommon"
210
- @conn.ResolveService('FORTS_OPTCOMMON_REPL').should== "FINTER_FORTS3.inter_optcommon"
202
+ @conn.ResolveService('FORTS_POS_REPL').should == "FINTER_FORTS3.inter_infocore"
203
+ @conn.ResolveService('FORTS_FUTCOMMON_REPL').should == "FINTER_FORTS3.inter_futcommon"
204
+ @conn.ResolveService('FORTS_OPTCOMMON_REPL').should == "FINTER_FORTS3.inter_optcommon"
211
205
  @conn.ResolveService('FORTS_VOLAT_REPL').should == "FINTER_FORTS3.inter_vmv"
212
206
  @conn.ResolveService('FORTS_VM_REPL').should == "FINTER_FORTS3.inter_vmv"
213
207
  # Order placement:
214
- @conn.ResolveService("FORTS_SRV").should == "FINTER_FORTS3.Dispatcher"
208
+ @conn.ResolveService("FORTS_SRV").should == SERVER_NAME # ? changed
215
209
  end
216
210
  end
217
211
 
218
- # �������������� ����������� ����������. �������� ������� �� ������ Login ��������,
219
- # ��� ������������������ ���������� ���� ������� �� ������. ��� ����, ����� ������,
220
- # ������� �� ����������� ��������������, ������� �������� � ������������ �����������
221
- # � ��������� ����������.
212
+ # �������������� ����������� ����������. �������� ������� �� ������ Login ��������,
213
+ # ��� ������������������ ���������� ���� ������� �� ������. ��� ����, ����� ������,
214
+ # ������� �� ����������� ��������������, ������� �������� � ������������ �����������
215
+ # � ��������� ����������.
222
216
  context 'When router is authenticated via ini file' do
223
217
  end
224
218
  context 'When router is authenticated explicitely - via Login()' do
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # encoding: CP1251
2
2
  require 'spec_helper'
3
3
 
4
4
  def baseless_opts
@@ -13,6 +13,7 @@ describe P2::DataStream do
13
13
  @conn = P2::Connection.new :app_name => 'DSTest',
14
14
  :host => "127.0.0.1", :port => 4001
15
15
  @conn.Connect
16
+ sleep 0.5
16
17
  @conn.should be_connected
17
18
  @conn.should be_logged
18
19
  # Disconnected connection, for comparison
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # encoding: CP1251
2
2
  require 'spec_helper'
3
3
 
4
4
  describe P2::Library do
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # encoding: CP1251
2
2
  require 'spec_helper'
3
3
 
4
4
  describe P2::MessageFactory do
@@ -16,16 +16,10 @@ describe P2::MessageFactory do
16
16
  its(:ole) { should be_a WIN32OLE }
17
17
 
18
18
  describe '#Init()', 'is implicitly called by #new'
19
- # Init ( BSTR structFile, BSTR signFile); - ������������� �������.
20
- # ���������
21
- # � structFile � ini-����, ���������� ����� ���������.
22
- # � signFile � �� ������������.
19
+ # Init ( BSTR structFile, BSTR signFile);
23
20
 
24
21
  describe '#CreateMessageByName()', 'creates raw (unwrapped) OLE message objects' do
25
22
  # CreateMessageByName ( [in] BSTR msgName, [out,retval] IP2BLMessage** newMsg);
26
- # �������� ��������� �� �����.
27
- # ���������
28
- # � msgName � ��� ��������� (��� ������� ��).
29
23
  it 'creates raw OLE message objects according to scheme' do
30
24
  msg = subject.CreateMessageByName("FutAddOrder")
31
25
  msg.should be_a WIN32OLE # raw (unwrapped) OLE object!
@@ -3,17 +3,16 @@ require 'spec_helper'
3
3
 
4
4
  def get_message opts ={}
5
5
  @factory.message :name => opts[:name] ||"FutAddOrder",
6
- :dest_addr => opts[:dest_addr] || "FINTER_FORTS3.Dispatcher",
6
+ :dest_addr => opts[:dest_addr] || SERVER_NAME,
7
7
  :field => opts[:field] || {
8
8
  "P2_Category" => opts[:P2_Category] || "FORTS_MSG",
9
9
  :P2_Type => opts[:P2_Type] || 1,
10
- "isin" => opts[:isin] || "RTS-3.11",
11
- :price => opts[:price] || "186500",
10
+ "isin" => opts[:isin] || "RTS-3.12",
11
+ :price => opts[:price] || "155500",
12
12
  :amount => opts[:amount] || 1,
13
13
  "client_code" => opts[:client_code] || "001",
14
14
  "type" => opts[:type] || 1,
15
- "dir" => opts[:dir] || 1
16
- }
15
+ "dir" => opts[:dir] || 1}
17
16
  end
18
17
 
19
18
  describe P2::Message do
@@ -35,14 +34,14 @@ describe P2::Message do
35
34
  its(:opts) { should have_key :name }
36
35
  its(:ole) { should be_a WIN32OLE }
37
36
  its(:Name) { should == "" } # Why? Because there is no Message#Name= setter... :(
38
- its(:DestAddr) { should == "FINTER_FORTS3.Dispatcher" }
37
+ its(:DestAddr) { should == SERVER_NAME }
39
38
 
40
39
  context 'working with named property Field' do
41
40
  it 'initializes Field named properties correctly' do
42
41
  subject.Field["P2_Category"].should == "FORTS_MSG"
43
42
  subject.Field["P2_Type"].should == 1
44
- subject.Field['isin'].should == "RTS-3.11"
45
- subject.Field['price'].should == "186500"
43
+ subject.Field['isin'].should == "RTS-3.12"
44
+ subject.Field['price'].should == "155500"
46
45
  subject.Field['amount'].should == 1
47
46
  subject.Field['client_code'].should == "001"
48
47
  subject.Field['type'].should == 1
@@ -100,6 +99,7 @@ describe P2::Message do
100
99
  @conn = P2::Connection.new :app_name => 'DSTest',
101
100
  :host => "127.0.0.1", :port => 4001
102
101
  @conn.Connect
102
+ sleep 0.3
103
103
  @conn.should be_connected
104
104
  @conn.should be_logged
105
105
  # Disconnected connection, for comparison
@@ -145,6 +145,7 @@ describe P2::Message do
145
145
 
146
146
  it 'correctly outputs Windows Cyrillics' do
147
147
  pending 'freaking RSpec just does NOT output Cyrillics correctly, no matter what'
148
+
148
149
  Encoding.default_internal, Encoding.default_external = ['cp1251'] * 2
149
150
  lit = "������ �������������� ����� �������� ���� ������ ������ ������� �����"
150
151
  reply = @wrong_order.Send(@conn, 1000)
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # encoding: CP1251
2
2
  require 'spec_helper'
3
3
 
4
4
  # Impossible to instantiate Record directly (no PROGID), need to receive
@@ -9,6 +9,7 @@ def get_record
9
9
  @conn = P2::Connection.new :app_name => 'RecordTest',
10
10
  :host => "127.0.0.1", :port => 4001
11
11
  @conn.Connect
12
+ sleep 0.5
12
13
 
13
14
  @ds = P2::DataStream.new :stream_name => 'RTS_INDEX_REPL',
14
15
  :type => P2::RT_COMBINED_DYNAMIC
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # encoding: CP1251
2
2
  require 'spec_helper'
3
3
 
4
4
  describe P2::Router, "Driver for Router server app" do
@@ -22,7 +22,7 @@ describe P2::Router, "Driver for Router server app" do
22
22
 
23
23
  context "router initialized with :path => #{ROUTER_PATH}, :ini => #{ROUTER_INI}" do
24
24
  before(:all) { @router = P2::Router.new :dir => TEST_DIR, # To avoid file litter in BASE_DIR
25
- :path => ROUTER_PATH, :ini => ROUTER_INI }
25
+ :path => ROUTER_PATH, :ini => ROUTER_INI }
26
26
  subject { @router }
27
27
 
28
28
  it 'has P2 Router application/window launched' do
@@ -66,7 +66,9 @@ describe P2::TableSet do
66
66
  subject { P2::TableSet.new :ole => @ds.ole.TableSet }
67
67
  describe '#each' do
68
68
 
69
- it 'is' do
69
+ it 'is defined' do
70
+ pending 'Implementation error. See http://forum.rts.ru/viewtopic.asp?t=20380'
71
+
70
72
  p subject
71
73
  p subject.Count()
72
74
  p (subject.each.methods-Object.methods).sort
data/spec/p2ruby_spec.rb CHANGED
@@ -39,8 +39,8 @@ describe P2 do
39
39
  P2MQ_ERRORCLASS_IS_USELESS.should == 0x0001
40
40
  end
41
41
 
42
- it 'has error handler'do
43
- expect { error 'Blah'}.to raise_error P2::Error, /Blah/
42
+ it 'has error handler' do
43
+ expect { error 'Blah' }.to raise_error P2::Error, /Blah/
44
44
  end
45
45
  end
46
46
 
data/spec/spec_helper.rb CHANGED
@@ -19,13 +19,15 @@ TABLESET_INI = CONFIG_DIR + 'rts_index.ini'
19
19
  ROUTER_INI = CONFIG_DIR + 'client_router.ini'
20
20
  ROUTER_PATH = TEST_DIR + 'p2bin/P2MQRouter.exe'
21
21
  ROUTER_ARGS = "/ini:#{ROUTER_INI}"
22
- ROUTER_LOGIN = "FORTS_FZ36001_" # Login (incomplete) to RTS test server
23
- ROUTER_TITLE = Regexp.new('P2MQRouter - ') # + ROUTER_LOGIN
22
+ ROUTER_LOGIN = "FORTS_FZ36" # Login (incomplete) to RTS test server
23
+ ROUTER_TITLE = Regexp.new('P2MQRouter - ')
24
+ SERVER_NAME = 'FINTER_FORTS3.SQLProxy1' # @conn.ResolveService("FORTS_SRV")
24
25
 
25
26
  RSpec.configure do |config|
26
27
  # config.exclusion_filter = { :slow => true }
27
28
  # config.filter = { :focus => true }
28
29
  # config.include(UserExampleHelpers)
30
+ # config.fail_fast = true
29
31
  end
30
32
 
31
33
  def show_ole
@@ -35,13 +37,6 @@ def show_ole
35
37
  p subject.ole_methods.map { |m| "#{m.invoke_kind} #{m.name}(#{m.params.join ', '})" }.sort
36
38
  end
37
39
 
38
- # Closes any open Router application
39
- def stop_router
40
- while router_app = WinGui::App.find(:title => ROUTER_TITLE)
41
- router_app.exit(timeout=10)
42
- end
43
- end
44
-
45
40
  # Starts new Router application. Options:
46
41
  # :force - force Router to start, even if it's already running (default *false*)
47
42
  # :title - look for specific Router title
@@ -68,11 +63,22 @@ def restart_router
68
63
  start_router :force => true
69
64
  end
70
65
 
66
+ # Closes any open Router application
67
+ def stop_router
68
+ while router_app = WinGui::App.find(:title => ROUTER_TITLE)
69
+ router_app.exit(timeout=10)
70
+ end
71
+ end
72
+
71
73
  # Prepares test stand by copying P2 files to /tmp
72
74
  def prepare_test_stand
75
+ unless CONFIG_DIR.exist?
76
+ puts "Unable to rum specs - .ini not found. Put all your .ini files into #{CONFIG_DIR}!"
77
+ RSpec.wants_to_quit=true
78
+ end
79
+
73
80
  FileUtils.rm_rf TMP_DIR
74
81
  FileUtils.cp_r SOURCE_DIR, TEST_DIR #TMP_DIR
75
82
  end
76
83
 
77
84
  prepare_test_stand
78
- #FileUtils.cd "#{TEST_DIR}"
data/tasks/common.rake CHANGED
@@ -2,7 +2,7 @@
2
2
  #task 'gem:release' => 'test:run'
3
3
 
4
4
  task :notes do
5
- puts 'Output annotations (TBD)'
5
+ puts 'Output annotations (TBD)'
6
6
  end
7
7
 
8
8
  #Bundler not ready for prime time just yet
@@ -15,4 +15,4 @@ end
15
15
  # system "bundle install"
16
16
  # puts
17
17
  # end
18
- #end
18
+ #end
data/tasks/spec.rake CHANGED
@@ -6,7 +6,7 @@ namespace :spec do
6
6
  require 'rspec/core/rake_task'
7
7
 
8
8
  desc "Run all specs"
9
- RSpec::Core::RakeTask.new(:spec){|task|}
9
+ RSpec::Core::RakeTask.new(:spec) { |task|}
10
10
 
11
11
  desc "Run specs with RCov"
12
12
  RSpec::Core::RakeTask.new(:rcov) do |task|
data/tasks/version.rake CHANGED
@@ -35,7 +35,7 @@ class Version
35
35
  end
36
36
 
37
37
  def write(desc = nil)
38
- CLASS_NAME::VERSION_FILE.open('w') {|file| file.puts to_s }
38
+ CLASS_NAME::VERSION_FILE.open('w') { |file| file.puts to_s }
39
39
  (BASE_PATH + 'HISTORY').open('a') do |file|
40
40
  file.puts "\n== #{to_s} / #{Time.now.strftime '%Y-%m-%d'}\n"
41
41
  file.puts "\n* #{desc}\n" if desc
@@ -51,17 +51,17 @@ desc 'Set version: [x.y.z] - explicitly, [1/10/100] - bump major/minor/patch, [.
51
51
  task :version, [:command, :desc] do |t, args|
52
52
  version = Version.new(CLASS_NAME::VERSION)
53
53
  case args.command
54
- when /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/ # Set version explicitly
54
+ when /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/ # Set version explicitly
55
55
  version.update($1, $2, $3, $4)
56
- when /^\.(.*?)$/ # Set build
56
+ when /^\.(.*?)$/ # Set build
57
57
  version.build = $1
58
- when /^(\d{1})$/ # Bump patch
58
+ when /^(\d{1})$/ # Bump patch
59
59
  version.bump_patch $1
60
- when /^(\d{1})0$/ # Bump minor
60
+ when /^(\d{1})0$/ # Bump minor
61
61
  version.bump_minor $1
62
- when /^(\d{1})00$/ # Bump major
62
+ when /^(\d{1})00$/ # Bump major
63
63
  version.bump_major $1
64
- else # Unknown command, just display VERSION
64
+ else # Unknown command, just display VERSION
65
65
  puts "#{NAME} #{version}"
66
66
  next
67
67
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: p2ruby
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.1.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - arvicco
@@ -10,53 +10,31 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-19 00:00:00 +03:00
13
+ date: 2011-11-11 00:00:00 +03:00
14
14
  default_executable:
15
15
  dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: rspec
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
20
- none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: 2.0.0
25
- type: :development
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: cucumber
29
- prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
31
- none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
35
- version: "0"
36
- type: :development
37
- version_requirements: *id002
38
16
  - !ruby/object:Gem::Dependency
39
17
  name: bundler
40
18
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
19
+ requirement: &id001 !ruby/object:Gem::Requirement
42
20
  none: false
43
21
  requirements:
44
22
  - - ">="
45
23
  - !ruby/object:Gem::Version
46
24
  version: 1.0.0
47
25
  type: :runtime
48
- version_requirements: *id003
26
+ version_requirements: *id001
49
27
  - !ruby/object:Gem::Dependency
50
28
  name: win_gui
51
29
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
30
+ requirement: &id002 !ruby/object:Gem::Requirement
53
31
  none: false
54
32
  requirements:
55
33
  - - ">="
56
34
  - !ruby/object:Gem::Version
57
- version: 0.2.20
35
+ version: 0.2.21
58
36
  type: :runtime
59
- version_requirements: *id004
37
+ version_requirements: *id002
60
38
  description: Ruby bindings and wrapper classes for P2ClientGate
61
39
  email: arvitallian@gmail.com
62
40
  executables:
@@ -141,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
119
  requirements: []
142
120
 
143
121
  rubyforge_project:
144
- rubygems_version: 1.5.0
122
+ rubygems_version: 1.6.2
145
123
  signing_key:
146
124
  specification_version: 3
147
125
  summary: Ruby bindings for P2ClientGate