| 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
 | require 'spec_helper'
describe Chouette::ActiveRecord, :type => :model do
  it { expect(Chouette::ActiveRecord.ancestors).to include(ActiveRecord::Base) }
  describe "table_name" do
    it "should return line for Chouette::Line" do
      expect(Chouette::Line.table_name).to eq("public.lines")
    end
    it "should return ptnetwork for Chouette::Network" do
      expect(Chouette::Network.table_name).to eq("public.networks")
    end
    it "should return timetable_date for Chouette::TimeTableDate" do
      expect(Chouette::TimeTableDate.table_name).to eq("time_table_dates")
    end
    it "should return timetable_period for Chouette::TimeTablePeriod" do
      expect(Chouette::TimeTablePeriod.table_name).to eq("time_table_periods")
    end
  end
  describe "method_missing" do
    it "should support method with additionnal underscores" do
      stop_area = Chouette::StopArea.new
      expect(stop_area.area_type).to eq(stop_area.area_type)
    end
  end
  describe "respond_to?" do
    it "should respond to method with additionnal underscores" do
      stop_area = Chouette::StopArea.new
      expect(stop_area.respond_to?(:area_type)).to be_truthy
    end
  end
#   describe "create_reflection" do
#     let(:macro) { :has_many }
#     let(:name) { :lines }
#     let(:options) { {} }
#     let(:active_record) { Chouette::Network }
#     let(:modified_options) { {:modified => true}  }
#     it "should invoke create_reflection_without_chouette_naming with modified options" do
#       allow(Chouette::ActiveRecord::Reflection).to receive_messages :new => double(:options_with_default => modified_options)
#       expect(Chouette::ActiveRecord).to receive(:create_reflection_without_chouette_naming).with macro, name, modified_options, active_record
#       Chouette::ActiveRecord.create_reflection macro, name, options, active_record
#     end
#   end
end
# describe Chouette::ActiveRecord::Reflection, :type => :model do
#   let(:macro) { :has_many }
#   let(:name) { :lines }
#   let(:options) { {} }
#   let(:active_record) { Chouette::Network }
#   subject { Chouette::ActiveRecord::Reflection.new macro, name, options, active_record }
#   describe "collection?" do
#     it "should be true when macro is has_many" do
#       allow(subject).to receive_messages :macro => :has_many
#       expect(subject).to be_collection
#     end
#     it "should be false when macro is belongs_to" do
#       allow(subject).to receive_messages :macro => :belong_to
#       expect(subject).not_to be_collection
#     end
#   end
#   describe "class_name" do
#     it "should be Chouette::Line when name is line" do
#       allow(subject).to receive_messages :name => "line"
#       expect(subject.class_name).to eq("Chouette::Line")
#     end
#     it "should be Chouette::Routes when name is routes and reflection is a collection" do
#       allow(subject).to receive_messages :name => "routes", :collection? => true
#       expect(subject.class_name).to eq("Chouette::Route")
#     end
#   end
#   describe "options" do
#     it "should define class_name if not" do
#       allow(subject).to receive_messages :options => {}, :class_name => "class_name"
#       expect(subject.options_with_default[:class_name]).to eq("class_name")
#     end
#     it "should not define class_name if presents" do
#       allow(subject).to receive_messages :options => {:class_name => "dummy"}
#       expect(subject.options_with_default[:class_name]).to eq("dummy")
#     end
#   end
# end
 |