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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 654b5bc958cd0b8226eb0f4048c88540fa3024db
4
- data.tar.gz: 4dd0180bd6e67e797fc003342b13c9fbc093d138
3
+ metadata.gz: de2a8ead8c9e8a812cb212d5d3f0cf079b6d5396
4
+ data.tar.gz: 575a2d5aef49c98a73b02ad097b742a2f53b9096
5
5
  SHA512:
6
- metadata.gz: 5b53a3128c5e0042ee01621f49dc931c1f9cd5480b1b3e7a66517f8fa6b05b97797accded6927604da3e8e28ed7c3b2650b15fbab33ea120ae37c60f166985f6
7
- data.tar.gz: a92771615847f0460bdb3fdca9e43730e9d14ccfa440b51fc73379f97964f0cf380a714620da2324a2547e11e77f0c214799397455169722e19a940a90ca3f6b
6
+ metadata.gz: 41a8a58bb79bcb253e6d82719f9fe38a59045d38824d97a7af32e91c6b3fff132fd41d445a343892f1b596baaa550c845d823d2bcc25c4bc8cee410b376d8891
7
+ data.tar.gz: 0bd542e8ccf1ba695bb09171a4bf43a62a57e5a015e488b09133e17639063491393cc602586ac80fd9e5dac9bee48300f59119e26a1261fd70890f94926f6997
@@ -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
- @headers ||= adapter_results.headers
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[headers.zip(row)].with_indifferent_access
44
+ Hash[raw_headers.zip(row)].with_indifferent_access
39
45
  end
40
46
 
41
47
  def each
42
- raise NotImplementedError, "#{self.class.name} must define `each`"
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 ||= super.map { |h| report.format_header(h) }
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
@@ -1,3 +1,3 @@
1
1
  module Dossier
2
- VERSION = "2.9.0"
2
+ VERSION = "2.9.1"
3
3
  end
@@ -2,22 +2,31 @@ require 'spec_helper'
2
2
 
3
3
  describe Dossier::Result do
4
4
 
5
- module EachStubber
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(:result) { Dossier::Result.new(adapter_result, report).tap { |r| r.extend(EachStubber) } }
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
@@ -3,7 +3,7 @@ defaults: &defaults
3
3
  database: dossier_test
4
4
  host: localhost
5
5
  username: root
6
- password: rubyr3d!
6
+ password:
7
7
 
8
8
  development:
9
9
  <<: *defaults
@@ -11,3 +11,4 @@ test:
11
11
  <<: *defaults
12
12
  production:
13
13
  <<: *defaults
14
+
Binary file