jredshift 0.0.3 → 0.0.5

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: db12692389bfe5cda6bc08190d017ee7f33cdefe
4
- data.tar.gz: bbf2bdcec247bd3b00917833efe587370f1d2b87
3
+ metadata.gz: a3d080c427b01705d8b15ee57188d4c8f94bea52
4
+ data.tar.gz: a9ffb5029b984c76fbb2981ec89eb1fd2d1442df
5
5
  SHA512:
6
- metadata.gz: 3f836191c700760f02067bde54291d5cce3ac06596820f42d718100f85e02f178c9b6513f48fb2e779b4298af6aac631a839139bc5d5e2ba8f7e331c7460ac11
7
- data.tar.gz: 5c30e5fb096f78fae249ef390f85cbd2683716756c89acffc2a9e88f15552e5941e02ee0c8bb264366f5fee14c6c148c9e0ffd1a70a024535829f3c9ed4c9069
6
+ metadata.gz: b7f837038cfe93d142cc35bec5f4c8488c8da05a8a5959e16b090c68c2dd046ceb68f16ac08473ddf1b2c53eb8fe688960d330fdd4a510670bd35b66665c9681
7
+ data.tar.gz: 643c3d2e6a5d68e49c325679f5191535a11084bf2e9a02e69a25f193c220b92de0c2c3b2413087885bd35698b685cd6d4c2656779ba4660625e0f062003a4fad
data/Rakefile CHANGED
@@ -1,2 +1,5 @@
1
- require "bundler/gem_tasks"
1
+ require 'rspec/core/rake_task'
2
2
 
3
+
4
+ task :default => [:spec]
5
+ spec = RSpec::Core::RakeTask.new(:spec)
data/jredshift.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency 'jdbc-postgres', '~> 9.3'
25
25
  spec.add_development_dependency 'bundler', '~> 1.6'
26
26
  spec.add_development_dependency 'rake', '~> 10'
27
+ spec.add_development_dependency 'rspec', '~> 3'
27
28
  end
@@ -1,3 +1,3 @@
1
1
  module Jredshift
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -0,0 +1,16 @@
1
+ require 'jredshift'
2
+
3
+
4
+ module Jredshift
5
+ class DevRedshift < Redshift
6
+
7
+ def initialize(options={})
8
+ super(
9
+ ENV['JREDSHIFT_JDBC_URL'],
10
+ ENV['JREDSHIFT_USER'],
11
+ ENV['JREDSHIFT_PASSWORD'],
12
+ options
13
+ )
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,74 @@
1
+ require_relative 'dev_redshift'
2
+
3
+
4
+ module Jredshift
5
+ describe 'Redshift' do
6
+
7
+ before(:all) do
8
+ @db_conn = DevRedshift.new
9
+ end
10
+
11
+ after(:all) do
12
+ @db_conn.drop_table_if_exists('test.tmp_drop_if_exists')
13
+ @db_conn.drop_table_if_exists('test.tmp_test_table')
14
+ @db_conn.drop_view_if_exists('test.tmp_test_table_vw')
15
+ end
16
+
17
+ describe '#drop_table_if_exists' do
18
+
19
+ it 'ignores a missing table' do
20
+ @db_conn.drop_table_if_exists('test.i_dont_exist')
21
+ expect(@db_conn.error_occurred?).to be false
22
+ end
23
+
24
+ it 'drops an existing table' do
25
+ @db_conn.drop_table_if_exists('test.tmp_drop_if_exists')
26
+ @db_conn.execute('CREATE TABLE test.tmp_drop_if_exists (tmp boolean)')
27
+ @db_conn.drop_table_if_exists('test.tmp_drop_if_exists')
28
+ expect(@db_conn.error_occurred?).to be false
29
+ end
30
+
31
+ it 'cascades when :cascade option is true' do
32
+ @db_conn.execute('CREATE TABLE test.tmp_test_table (tmp boolean)')
33
+ @db_conn.execute('CREATE VIEW test.tmp_test_table_vw AS SELECT * ' +
34
+ 'FROM test.tmp_test_table')
35
+ @db_conn.drop_table_if_exists('test.tmp_test_table', :cascade => true)
36
+ sql = "SELECT count(*) FROM pg_views WHERE viewname = 'tmp_test_table_vw'"
37
+
38
+ count = @db_conn.query(sql).first['count']
39
+ expect(count).to eq(0)
40
+ end
41
+ end
42
+
43
+ describe '#drop_view_if_exists' do
44
+
45
+ it 'ignores a missing view' do
46
+ @db_conn.drop_view_if_exists('test.i_dont_exist_vw')
47
+ expect(@db_conn.error_occurred?).to be false
48
+ end
49
+
50
+ it 'drops an existing view' do
51
+ @db_conn.drop_table_if_exists('test.tmp_test_table', :cascade => true)
52
+ @db_conn.execute('CREATE TABLE test.tmp_test_table (tmp boolean)')
53
+ @db_conn.execute('CREATE VIEW test.tmp_drop_if_exists_vw AS SELECT * ' +
54
+ 'FROM test.tmp_test_table')
55
+ @db_conn.drop_view_if_exists('test.tmp_drop_if_exists_vw')
56
+ @db_conn.execute('DROP TABLE test.tmp_test_table')
57
+ expect(@db_conn.error_occurred?).to be false
58
+ end
59
+ end
60
+
61
+ describe '#get_field_by_type' do
62
+
63
+ it 'converts booleans correctly' do
64
+ @db_conn.execute('CREATE TABLE test.tmp_test_table (tmp boolean)')
65
+ @db_conn.execute('INSERT INTO test.tmp_test_table VALUES (true), (false)')
66
+ rows = @db_conn.query('SELECT * FROM test.tmp_test_table ORDER BY tmp')
67
+ @db_conn.drop_table_if_exists('test.tmp_test_table')
68
+
69
+ expect(rows[0]['tmp']).to be false
70
+ expect(rows[1]['tmp']).to be true
71
+ end
72
+ end
73
+ end
74
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jredshift
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Morin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-28 00:00:00.000000000 Z
11
+ date: 2014-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jdbc-postgres
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3'
55
69
  description: |2
56
70
  Convience wrapper for using Redshift with JRuby.
57
71
  email:
@@ -71,6 +85,8 @@ files:
71
85
  - lib/jredshift/jdbc_db.rb
72
86
  - lib/jredshift/logger.rb
73
87
  - lib/jredshift/version.rb
88
+ - spec/dev_redshift.rb
89
+ - spec/redshift_spec.rb
74
90
  homepage: http://github.com/deanmorin/jredshift
75
91
  licenses:
76
92
  - The Unlicense
@@ -95,4 +111,6 @@ rubygems_version: 2.2.0
95
111
  signing_key:
96
112
  specification_version: 4
97
113
  summary: Redshift wrapper for JRuby.
98
- test_files: []
114
+ test_files:
115
+ - spec/dev_redshift.rb
116
+ - spec/redshift_spec.rb