Skip to content

Commit 2b39e70

Browse files
committed
Fix specs
1 parent 8d56654 commit 2b39e70

File tree

3 files changed

+25
-31
lines changed

3 files changed

+25
-31
lines changed

spec/analyze_sql_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
it "works" do
3232
puts result
3333
expect(JSON.parse(result)[0].keys.sort).to eq [
34-
"Execution Time", "Plan", "Planning Time", "Triggers",
35-
]
34+
"Execution Time", "Plan", "Planning Time", "Triggers",
35+
]
3636
end
3737
end
3838

@@ -43,8 +43,8 @@
4343

4444
it "works" do
4545
expect(result[0].keys.sort).to eq [
46-
"Execution Time", "Plan", "Planning Time", "Triggers",
47-
]
46+
"Execution Time", "Plan", "Planning Time", "Triggers",
47+
]
4848
end
4949
end
5050

@@ -55,8 +55,8 @@
5555

5656
it "works" do
5757
expect(JSON.parse(result)[0].keys.sort).to eq [
58-
"Execution Time", "Plan", "Planning Time", "Triggers",
59-
]
58+
"Execution Time", "Plan", "Planning Time", "Triggers",
59+
]
6060
end
6161
end
6262

@@ -76,8 +76,8 @@
7676

7777
it "works" do
7878
expect(result[0].keys.sort).to eq [
79-
"Execution Time", "Plan", "Planning Time", "Triggers",
80-
]
79+
"Execution Time", "Plan", "Planning Time", "Triggers",
80+
]
8181
end
8282
end
8383

@@ -95,8 +95,8 @@
9595
it "works" do
9696
puts result
9797
expect(JSON.parse(result)[0].keys.sort).to eq [
98-
"Execution Time", "Plan", "Planning Time", "Triggers",
99-
]
98+
"Execution Time", "Plan", "Planning Time", "Triggers",
99+
]
100100
end
101101
end
102102
end

spec/main_spec.rb

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@
66
class User < ActiveRecord::Base; end
77

88
describe "ActiveRecord analyze" do
9-
before(:all) do
10-
ActiveRecord::Base.establish_connection(
11-
ENV.fetch("DATABASE_URL")
12-
)
13-
14-
@schema_migration = ActiveRecord::Base.connection.schema_migration
15-
ActiveRecord::Migrator.new(:up, [CreateUsers.new], @schema_migration).migrate
16-
end
17-
189
describe "default opts" do
1910
it "works" do
2011
expect do
@@ -27,26 +18,26 @@ class User < ActiveRecord::Base; end
2718
it "works" do
2819
result = User.all.analyze(format: :json)
2920
expect(JSON.parse(result)[0].keys.sort).to eq [
30-
"Execution Time", "Plan", "Planning Time", "Triggers",
31-
]
21+
"Execution Time", "Plan", "Planning Time", "Triggers",
22+
]
3223
end
3324
end
3425

3526
describe "format hash" do
3627
it "works" do
3728
result = User.all.analyze(format: :hash)
3829
expect(result[0].keys.sort).to eq [
39-
"Execution Time", "Plan", "Planning Time", "Triggers",
40-
]
30+
"Execution Time", "Plan", "Planning Time", "Triggers",
31+
]
4132
end
4233
end
4334

4435
describe "format pretty" do
4536
it "works" do
4637
result = User.all.analyze(format: :pretty_json)
4738
expect(JSON.parse(result)[0].keys.sort).to eq [
48-
"Execution Time", "Plan", "Planning Time", "Triggers",
49-
]
39+
"Execution Time", "Plan", "Planning Time", "Triggers",
40+
]
5041
end
5142
end
5243

@@ -61,8 +52,8 @@ class User < ActiveRecord::Base; end
6152
it "works" do
6253
result = User.all.analyze(full_debug: true)
6354
expect(JSON.parse(result)[0].keys.sort).to eq [
64-
"Execution Time", "Plan", "Planning Time", "Triggers",
65-
]
55+
"Execution Time", "Plan", "Planning Time", "Triggers",
56+
]
6657
end
6758
end
6859

@@ -75,8 +66,8 @@ class User < ActiveRecord::Base; end
7566
summary: true,
7667
)
7768
expect(result[0].keys.sort).to eq [
78-
"Execution Time", "Plan", "Planning Time", "Triggers",
79-
]
69+
"Execution Time", "Plan", "Planning Time", "Triggers",
70+
]
8071
end
8172
end
8273
end

spec/spec_helper.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
ENV.fetch("DATABASE_URL")
1515
)
1616

17-
@schema_migration = ActiveRecord::Base.connection.schema_migration
18-
ActiveRecord::Migrator.new(:up, [CreateUsers.new], @schema_migration).migrate
17+
ActiveRecord::Schema.define do
18+
unless ActiveRecord::Base.connection.table_exists? "users"
19+
CreateUsers.new.change
20+
end
21+
end
1922
end
2023
end

0 commit comments

Comments
 (0)