@@ -99,57 +99,6 @@ def row_template(product)
99
99
CSV
100
100
end
101
101
102
- test "using view_template instead of row_template" do
103
- example = Class . new ( Phlex ::CSV ) do
104
- define_method ( :escape_csv_injection? ) { true }
105
- define_method ( :trim_whitespace? ) { true }
106
-
107
- define_method ( :view_template ) do |product |
108
- column "Name" , product . name
109
- column "Price" , product . price
110
- end
111
- end
112
-
113
- component = example . new ( products )
114
- assert component . respond_to? ( :row_template )
115
-
116
- assert_raises ( NoMethodError ) do
117
- component . some_random_method
118
- end
119
-
120
- assert_equal component . call , <<~CSV
121
- Name,Price
122
- Apple,1.0
123
- Banana,2.0
124
- strawberry,Three pounds
125
- "'=SUM(A1:B1)","'=SUM(A1:B1)"
126
- "Abc, ""def""","Foo
127
- bar ""baz"""
128
- CSV
129
- end
130
-
131
- test "with a yielder" do
132
- example = Class . new ( Phlex ::CSV ) do
133
- define_method ( :escape_csv_injection? ) { true }
134
- define_method ( :trim_whitespace? ) { true }
135
- define_method ( :yielder ) { |product , &block | block . call ( product . name , product . price ) }
136
- define_method ( :row_template ) do |name , price |
137
- column "Name" , name
138
- column "Price" , price
139
- end
140
- end
141
-
142
- assert_equal example . new ( products ) . call , <<~CSV
143
- Name,Price
144
- Apple,1.0
145
- Banana,2.0
146
- strawberry,Three pounds
147
- "'=SUM(A1:B1)","'=SUM(A1:B1)"
148
- "Abc, ""def""","Foo
149
- bar ""baz"""
150
- CSV
151
- end
152
-
153
102
test "with a custom delimiter defined as a method" do
154
103
example = Class . new ( Phlex ::CSV ) do
155
104
define_method ( :escape_csv_injection? ) { true }
0 commit comments