rspec-hive 0.1.0

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.
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+
3
+ describe RSpec::Hive::Connector do
4
+ describe '#start_connection' do
5
+ let(:tcli_connection) { double(RBHive::TCLIConnection) }
6
+ let(:connection_delegator) { double(RSpec::Hive::ConnectionDelegator) }
7
+ let(:host) { '127.0.0.1' }
8
+ let(:port) { '10000' }
9
+ let(:options_mock) { double('options') }
10
+ let(:hive_options) do
11
+ {'hive.exec.dynamic.partition' => 'true',
12
+ 'hive.exec.dynamic.partition.mode' => 'nonstrict',
13
+ 'hive.exec.max.dynamic.partitions.pernodexi' => '100000',
14
+ 'hive.exec.max.dynamic.partitions' => '100000',
15
+ 'mapred.child.java.opts' => '-Xmx2048m'}
16
+ end
17
+ let(:configuration) do
18
+ double(
19
+ RSpec::Hive::Configuration,
20
+ host: host,
21
+ port: port,
22
+ hive_options: hive_options
23
+ )
24
+ end
25
+
26
+ context 'when db_name is provided' do
27
+ let(:db_name) { 'test' }
28
+
29
+ before do
30
+ allow(subject).to receive(:connection_options) { options_mock }
31
+ expect(RBHive::TCLIConnection).to receive(:new).
32
+ with(host, port, options_mock) { tcli_connection }
33
+ expect(RSpec::Hive::ConnectionDelegator).to receive(:new).
34
+ with(tcli_connection, configuration) { connection_delegator }
35
+
36
+ expect(connection_delegator).to receive(:open).once
37
+ expect(connection_delegator).to receive(:open_session).once
38
+ expect(connection_delegator).to receive(:switch_database).
39
+ with(db_name).once
40
+ expect(connection_delegator).to receive(:execute).with('SET hive.exec.dynamic.partition=true;')
41
+ expect(connection_delegator).to receive(:execute).with('SET hive.exec.dynamic.partition.mode=nonstrict;')
42
+ expect(connection_delegator).to receive(:execute).with('SET hive.exec.max.dynamic.partitions.pernodexi=100000;')
43
+ expect(connection_delegator).to receive(:execute).with('SET hive.exec.max.dynamic.partitions=100000;')
44
+ expect(connection_delegator).to receive(:execute).with('SET mapred.child.java.opts=-Xmx2048m;')
45
+ allow(configuration).to receive_message_chain(:logger, :info)
46
+ end
47
+
48
+ subject { described_class.new(configuration) }
49
+
50
+ it do
51
+ expect(subject.start_connection(db_name)).to equal(connection_delegator)
52
+ end
53
+ end
54
+
55
+ context 'when db_name is not provided' do
56
+ let(:db_random_name) { 'rand123' }
57
+
58
+ before do
59
+ allow(subject).to receive(:connection_options) { options_mock }
60
+ expect(RSpec::Hive::DbName).to receive(:random_name) { db_random_name }
61
+ expect(RBHive::TCLIConnection).to receive(:new).
62
+ with(host, port, options_mock) { tcli_connection }
63
+ expect(RSpec::Hive::ConnectionDelegator).to receive(:new).
64
+ with(tcli_connection, configuration) { connection_delegator }
65
+
66
+ expect(connection_delegator).to receive(:open).once
67
+ expect(connection_delegator).to receive(:open_session).once
68
+ expect(connection_delegator).to receive(:switch_database).
69
+ with(db_random_name).once
70
+ expect(connection_delegator).to receive(:execute).with('SET hive.exec.dynamic.partition=true;')
71
+ expect(connection_delegator).to receive(:execute).with('SET hive.exec.dynamic.partition.mode=nonstrict;')
72
+ expect(connection_delegator).to receive(:execute).with('SET hive.exec.max.dynamic.partitions.pernodexi=100000;')
73
+ expect(connection_delegator).to receive(:execute).with('SET hive.exec.max.dynamic.partitions=100000;')
74
+ expect(connection_delegator).to receive(:execute).with('SET mapred.child.java.opts=-Xmx2048m;')
75
+ allow(configuration).to receive_message_chain(:logger, :info)
76
+ end
77
+
78
+ subject { described_class.new(configuration) }
79
+
80
+ it do
81
+ expect(subject.start_connection).to equal(connection_delegator)
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe RSpec::Hive::DbName do
4
+ describe '.random_name' do
5
+ subject { described_class.random_name }
6
+
7
+ before do
8
+ allow(described_class).to receive(:timestamp) { 'timestamp' }
9
+ allow(described_class).to receive(:random_key) { 'randomKey' }
10
+ end
11
+
12
+ it { is_expected.to eq('timestamp_randomKey') }
13
+ end
14
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe RSpec::Hive do
4
+ describe 'configure' do
5
+ let(:expected_host) { '127.0.0.1' }
6
+ let(:expected_port) { '10000' }
7
+ let(:expected_host_shared_directory_path) do
8
+ '/Users/Shared/tmp/spec-files'
9
+ end
10
+ let(:expected_docker_shared_directory_path) { '/tmp/spec-tmp-files' }
11
+
12
+ context 'when file name is provided' do
13
+ let(:file_name) { 'test.yaml' }
14
+ let(:configuration_mock) do
15
+ double(
16
+ described_class::Configuration,
17
+ host: expected_host,
18
+ port: expected_port,
19
+ host_shared_directory_path: expected_host_shared_directory_path,
20
+ docker_shared_directory_path: expected_docker_shared_directory_path
21
+ )
22
+ end
23
+
24
+ before do
25
+ expect(described_class).to receive(:new_configuration).
26
+ with(file_name) { configuration_mock }
27
+ end
28
+
29
+ subject { described_class.configure(file_name) }
30
+
31
+ its(:host) { is_expected.to eq(expected_host) }
32
+ its(:port) { is_expected.to eq(expected_port) }
33
+ its(:host_shared_directory_path) do
34
+ is_expected.to eq(expected_host_shared_directory_path)
35
+ end
36
+ its(:docker_shared_directory_path) do
37
+ is_expected.to eq(expected_docker_shared_directory_path)
38
+ end
39
+ end
40
+
41
+ context 'when block is given' do
42
+ subject do
43
+ described_class.configure do |config|
44
+ config.host = expected_host
45
+ config.port = expected_port
46
+ config.host_shared_directory_path =
47
+ expected_host_shared_directory_path
48
+ config.docker_shared_directory_path =
49
+ expected_docker_shared_directory_path
50
+ end
51
+ end
52
+
53
+ its(:host) { is_expected.to eq(expected_host) }
54
+ its(:port) { is_expected.to eq(expected_port) }
55
+ its(:host_shared_directory_path) do
56
+ is_expected.to eq(expected_host_shared_directory_path)
57
+ end
58
+ its(:docker_shared_directory_path) do
59
+ is_expected.to eq(expected_docker_shared_directory_path)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,104 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+
20
+ if ENV['COVERAGE']
21
+ require 'codeclimate-test-reporter'
22
+ CodeClimate::TestReporter.start
23
+ end
24
+
25
+ RSpec.configure do |config|
26
+ require 'rspec/hive'
27
+ require 'rspec/its'
28
+ # rspec-expectations config goes here. You can use an alternate
29
+ # assertion/expectation library such as wrong or the stdlib/minitest
30
+ # assertions if you prefer.
31
+ config.expect_with :rspec do |expectations|
32
+ # This option will default to `true` in RSpec 4. It makes the `description`
33
+ # and `failure_message` of custom matchers include text for helper methods
34
+ # defined using `chain`, e.g.:
35
+ # be_bigger_than(2).and_smaller_than(4).description
36
+ # # => "be bigger than 2 and smaller than 4"
37
+ # ...rather than:
38
+ # # => "be bigger than 2"
39
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
40
+ end
41
+
42
+ # rspec-mocks config goes here. You can use an alternate test double
43
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
44
+ config.mock_with :rspec do |mocks|
45
+ # Prevents you from mocking or stubbing a method that does not exist on
46
+ # a real object. This is generally recommended, and will default to
47
+ # `true` in RSpec 4.
48
+ mocks.verify_partial_doubles = true
49
+ end
50
+
51
+ # The settings below are suggested to provide a good initial experience
52
+ # with RSpec, but feel free to customize to your heart's content.
53
+ =begin
54
+ # These two settings work together to allow you to limit a spec run
55
+ # to individual examples or groups you care about by tagging them with
56
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
57
+ # get run.
58
+ config.filter_run :focus
59
+ config.run_all_when_everything_filtered = true
60
+
61
+ # Allows RSpec to persist some state between runs in order to support
62
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
63
+ # you configure your source control system to ignore this file.
64
+ config.example_status_persistence_file_path = "spec/examples.txt"
65
+
66
+ # Limits the available syntax to the non-monkey patched syntax that is
67
+ # recommended. For more details, see:
68
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
69
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
70
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
71
+ config.disable_monkey_patching!
72
+
73
+ # This setting enables warnings. It's recommended, but in some cases may
74
+ # be too noisy due to issues in dependencies.
75
+ config.warnings = true
76
+
77
+ # Many RSpec users commonly either run the entire suite or an individual
78
+ # file, and it's useful to allow more verbose output when running an
79
+ # individual spec file.
80
+ if config.files_to_run.one?
81
+ # Use the documentation formatter for detailed output,
82
+ # unless a formatter has already been configured
83
+ # (e.g. via a command-line flag).
84
+ config.default_formatter = 'doc'
85
+ end
86
+
87
+ # Print the 10 slowest examples and example groups at the
88
+ # end of the spec run, to help surface which specs are running
89
+ # particularly slow.
90
+ config.profile_examples = 10
91
+
92
+ # Run specs in random order to surface order dependencies. If you find an
93
+ # order dependency and want to debug it, you can fix the order by providing
94
+ # the seed, which is printed after each run.
95
+ # --seed 1234
96
+ config.order = :random
97
+
98
+ # Seed global randomization in this process using the `--seed` CLI option.
99
+ # Setting this allows you to use `--seed` to deterministically reproduce
100
+ # test failures related to randomization by passing the same `--seed` value
101
+ # as the one that triggered the failure.
102
+ Kernel.srand config.seed
103
+ =end
104
+ end
metadata ADDED
@@ -0,0 +1,284 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-hive
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Wojtek Mielczarek
8
+ - Mikołaj Nowak
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-04-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '10.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '10.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: colorize
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0.7'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.7'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.7'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.7'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '3.4'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3.4'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec-its
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '1.2'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '1.2'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rbhive
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: 0.6.0
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 0.6.0
98
+ - !ruby/object:Gem::Dependency
99
+ name: rubocop
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '0.34'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '0.34'
112
+ - !ruby/object:Gem::Dependency
113
+ name: rubocop-rspec
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '1.3'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '1.3'
126
+ - !ruby/object:Gem::Dependency
127
+ name: guard
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '2.6'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '2.6'
140
+ - !ruby/object:Gem::Dependency
141
+ name: guard-rspec
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '4.3'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '4.3'
154
+ - !ruby/object:Gem::Dependency
155
+ name: guard-rubocop
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - "~>"
159
+ - !ruby/object:Gem::Version
160
+ version: '1.2'
161
+ type: :development
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '1.2'
168
+ - !ruby/object:Gem::Dependency
169
+ name: codeclimate-test-reporter
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - "~>"
173
+ - !ruby/object:Gem::Version
174
+ version: '0.4'
175
+ type: :development
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - "~>"
180
+ - !ruby/object:Gem::Version
181
+ version: '0.4'
182
+ - !ruby/object:Gem::Dependency
183
+ name: pry
184
+ requirement: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ type: :development
190
+ prerelease: false
191
+ version_requirements: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ - !ruby/object:Gem::Dependency
197
+ name: pry-byebug
198
+ requirement: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ type: :development
204
+ prerelease: false
205
+ version_requirements: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ description: |-
211
+ RSpecHive let you test your hive queries
212
+ connecting to hive instance installed on docker
213
+ email:
214
+ - wojtek.mielczarek@u2i.com
215
+ - mikolaj.nowak@u2i.com
216
+ executables: []
217
+ extensions: []
218
+ extra_rdoc_files: []
219
+ files:
220
+ - ".codeclimate.yml"
221
+ - ".gitignore"
222
+ - ".rspec"
223
+ - ".rubocop.yml"
224
+ - ".rubocop_u2i.yml"
225
+ - ".ruby-version"
226
+ - Gemfile
227
+ - Gemfile.lock
228
+ - Guardfile
229
+ - LICENSE.txt
230
+ - README.md
231
+ - Rakefile
232
+ - docker/Dockerfile
233
+ - examples/config_helper.rb
234
+ - examples/hive_tests_config.yml.example
235
+ - examples/query.rb
236
+ - examples/query_spec.rb
237
+ - lib/rspec/hive.rb
238
+ - lib/rspec/hive/configuration.rb
239
+ - lib/rspec/hive/connection_delegator.rb
240
+ - lib/rspec/hive/connector.rb
241
+ - lib/rspec/hive/db_name.rb
242
+ - lib/rspec/hive/version.rb
243
+ - lib/rspec/hive/with_hive_connection.rb
244
+ - lib/rspec/rake_tasks/docker.rake
245
+ - lib/rspec/rake_tasks/railtie.rb
246
+ - rspec-hive.gemspec
247
+ - spec/lib/rspec/hive/configuration_spec.rb
248
+ - spec/lib/rspec/hive/connection_delegator_spec.rb
249
+ - spec/lib/rspec/hive/connector_spec.rb
250
+ - spec/lib/rspec/hive/db_name_spec.rb
251
+ - spec/lib/rspec/hive_spec.rb
252
+ - spec/spec_helper.rb
253
+ homepage: https://github.com/u2i/ns-rspec-hive
254
+ licenses:
255
+ - MIT
256
+ metadata: {}
257
+ post_install_message:
258
+ rdoc_options: []
259
+ require_paths:
260
+ - lib
261
+ required_ruby_version: !ruby/object:Gem::Requirement
262
+ requirements:
263
+ - - ">="
264
+ - !ruby/object:Gem::Version
265
+ version: '0'
266
+ required_rubygems_version: !ruby/object:Gem::Requirement
267
+ requirements:
268
+ - - ">="
269
+ - !ruby/object:Gem::Version
270
+ version: '0'
271
+ requirements: []
272
+ rubyforge_project:
273
+ rubygems_version: 2.4.3
274
+ signing_key:
275
+ specification_version: 4
276
+ summary: RSpec addition to test hive queries
277
+ test_files:
278
+ - spec/lib/rspec/hive/configuration_spec.rb
279
+ - spec/lib/rspec/hive/connection_delegator_spec.rb
280
+ - spec/lib/rspec/hive/connector_spec.rb
281
+ - spec/lib/rspec/hive/db_name_spec.rb
282
+ - spec/lib/rspec/hive_spec.rb
283
+ - spec/spec_helper.rb
284
+ has_rdoc: