ass_tests 1.0.0.alpha → 1.2.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: acb1038346a0074cd225e0b28448550f6dd491dd
4
- data.tar.gz: 841ebc7201ba1cb6f59843e65001c4fe0d92d9e3
3
+ metadata.gz: 5759b3b984cf4cc39328bc1000524c7219abbb17
4
+ data.tar.gz: d1b60660362f009f702cc52b20e412b10430a8d7
5
5
  SHA512:
6
- metadata.gz: d2aef05c2225fca10ef9d90350516820d7d6d7fc11e77e8132e14610fee9535da19cbe11e38d0eb854837131dbdd9b2ab09d80f4e6d9336aec274b653d584899
7
- data.tar.gz: 0bbcaf34554b63eb3ac1570fca81213102dff28f28158af8a73303eabe49df4f31177e1b84607cc8648806755cb11e37529319e37445e79a4262e44196889147
6
+ metadata.gz: 1dbc3df6a7bc7f6fb6380c63fe4a838fea03de32e799af5af3684f6a462ce428f2110cc28abc4490b251039c52f164cc0f9ddb5e7c067134bbe98a149c0990e1
7
+ data.tar.gz: ff6c2770137227159bef588d836b84e42b144d30e3ca7c9f3942cd477ec6b712120de92c87bbb57b07a20cfd4d71a0247f94fe3ef6669504a9a6d23374364fcc
data/README.md CHANGED
@@ -19,7 +19,8 @@ It make possible to write tests for 1C:Enterprise on Ruby easy.
19
19
  - Works only in Windows or Cygwin.
20
20
  - Not available methods ```eval``` and ```execute``` of 1C "Global context"
21
21
  - Unpossible attach to 1C debugger.
22
- - Now support ```Minitest::Test``` only
22
+ - Now support ```Minitest``` only
23
+ - `AssTests::Assertions` works for external or thick application ole connectors only
23
24
  - Other unknown now :(
24
25
 
25
26
  ## Features
@@ -28,10 +29,7 @@ It make possible to write tests for 1C:Enterprise on Ruby easy.
28
29
  - Support to describe many different 1C Information bases.
29
30
  - Support describe exists Information bases as ```external```. Such Information bases is persistent and can't be build or remove.
30
31
  - Automatically build described Information base on demand.
31
- - Automatically rebuild Information base on demand.
32
- - Passes required instance of class `InfoBase` into tests for connect to Information base for testing.
33
- - Hold pool of opened connection with 1C information bases for decrease costs on wakeup 1C application.
34
- - Automatically close all opened connection after all tests executed.
32
+ - Automatically close all opened connection after all tests executed. It provides `AssOle::Runtimes`
35
33
  - Provides assertions for tests 1C values in Ruby side
36
34
  - Provides features for testing of 1C externals like as ExternalDataProcessor and ExternalReport
37
35
  - Provides features for fill data in infobases under test.
@@ -59,67 +57,76 @@ Or install it yourself as:
59
57
 
60
58
  - ```test_helper.rb```:
61
59
  ```ruby
62
- require 'ass_tests/autorun'
63
- require 'ass_tests/info_bases'
64
-
65
60
  # Describe empty InfoBase
61
+
62
+ require 'ass_tests/minitest'
66
63
  AssTests::InfoBases.describe do
67
64
  file :empty_ib
68
65
  end
66
+
67
+ module ExampleTest
68
+ # Describe runtimes
69
+ module Runtimes
70
+ module Ext
71
+ is_ole_runtime :external
72
+ run AssTests::InfoBases[:empty_ib]
73
+ end
74
+
75
+ module ThickApp
76
+ is_ole_runtime :thick
77
+ run AssTests::InfoBases[:empty_ib]
78
+ end
79
+ end
80
+ end
81
+
82
+ # After all was prepared loads autorun
83
+ require 'ass_tests/minitest/autorun'
69
84
  ```
70
- - ```small_test.rb```:
85
+ - ```exmple_test.rb```:
71
86
  ```ruby
72
-
73
- class SmalTest < AssTests::MiniTest::Test
74
- # Demands described :empty_ib information base
75
- use :empty_ib
76
- # Declare to run :empty_ib in :context of :thick application
77
- # and we ask keep alive connection while tests executing
78
- # Default :keep_alive => true.
79
- # If set :keep_alive => false for :thick or :thin context
80
- # wakeup connection will be very slowly for big applications
81
- context :thick, :keep_alive => true
82
- # If we want login in information base as some user we say:
83
- # login :as => 'user', :with => 'password'
84
- # In this example we use empty information base without any users
85
-
86
- # If we say :keep_alive => true and in tests we want to manipulate
87
- # with data, each test mast be wrapped in 1C transaction
88
- # for tests isolation.
89
- # In this example we aren't manipulate with data
90
- # Warning! 1C transaction not define for :thin context,
91
- # for :thin context require patch information base application
92
- def setup
93
- ole.BeginTransaction
87
+ module ExampleTest
88
+ describe 'Spec examle' do
89
+ like_ole_runtime Runtimes::Ext
90
+ include AssTests::Assertions
91
+
92
+ it 'Call runtime #metaData' do
93
+ _assert_equal metaData, metaData
94
+ end
94
95
  end
95
96
 
96
- # Transaction mast be rollback for tests isolation
97
- def teardown
98
- ole.RollbackTransaction
97
+ class TestExample < Minitest::Test
98
+ like_ole_runtime Runtimes::Ext
99
+ include AssTests::Assertions
100
+
101
+ def test_runtime_metaData
102
+ _assert_equal metaData, metaData
103
+ end
99
104
  end
100
105
 
101
- puts infobase.name # => "empty_ib"
102
- puts infobase.exists? # => "true"
103
- puts ole.__opened__? # => "false"
104
- puts ole.class # => "AssLauncher::Enterprise::Ole::ThickApplication"
106
+ # Shared tests
107
+ module SharedTests
108
+ def test_runtime_metaData
109
+ _assert_equal metaData, metaData
110
+ end
111
+ end
105
112
 
106
- def test_hello_world
107
- puts ole.__opened__? # => "true"
108
- a = ole.newObject 'array'
109
- a.add 'Hello world'
110
- assert_equal 'Hello world', ole.string(a.get(0))
113
+ class TestInExternalRuntime < Minitest::Test
114
+ like_ole_runtime Runtimes::Ext
115
+ include AssTests::Assertions
116
+ include SharedTests
111
117
  end
112
118
 
113
- def test_other
114
- assert ole.__opened__?
119
+ class TestInThickAppRuntime < Minitest::Test
120
+ like_ole_runtime Runtimes::ThickApp
121
+ include AssTests::Assertions
122
+ include SharedTests
115
123
  end
116
124
  end
125
+
117
126
  ```
118
127
  - also you can write native ```Minitest::Test``` for testing
119
128
  other things like this ```ordinary_test.rb```:
120
129
  ```ruby
121
- # Also you can write native Minitest::Test
122
-
123
130
  class OrdinaryTest < Minitest::Test
124
131
  def test_fail
125
132
  assert false
data/ass_tests.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "ass_launcher"
21
+ spec.add_dependency "ass_ole"
22
22
  spec.add_dependency "ass_maintainer-info_base"
23
23
  spec.add_dependency "minitest", "> 5"
24
24
  spec.add_dependency "minitest-hooks"
data/lib/ass_tests.rb CHANGED
@@ -1,16 +1,12 @@
1
1
  module AssTests
2
2
  class ConfigureError < StandardError; end
3
+ require 'ass_ole'
3
4
  require 'ass_tests/version'
4
5
  require 'ass_tests/config'
5
6
  require 'ass_tests/fixt'
6
7
  require 'ass_tests/externals'
7
8
  require 'ass_tests/info_bases'
9
+ require 'ass_tests/core_patch/win32ole_runtime_error'
10
+ require 'ass_tests/core_patch/no_method_error'
8
11
  end
9
12
 
10
- class WIN32OLERuntimeError
11
- old_message = instance_method(:message)
12
- define_method(:message) do
13
- old_message.bind(self).call.force_encoding('ASCII-8BIT')\
14
- .split('HRESULT')[0].force_encoding('UTF-8').strip
15
- end
16
- end
@@ -0,0 +1,5 @@
1
+ require 'ass_tests/core_patch/standard_error'
2
+ # Monkey patch for encoding error message
3
+ class NoMethodError
4
+ __patch_message__
5
+ end
@@ -0,0 +1,11 @@
1
+ # Monkey patch for encoding error message
2
+ class StandardError
3
+ def self.__patch_message__
4
+ old_message = instance_method(:message)
5
+ define_method(:message) do
6
+ old_message.bind(self).call.force_encoding('ASCII-8BIT')\
7
+ .split(%r{(HRESULT error code:\dx\d+)}i)[0 .. 1].join
8
+ .force_encoding('UTF-8').strip
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ require 'ass_tests/core_patch/standard_error'
2
+ # Monkey patch for encoding error message
3
+ class WIN32OLERuntimeError
4
+ __patch_message__
5
+ end
@@ -3,5 +3,7 @@ module AssTests
3
3
  module Minitests
4
4
  require 'minitest'
5
5
  require 'ass_tests/minitest/assertions'
6
+ require 'ass_tests/core_patch/win32ole_runtime_error'
7
+ require 'ass_tests/core_patch/no_method_error'
6
8
  end
7
9
  end
@@ -13,9 +13,14 @@ end
13
13
 
14
14
  module AssTests
15
15
  module Assertions
16
- # TODO: It works bad
16
+ UNKNOWN_XML_TYPE = 'UNKNOWN_XML_TYPE'
17
+
18
+ GOOD_OLE_CONNECTORS = [
19
+ AssLauncher::Enterprise::Ole::IbConnection,
20
+ AssLauncher::Enterprise::Ole::ThickApplication
21
+ ]
17
22
  def _assert_xml_type(exp, obj, mess = nil)
18
- act = ole_connector.xmlTypeOf(obj).typeName
23
+ act = xml_type_get(obj)
19
24
  mess = message(mess) do
20
25
  "Expected #{exp} xml type but #{act} given"
21
26
  end
@@ -44,13 +49,40 @@ module AssTests
44
49
  return obj unless obj.is_a? WIN32OLE
45
50
  return obj.__real_obj__ if obj.__ruby__?
46
51
  # TODO: make comparsation ruby object from internal Ass string
52
+
53
+ return to_comparable_srv_context(obj) if\
54
+ GOOD_OLE_CONNECTORS.include? ole_connector.class
55
+ to_comparable_client_context(obj)
56
+ end
57
+ private :to_comparable
58
+
59
+ def to_comparable_client_context(obj)
60
+ fail 'You should define own method #to_comparable_client_context'\
61
+ ' and returns #new_comparable Hash'
62
+ end
63
+ private :to_comparable_client_context
64
+
65
+ def to_comparable_srv_context(obj)
66
+ new_comparable ole_connector.sTring(obj),
67
+ xml_type_get(obj),
68
+ ole_connector.ValueToStringInternal(obj)
69
+ end
70
+ private :to_comparable_srv_context
71
+
72
+ def new_comparable(as_string, xml_type, as_string_internal)
47
73
  r = {}
48
- r[:as_string] = ole_connector.sTring obj
49
- r[:xml_type] = ole_connector.xmlTypeOf(obj).typeName
50
- r[:as_string_internal] = ole_connector.ValueToStringInternal obj
74
+ r[:as_string] = as_string
75
+ r[:xml_type] = xml_type
76
+ r[:as_string_internal] = as_string_internal
51
77
  r
52
78
  end
53
- private :to_comparable
79
+ private :new_comparable
80
+
81
+ def xml_type_get(obj)
82
+ return UNKNOWN_XML_TYPE if ole_connector.xmlTypeOf(obj).nil?
83
+ ole_connector.xmlTypeOf(obj).typeName
84
+ end
85
+ private :xml_type_get
54
86
 
55
87
  def not_comparable?(exp, act)
56
88
  is_ruby?(exp) ^ is_ruby?(act)
@@ -64,10 +96,16 @@ module AssTests
64
96
 
65
97
  def fail_not_comparable(exp, act)
66
98
  fail ArgumentError,
67
- "Not comparable types `#{exp.__real_object__.class}'"\
68
- " and `#{act.__real_object__.class}'"
99
+ "Not comparable types `#{not_comparable_class exp}'"\
100
+ " and `#{not_comparable_class act}'"
69
101
  end
70
102
  private :fail_not_comparable
103
+
104
+ def not_comparable_class(obj)
105
+ return obj.__real_obj__.class if obj.respond_to? :__real_obj__
106
+ obj.class
107
+ end
108
+ private :not_comparable_class
71
109
  end
72
110
  end
73
111
 
@@ -1,3 +1,3 @@
1
1
  module AssTests
2
- VERSION = "1.0.0.alpha"
2
+ VERSION = "1.2.0.alpha"
3
3
  end
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ass_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha
4
+ version: 1.2.0.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Vlasov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-09 00:00:00.000000000 Z
11
+ date: 2016-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: ass_launcher
14
+ name: ass_ole
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ass_maintainer-info_base
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>'
45
+ - - ">"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '5'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>'
52
+ - - ">"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest-hooks
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.10'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.10'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '10.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '10.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: simplecov
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: pry
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: mocha
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: It make possible to write tests for 1C:Enterprise on Ruby easy. Access
@@ -144,9 +144,9 @@ executables: []
144
144
  extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
- - .gitignore
148
- - .simplecov
149
- - .travis.yml
147
+ - ".gitignore"
148
+ - ".simplecov"
149
+ - ".travis.yml"
150
150
  - Gemfile
151
151
  - README.md
152
152
  - Rakefile
@@ -157,6 +157,9 @@ files:
157
157
  - lib/ass_tests.rb
158
158
  - lib/ass_tests/ass_dummy.rb
159
159
  - lib/ass_tests/config.rb
160
+ - lib/ass_tests/core_patch/no_method_error.rb
161
+ - lib/ass_tests/core_patch/standard_error.rb
162
+ - lib/ass_tests/core_patch/win32ole_runtime_error.rb
160
163
  - lib/ass_tests/externals.rb
161
164
  - lib/ass_tests/fixt.rb
162
165
  - lib/ass_tests/info_bases.rb
@@ -175,17 +178,17 @@ require_paths:
175
178
  - lib
176
179
  required_ruby_version: !ruby/object:Gem::Requirement
177
180
  requirements:
178
- - - '>='
181
+ - - ">="
179
182
  - !ruby/object:Gem::Version
180
183
  version: '0'
181
184
  required_rubygems_version: !ruby/object:Gem::Requirement
182
185
  requirements:
183
- - - '>'
186
+ - - ">"
184
187
  - !ruby/object:Gem::Version
185
188
  version: 1.3.1
186
189
  requirements: []
187
190
  rubyforge_project:
188
- rubygems_version: 2.0.14
191
+ rubygems_version: 2.4.7
189
192
  signing_key:
190
193
  specification_version: 4
191
194
  summary: Framework for unit testing code written on 1C:Enterprise embedded programming