dossier 2.9.0 → 2.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dossier/result.rb +14 -6
- data/lib/dossier/version.rb +1 -1
- data/spec/dossier/result_spec.rb +18 -2
- data/spec/dummy/config/database.yml +2 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +820 -266
- data/spec/fixtures/db/mysql2.yml +2 -1
- data/spec/fixtures/db/sqlite3.yml +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de2a8ead8c9e8a812cb212d5d3f0cf079b6d5396
|
4
|
+
data.tar.gz: 575a2d5aef49c98a73b02ad097b742a2f53b9096
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41a8a58bb79bcb253e6d82719f9fe38a59045d38824d97a7af32e91c6b3fff132fd41d445a343892f1b596baaa550c845d823d2bcc25c4bc8cee410b376d8891
|
7
|
+
data.tar.gz: 0bd542e8ccf1ba695bb09171a4bf43a62a57e5a015e488b09133e17639063491393cc602586ac80fd9e5dac9bee48300f59119e26a1261fd70890f94926f6997
|
data/lib/dossier/result.rb
CHANGED
@@ -9,8 +9,12 @@ module Dossier
|
|
9
9
|
self.report = report
|
10
10
|
end
|
11
11
|
|
12
|
+
def raw_headers
|
13
|
+
@raw_headers ||= adapter_results.headers
|
14
|
+
end
|
15
|
+
|
12
16
|
def headers
|
13
|
-
|
17
|
+
raise NotImplementedError.new("#{self.class.name} must implement `headers', use `raw_headers' for adapter headers")
|
14
18
|
end
|
15
19
|
|
16
20
|
def body
|
@@ -34,20 +38,20 @@ module Dossier
|
|
34
38
|
@hashes = rows.map { |row| row_hash(row) }
|
35
39
|
end
|
36
40
|
|
41
|
+
# this is the method that creates the individual hash entry
|
42
|
+
# hashes should always use raw headers
|
37
43
|
def row_hash(row)
|
38
|
-
Hash[
|
44
|
+
Hash[raw_headers.zip(row)].with_indifferent_access
|
39
45
|
end
|
40
46
|
|
41
47
|
def each
|
42
|
-
raise NotImplementedError
|
48
|
+
raise NotImplementedError.new("#{self.class.name} must define `each`")
|
43
49
|
end
|
44
50
|
|
45
51
|
class Formatted < Result
|
46
52
|
|
47
|
-
alias :raw_headers :headers
|
48
|
-
|
49
53
|
def headers
|
50
|
-
@formatted_headers ||=
|
54
|
+
@formatted_headers ||= raw_headers.map { |h| report.format_header(h) }
|
51
55
|
end
|
52
56
|
|
53
57
|
def each
|
@@ -79,6 +83,10 @@ module Dossier
|
|
79
83
|
def each
|
80
84
|
adapter_results.rows.each { |row| yield row }
|
81
85
|
end
|
86
|
+
|
87
|
+
def headers
|
88
|
+
raw_headers
|
89
|
+
end
|
82
90
|
end
|
83
91
|
|
84
92
|
end
|
data/lib/dossier/version.rb
CHANGED
data/spec/dossier/result_spec.rb
CHANGED
@@ -2,22 +2,31 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Dossier::Result do
|
4
4
|
|
5
|
-
module
|
5
|
+
module AbstractStub
|
6
6
|
def each
|
7
7
|
adapter_results.rows.each do |row|
|
8
8
|
yield row
|
9
9
|
end
|
10
10
|
end
|
11
|
+
|
12
|
+
def headers
|
13
|
+
raw_headers
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
let(:report) { TestReport.new }
|
14
18
|
let(:result_row) { {'mascot' => 'platapus', 'cheese' => 'bleu'} }
|
15
19
|
let(:adapter_result) { double(:adapter_result, rows: [result_row.values], headers: result_row.keys) }
|
16
|
-
let(:
|
20
|
+
let(:result_class) { Class.new(described_class) { include AbstractStub } }
|
21
|
+
let(:result) { result_class.new(adapter_result, report) }
|
17
22
|
|
18
23
|
it "requires each to be overridden" do
|
19
24
|
expect { described_class.new(adapter_result, report).each }.to raise_error(NotImplementedError, /result must define/i)
|
20
25
|
end
|
26
|
+
|
27
|
+
it "requires headers to be overridden" do
|
28
|
+
expect { described_class.new(adapter_result, report).headers }.to raise_error(NotImplementedError, /headers/i)
|
29
|
+
end
|
21
30
|
|
22
31
|
describe "initialization with an adapter result object" do
|
23
32
|
|
@@ -63,6 +72,13 @@ describe Dossier::Result do
|
|
63
72
|
end
|
64
73
|
end
|
65
74
|
|
75
|
+
describe "hashing" do
|
76
|
+
it "does not format the keys of the hash" do
|
77
|
+
hash = result.hashes.first
|
78
|
+
expect(hash.keys).to eq %w[mascot cheese]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
66
82
|
describe "each" do
|
67
83
|
|
68
84
|
it "calls :each on on its adapter's results" do
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|