forked from rsim/ruby-plsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsequence_spec.rb
More file actions
65 lines (49 loc) · 1.65 KB
/
Copy pathsequence_spec.rb
File metadata and controls
65 lines (49 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
RSpec.describe "Table" do
before(:all) do
plsql.connection = get_connection
plsql.connection.autocommit = false
plsql.execute "CREATE SEQUENCE test_employees_seq"
end
after(:all) do
plsql.execute "DROP SEQUENCE test_employees_seq"
plsql.logoff
end
after(:each) do
plsql.rollback
end
describe "find" do
it "should find existing sequence" do
expect(PLSQL::Sequence.find(plsql, :test_employees_seq)).not_to be_nil
end
it "should not find nonexisting table" do
expect(PLSQL::Sequence.find(plsql, :qwerty123456)).to be_nil
end
it "should find existing sequence in schema" do
expect(plsql.test_employees_seq).to be_a(PLSQL::Sequence)
end
end
describe "synonym" do
before(:all) do
plsql.connection.exec "CREATE SYNONYM test_employees_seq_synonym FOR hr.test_employees_seq"
end
after(:all) do
plsql.connection.exec "DROP SYNONYM test_employees_seq_synonym" rescue nil
end
it "should find synonym to sequence" do
expect(PLSQL::Sequence.find(plsql, :test_employees_seq_synonym)).not_to be_nil
end
it "should find sequence using synonym in schema" do
expect(plsql.test_employees_seq_synonym).to be_a(PLSQL::Sequence)
end
end
describe "values" do
it "should get next value from sequence" do
next_value = plsql.select_one "SELECT test_employees_seq.NEXTVAL FROM dual"
expect(plsql.test_employees_seq.nextval).to eq(next_value + 1)
end
it "should get current value from sequence" do
next_value = plsql.test_employees_seq.nextval
expect(plsql.test_employees_seq.currval).to eq(next_value)
end
end
end