bespoke 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,44 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- describe Bespoke::Join do
4
- let(:projections) {
5
- [
6
- projection(:one) {
7
- field :id, :integer
8
- field :name, :string
9
- },
10
- projection(:two) {
11
- field :id, :integer
12
- field :one_id, :integer
13
- field :description, :string
14
- }
15
- ]
16
- }
17
- let(:join) { Bespoke::Join.new(projections) }
18
-
19
- context "table 'one'" do
20
- before { join.load_csv('one', fixture('one.csv')) }
21
-
22
- it "loads csv" do
23
- join.database[:one].count.should == 2
24
- end
25
-
26
- context "and table 'two'" do
27
- before { join.load_csv('two', fixture('two.csv')) }
28
-
29
- it "loads csv" do
30
- join.database[:two].count.should == 3
31
- end
32
-
33
- it "joins" do
34
- sql = "SELECT name, description FROM one LEFT JOIN two ON one.id = two.one_id"
35
- join.query(sql).map { |row| row }.
36
- should == [
37
- {:name=>"bitcoin", :description=>"Cryptocurrency"},
38
- {:name=>"bitcoin", :description=>"Investment"},
39
- {:name=>"nxt", :description=>"Alternate Cryptocurrency"}
40
- ]
41
- end
42
- end
43
- end
44
- end