ruport 1.7.1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +38 -0
- data/HACKING +1 -17
- data/{README.rdoc → README.md} +30 -38
- data/Rakefile +0 -10
- data/examples/row_renderer.rb +1 -1
- data/examples/simple_pdf_lines.rb +1 -1
- data/examples/trac_ticket_status.rb +1 -1
- data/lib/ruport/controller.rb +1 -1
- data/lib/ruport/data/grouping.rb +7 -7
- data/lib/ruport/data/record.rb +4 -4
- data/lib/ruport/data/table.rb +9 -9
- data/lib/ruport/formatter/csv.rb +1 -1
- data/lib/ruport/formatter/markdown.rb +105 -0
- data/lib/ruport/formatter/prawn_pdf.rb +96 -9
- data/lib/ruport/formatter/text.rb +1 -1
- data/lib/ruport/formatter.rb +1 -2
- data/lib/ruport/version.rb +1 -1
- data/lib/ruport.rb +7 -11
- data/test/controller_test.rb +107 -109
- data/test/csv_formatter_test.rb +21 -21
- data/test/data_feeder_test.rb +39 -39
- data/test/expected_outputs/prawn_pdf_formatter/pdf_basic.pdf.test +265 -0
- data/test/grouping_test.rb +74 -74
- data/test/helpers.rb +16 -5
- data/test/html_formatter_test.rb +22 -22
- data/test/markdown_formatter_test.rb +142 -0
- data/test/prawn_pdf_formatter_test.rb +108 -0
- data/test/record_test.rb +82 -82
- data/test/table_pivot_test.rb +9 -2
- data/test/table_test.rb +33 -40
- data/test/template_test.rb +12 -12
- data/test/text_formatter_test.rb +34 -34
- data/util/bench/data/table/bench_column_manip.rb +0 -1
- data/util/bench/data/table/bench_dup.rb +0 -1
- data/util/bench/data/table/bench_init.rb +0 -1
- data/util/bench/data/table/bench_manip.rb +0 -1
- data/util/bench/formatter/bench_csv.rb +0 -1
- data/util/bench/formatter/bench_html.rb +0 -1
- data/util/bench/formatter/bench_pdf.rb +0 -1
- data/util/bench/formatter/bench_text.rb +0 -1
- metadata +30 -29
- data/lib/ruport/formatter/pdf.rb +0 -589
@@ -110,7 +110,7 @@ module Ruport
|
|
110
110
|
def build_row(data = self.data)
|
111
111
|
max_col_widths_for_row(data) unless options.max_col_width
|
112
112
|
|
113
|
-
data.enum_for(:each_with_index).inject(line=[]) { |
|
113
|
+
data.enum_for(:each_with_index).inject(line=[]) { |_s,e|
|
114
114
|
field,index = e
|
115
115
|
if options.alignment.eql? :center
|
116
116
|
line << field.to_s.center(options.max_col_width[index])
|
data/lib/ruport/formatter.rb
CHANGED
@@ -117,7 +117,6 @@ module Ruport
|
|
117
117
|
:io => output,
|
118
118
|
:layout => false }.merge(options)
|
119
119
|
|
120
|
-
options[:io] = "" if self.class.kind_of?(Ruport::Formatter::PDF)
|
121
120
|
rend_klass.render(format,options) do |rend|
|
122
121
|
block[rend] if block
|
123
122
|
end
|
@@ -251,5 +250,5 @@ require "ruport/formatter/template"
|
|
251
250
|
require "ruport/formatter/csv"
|
252
251
|
require "ruport/formatter/html"
|
253
252
|
require "ruport/formatter/text"
|
254
|
-
require "ruport/formatter/pdf"
|
255
253
|
require "ruport/formatter/prawn_pdf"
|
254
|
+
require "ruport/formatter/markdown"
|
data/lib/ruport/version.rb
CHANGED
data/lib/ruport.rb
CHANGED
@@ -60,29 +60,26 @@ module Ruport #:nodoc:#
|
|
60
60
|
stdout_handle = m_GetStdHandle.call(0xFFFFFFF5)
|
61
61
|
|
62
62
|
m_GetConsoleScreenBufferInfo.call(stdout_handle, buf)
|
63
|
-
|
64
|
-
left, top, right, bottom, maxx, maxy = buf.unpack(format)
|
63
|
+
_bufx, _bufy, _curx, _cury, _wattr, left, top, right, bottom, _maxx, _maxy = buf.unpack(format)
|
65
64
|
return right - left + 1, bottom - top + 1
|
66
65
|
end
|
67
66
|
rescue LoadError # If we're not on Windows try...
|
68
67
|
# A Unix savvy method to fetch the console columns, and rows.
|
69
68
|
def terminal_size
|
70
69
|
size = if /solaris/ =~ RUBY_PLATFORM
|
71
|
-
output = `stty`
|
70
|
+
output = `stty 2>&1`
|
72
71
|
[output.match('columns = (\d+)')[1].to_i,
|
73
72
|
output.match('rows = (\d+)')[1].to_i]
|
74
73
|
else
|
75
|
-
`stty size`.split.map { |x| x.to_i }.reverse
|
74
|
+
`stty size 2>&1`.split.map { |x| x.to_i }.reverse
|
76
75
|
end
|
77
76
|
return $? == 0 ? size : [80,24]
|
78
77
|
end
|
79
|
-
|
80
|
-
end
|
78
|
+
end
|
81
79
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
80
|
+
def terminal_width
|
81
|
+
terminal_size.first
|
82
|
+
end
|
86
83
|
end
|
87
84
|
|
88
85
|
# quiets warnings for block
|
@@ -99,7 +96,6 @@ module Ruport #:nodoc:#
|
|
99
96
|
end
|
100
97
|
|
101
98
|
require "ruport/version"
|
102
|
-
require "enumerator"
|
103
99
|
require "ruport/controller"
|
104
100
|
require "ruport/data"
|
105
101
|
require "ruport/formatter"
|
data/test/controller_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env ruby -w
|
1
|
+
#!/usr/bin/env ruby -w
|
2
2
|
require File.join(File.expand_path(File.dirname(__FILE__)), "helpers")
|
3
3
|
|
4
4
|
###########################################################################
|
@@ -28,7 +28,7 @@ class OldSchoolController < Ruport::Controller
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
end
|
31
|
+
end
|
32
32
|
|
33
33
|
class VanillaController < Ruport::Controller
|
34
34
|
stage :header,:body,:footer
|
@@ -39,9 +39,9 @@ end
|
|
39
39
|
# that the hooks are being set up right. Perhaps these could
|
40
40
|
# be replaced by mock objects in the future.
|
41
41
|
class DummyText < Ruport::Formatter
|
42
|
-
|
42
|
+
|
43
43
|
renders :text, :for => OldSchoolController
|
44
|
-
|
44
|
+
|
45
45
|
def prepare_document
|
46
46
|
output << "p"
|
47
47
|
end
|
@@ -61,7 +61,7 @@ class DummyText < Ruport::Formatter
|
|
61
61
|
def finalize_document
|
62
62
|
output << "f"
|
63
63
|
end
|
64
|
-
end
|
64
|
+
end
|
65
65
|
|
66
66
|
# This formatter modifies the (String) data object passed to it
|
67
67
|
class Destructive < Ruport::Formatter
|
@@ -84,11 +84,11 @@ end
|
|
84
84
|
class VanillaBinary < Ruport::Formatter
|
85
85
|
renders :bin, :for => VanillaController
|
86
86
|
save_as_binary_file
|
87
|
-
end
|
87
|
+
end
|
88
88
|
|
89
89
|
class SpecialFinalize < Ruport::Formatter
|
90
90
|
renders :with_finalize, :for => VanillaController
|
91
|
-
|
91
|
+
|
92
92
|
def finalize
|
93
93
|
output << "I has been finalized"
|
94
94
|
end
|
@@ -103,60 +103,60 @@ class TestController < Minitest::Test
|
|
103
103
|
def test_trivial
|
104
104
|
actual = OldSchoolController.render(:text)
|
105
105
|
assert_equal "header\nbody\nfooter\n", actual
|
106
|
-
end
|
107
|
-
|
106
|
+
end
|
107
|
+
|
108
108
|
context "when running a formatter with custom a finalize method" do
|
109
|
-
|
110
|
-
assert_equal "I has been finalized",
|
109
|
+
should "specify_finalize_method_should_be_called" do
|
110
|
+
assert_equal "I has been finalized",
|
111
111
|
VanillaController.render_with_finalize
|
112
|
-
end
|
112
|
+
end
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
context "when using templates" do
|
116
|
-
|
116
|
+
should "specify_apply_template_should_be_called" do
|
117
117
|
Ruport::Formatter::Template.create(:stub)
|
118
118
|
Ruport.Table(%w[a b c]).to_csv(:template => :stub) do |r|
|
119
119
|
r.formatter.expects(:apply_template)
|
120
|
-
end
|
121
|
-
end
|
120
|
+
end
|
121
|
+
end
|
122
122
|
|
123
|
-
|
123
|
+
should "specify_undefined_template_should_throw_sensible_error" do
|
124
124
|
assert_raises(Ruport::Formatter::TemplateNotDefined) do
|
125
125
|
Ruport.Table(%w[a b c]).to_csv(:template => :sub)
|
126
|
-
end
|
126
|
+
end
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
context "when using default templates" do
|
131
|
-
|
131
|
+
should "specify_default_template_should_be_called" do
|
132
132
|
Ruport::Formatter::Template.create(:default)
|
133
133
|
Ruport.Table(%w[a b c]).to_csv do |r|
|
134
134
|
r.formatter.expects(:apply_template)
|
135
135
|
assert r.formatter.template == Ruport::Formatter::Template[:default]
|
136
|
-
end
|
136
|
+
end
|
137
137
|
end
|
138
138
|
|
139
|
-
|
139
|
+
should "specify_specific_should_override_default" do
|
140
140
|
Ruport::Formatter::Template.create(:default)
|
141
141
|
Ruport::Formatter::Template.create(:stub)
|
142
142
|
Ruport.Table(%w[a b c]).to_csv(:template => :stub) do |r|
|
143
143
|
r.formatter.expects(:apply_template)
|
144
144
|
assert r.formatter.template == Ruport::Formatter::Template[:stub]
|
145
|
-
end
|
145
|
+
end
|
146
146
|
end
|
147
147
|
|
148
|
-
|
148
|
+
should "specify_should_be_able_to_disable_templates" do
|
149
149
|
Ruport::Formatter::Template.create(:default)
|
150
150
|
Ruport.Table(%w[a b c]).to_csv(:template => false) do |r|
|
151
151
|
r.formatter.expects(:apply_template).never
|
152
|
-
end
|
152
|
+
end
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
156
|
def test_using_io
|
157
157
|
require "stringio"
|
158
158
|
out = StringIO.new
|
159
|
-
|
159
|
+
OldSchoolController.render(:text) { |r| r.io = out }
|
160
160
|
out.rewind
|
161
161
|
assert_equal "header\nbody\nfooter\n", out.read
|
162
162
|
assert_equal "", out.read
|
@@ -165,21 +165,21 @@ class TestController < Minitest::Test
|
|
165
165
|
def test_using_file
|
166
166
|
f = []
|
167
167
|
File.expects(:open).yields(f)
|
168
|
-
|
168
|
+
OldSchoolController.render(:text, :file => "foo.text")
|
169
169
|
assert_equal "header\nbody\nfooter\n", f[0]
|
170
|
-
|
170
|
+
|
171
171
|
f = []
|
172
172
|
File.expects(:open).with("blah","wb").yields(f)
|
173
|
-
VanillaController.render(:bin, :file => "blah")
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_using_file_via_rendering_tools
|
173
|
+
VanillaController.render(:bin, :file => "blah")
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_using_file_via_rendering_tools
|
177
177
|
f = []
|
178
|
-
File.expects(:open).yields(f)
|
178
|
+
File.expects(:open).yields(f)
|
179
179
|
Ruport.Table(%w[a b c], :data => [[1,2,3],[4,5,6]]).save_as("foo.csv")
|
180
|
-
assert_equal "a,b,c\n1,2,3\n4,5,6\n", f[0]
|
180
|
+
assert_equal "a,b,c\n1,2,3\n4,5,6\n", f[0]
|
181
181
|
end
|
182
|
-
|
182
|
+
|
183
183
|
|
184
184
|
def test_formats
|
185
185
|
assert_equal( {}, Ruport::Controller.formats )
|
@@ -209,33 +209,33 @@ class TestController < Minitest::Test
|
|
209
209
|
|
210
210
|
rend.formatter.clear_output
|
211
211
|
assert_equal "", rend.formatter.output
|
212
|
-
end
|
213
|
-
|
212
|
+
end
|
213
|
+
|
214
214
|
def test_options_act_like_indifferent_hash
|
215
215
|
opts = Ruport::Controller::Options.new
|
216
216
|
opts.foo = "bar"
|
217
217
|
assert_equal "bar", opts[:foo]
|
218
|
-
assert_equal "bar", opts["foo"]
|
219
|
-
|
218
|
+
assert_equal "bar", opts["foo"]
|
219
|
+
|
220
220
|
opts["f"] = "bar"
|
221
221
|
assert_equal "bar", opts[:f]
|
222
222
|
assert_equal "bar", opts.f
|
223
223
|
assert_equal "bar", opts["f"]
|
224
|
-
|
224
|
+
|
225
225
|
opts[:apple] = "banana"
|
226
226
|
assert_equal "banana", opts.apple
|
227
227
|
assert_equal "banana", opts["apple"]
|
228
228
|
assert_equal "banana", opts[:apple]
|
229
|
-
end
|
230
|
-
|
229
|
+
end
|
230
|
+
|
231
231
|
end
|
232
232
|
|
233
233
|
|
234
234
|
class TestFormatterUsingBuild < Minitest::Test
|
235
235
|
# This formatter uses the build syntax
|
236
236
|
class UsesBuild < Ruport::Formatter
|
237
|
-
renders :text_using_build, :for => VanillaController
|
238
|
-
|
237
|
+
renders :text_using_build, :for => VanillaController
|
238
|
+
|
239
239
|
build :header do
|
240
240
|
output << "header\n"
|
241
241
|
end
|
@@ -246,7 +246,7 @@ class TestFormatterUsingBuild < Minitest::Test
|
|
246
246
|
|
247
247
|
build :footer do
|
248
248
|
output << "footer\n"
|
249
|
-
end
|
249
|
+
end
|
250
250
|
end
|
251
251
|
|
252
252
|
def test_should_render_using_build_syntax
|
@@ -265,21 +265,21 @@ class TestFormatterWithLayout < Minitest::Test
|
|
265
265
|
# This formatter is meant to check out a special case in Ruport's renderer,
|
266
266
|
# in which a layout method is called and yielded to when defined
|
267
267
|
class WithLayout < DummyText
|
268
|
-
renders :text_with_layout, :for => VanillaController
|
269
|
-
|
270
|
-
def layout
|
268
|
+
renders :text_with_layout, :for => VanillaController
|
269
|
+
|
270
|
+
def layout
|
271
271
|
output << "---\n"
|
272
272
|
yield
|
273
273
|
output << "---\n"
|
274
274
|
end
|
275
|
-
|
275
|
+
|
276
276
|
end
|
277
277
|
|
278
278
|
def test_layout
|
279
|
-
assert_equal "---\nheader\nbody\nfooter\n---\n",
|
279
|
+
assert_equal "---\nheader\nbody\nfooter\n---\n",
|
280
280
|
VanillaController.render_text_with_layout
|
281
281
|
end
|
282
|
-
|
282
|
+
|
283
283
|
def test_layout_disabled
|
284
284
|
assert_equal "header\nbody\nfooter\n",
|
285
285
|
VanillaController.render_text_with_layout(:layout => false)
|
@@ -305,30 +305,28 @@ class TestControllerWithManyHooks < Minitest::Test
|
|
305
305
|
def setup
|
306
306
|
options.apple = true
|
307
307
|
end
|
308
|
-
|
309
308
|
end
|
310
309
|
|
311
310
|
def test_hash_options_setters
|
312
|
-
|
313
|
-
:subsubtitle => "bar") { |r|
|
311
|
+
ControllerWithManyHooks.render(:text, :subtitle => "foo", :subsubtitle => "bar") do |r|
|
314
312
|
assert_equal "foo", r.options.subtitle
|
315
313
|
assert_equal "bar", r.options.subsubtitle
|
316
|
-
|
314
|
+
end
|
317
315
|
end
|
318
316
|
|
319
317
|
def test_data_accessors
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
318
|
+
ControllerWithManyHooks.render(:text, :data => [1,2,4]) do |r|
|
319
|
+
assert_equal [1,2,4], r.data
|
320
|
+
end
|
321
|
+
|
322
|
+
ControllerWithManyHooks.render_text(%w[a b c]) do |r|
|
323
|
+
assert_equal %w[a b c], r.data
|
324
|
+
end
|
325
|
+
|
326
|
+
ControllerWithManyHooks.render_text(%w[a b f],:snapper => :red) do |r|
|
327
|
+
assert_equal %w[a b f], r.data
|
328
|
+
assert_equal :red, r.options.snapper
|
329
|
+
end
|
332
330
|
end
|
333
331
|
|
334
332
|
def test_formatter_data_dup
|
@@ -341,7 +339,7 @@ class TestControllerWithManyHooks < Minitest::Test
|
|
341
339
|
def test_stage_helper
|
342
340
|
assert ControllerWithManyHooks.stages.include?('body')
|
343
341
|
end
|
344
|
-
|
342
|
+
|
345
343
|
def test_finalize_helper
|
346
344
|
assert_equal :document, ControllerWithManyHooks.final_stage
|
347
345
|
end
|
@@ -351,14 +349,14 @@ class TestControllerWithManyHooks < Minitest::Test
|
|
351
349
|
end
|
352
350
|
|
353
351
|
def test_finalize_again
|
354
|
-
assert_raises(Ruport::Controller::StageAlreadyDefinedError) {
|
355
|
-
ControllerWithManyHooks.finalize :report
|
352
|
+
assert_raises(Ruport::Controller::StageAlreadyDefinedError) {
|
353
|
+
ControllerWithManyHooks.finalize :report
|
356
354
|
}
|
357
355
|
end
|
358
356
|
|
359
357
|
def test_prepare_again
|
360
|
-
assert_raises(Ruport::Controller::StageAlreadyDefinedError) {
|
361
|
-
ControllerWithManyHooks.prepare :foo
|
358
|
+
assert_raises(Ruport::Controller::StageAlreadyDefinedError) {
|
359
|
+
ControllerWithManyHooks.prepare :foo
|
362
360
|
}
|
363
361
|
end
|
364
362
|
|
@@ -387,7 +385,7 @@ class TestControllerWithManyHooks < Minitest::Test
|
|
387
385
|
|
388
386
|
assert_raises(Ruport::Controller::RequiredOptionNotSet) { a.render(:text) }
|
389
387
|
end
|
390
|
-
|
388
|
+
|
391
389
|
end
|
392
390
|
|
393
391
|
|
@@ -409,7 +407,7 @@ class TestControllerWithRunHook < Minitest::Test
|
|
409
407
|
end
|
410
408
|
|
411
409
|
def test_renderer_with_run_hooks
|
412
|
-
assert_equal "|header\nbody\nfooter\n",
|
410
|
+
assert_equal "|header\nbody\nfooter\n",
|
413
411
|
ControllerWithRunHook.render_text(:foo => "bar",:bar => "baz")
|
414
412
|
end
|
415
413
|
|
@@ -427,7 +425,7 @@ class TestControllerWithHelperModule < Minitest::Test
|
|
427
425
|
"Hello Dolly"
|
428
426
|
end
|
429
427
|
end
|
430
|
-
end
|
428
|
+
end
|
431
429
|
|
432
430
|
def test_renderer_helper_module
|
433
431
|
ControllerWithHelperModule.render_stub do |r|
|
@@ -439,7 +437,7 @@ end
|
|
439
437
|
|
440
438
|
class TestMultiPurposeFormatter < Minitest::Test
|
441
439
|
# This provides a way to check the multi-format hooks for the Controller
|
442
|
-
class MultiPurposeFormatter < Ruport::Formatter
|
440
|
+
class MultiPurposeFormatter < Ruport::Formatter
|
443
441
|
|
444
442
|
renders [:html,:text], :for => VanillaController
|
445
443
|
|
@@ -447,7 +445,7 @@ class TestMultiPurposeFormatter < Minitest::Test
|
|
447
445
|
a = 10
|
448
446
|
|
449
447
|
text { output << "Foo: #{a}\n" }
|
450
|
-
html { output << "<b>Foo: #{a}</b>\n" }
|
448
|
+
html { output << "<b>Foo: #{a}</b>\n" }
|
451
449
|
end
|
452
450
|
|
453
451
|
def build_body
|
@@ -456,7 +454,7 @@ class TestMultiPurposeFormatter < Minitest::Test
|
|
456
454
|
html { output << "\n</pre>\n" }
|
457
455
|
end
|
458
456
|
|
459
|
-
end
|
457
|
+
end
|
460
458
|
|
461
459
|
def test_multi_purpose
|
462
460
|
text = VanillaController.render_text(:body_text => "foo")
|
@@ -471,12 +469,12 @@ class TestMultiPurposeFormatter < Minitest::Test
|
|
471
469
|
|
472
470
|
a = MultiPurposeFormatter.new
|
473
471
|
a.format = :html
|
474
|
-
|
472
|
+
|
475
473
|
visited = false
|
476
474
|
a.html { visited = true }
|
477
475
|
|
478
476
|
assert visited
|
479
|
-
|
477
|
+
|
480
478
|
visited = false
|
481
479
|
a.text { visited = true }
|
482
480
|
assert !visited
|
@@ -504,7 +502,7 @@ class TestFormatterErbHelper < Minitest::Test
|
|
504
502
|
output << erb("Default Binding: <%= @foo %>")
|
505
503
|
end
|
506
504
|
end
|
507
|
-
|
505
|
+
|
508
506
|
end
|
509
507
|
|
510
508
|
#FIXME: need to test file
|
@@ -523,66 +521,66 @@ end
|
|
523
521
|
|
524
522
|
|
525
523
|
class TestOptionReaders < Minitest::Test
|
526
|
-
|
524
|
+
|
527
525
|
class ControllerForCheckingOptionReaders < Ruport::Controller
|
528
|
-
required_option :foo
|
529
|
-
end
|
530
|
-
|
526
|
+
required_option :foo
|
527
|
+
end
|
528
|
+
|
531
529
|
class ControllerForCheckingPassivity < Ruport::Controller
|
532
530
|
def foo
|
533
531
|
"apples"
|
534
532
|
end
|
535
|
-
required_option :foo
|
533
|
+
required_option :foo
|
536
534
|
end
|
537
535
|
|
538
|
-
def setup
|
539
|
-
@renderer = ControllerForCheckingOptionReaders.new
|
540
|
-
@renderer.formatter = Ruport::Formatter.new
|
541
|
-
|
536
|
+
def setup
|
537
|
+
@renderer = ControllerForCheckingOptionReaders.new
|
538
|
+
@renderer.formatter = Ruport::Formatter.new
|
539
|
+
|
542
540
|
@passive = ControllerForCheckingPassivity.new
|
543
541
|
@passive.formatter = Ruport::Formatter.new
|
544
542
|
end
|
545
|
-
|
543
|
+
|
546
544
|
def test_options_are_readable
|
547
545
|
@renderer.foo = 5
|
548
546
|
assert_equal 5, @renderer.foo
|
549
|
-
end
|
550
|
-
|
547
|
+
end
|
548
|
+
|
551
549
|
def test_methods_are_not_overridden
|
552
550
|
@passive.foo = 5
|
553
551
|
assert_equal "apples", @passive.foo
|
554
552
|
assert_equal 5, @passive.options.foo
|
555
553
|
assert_equal 5, @passive.formatter.options.foo
|
556
554
|
end
|
557
|
-
|
555
|
+
|
558
556
|
end
|
559
|
-
|
557
|
+
|
560
558
|
class TestSetupOrdering < Minitest::Test
|
561
|
-
|
559
|
+
|
562
560
|
class ControllerWithSetup < Ruport::Controller
|
563
561
|
stage :bar
|
564
562
|
def setup
|
565
563
|
options.foo.capitalize!
|
566
|
-
end
|
567
|
-
end
|
568
|
-
|
569
|
-
class BasicFormatter < Ruport::Formatter
|
564
|
+
end
|
565
|
+
end
|
566
|
+
|
567
|
+
class BasicFormatter < Ruport::Formatter
|
570
568
|
renders :text, :for => ControllerWithSetup
|
571
|
-
|
569
|
+
|
572
570
|
def build_bar
|
573
571
|
output << options.foo
|
574
572
|
end
|
575
573
|
end
|
576
|
-
|
574
|
+
|
577
575
|
def test_render_hash_options_should_be_called_before_setup
|
578
576
|
assert_equal "Hello", ControllerWithSetup.render_text(:foo => "hello")
|
579
|
-
end
|
580
|
-
|
577
|
+
end
|
578
|
+
|
581
579
|
def test_render_block_should_be_called_before_setup
|
582
|
-
assert_equal "Hello",
|
580
|
+
assert_equal "Hello",
|
583
581
|
ControllerWithSetup.render_text { |r| r.options.foo = "hello" }
|
584
582
|
end
|
585
|
-
|
583
|
+
|
586
584
|
end
|
587
585
|
|
588
586
|
class CustomFormatter < Ruport::Formatter
|
@@ -608,7 +606,7 @@ class ControllerWithAnonymousFormatters < Ruport::Controller
|
|
608
606
|
end
|
609
607
|
|
610
608
|
formatter :pdf do
|
611
|
-
build :report do
|
609
|
+
build :report do
|
612
610
|
add_text "hello world"
|
613
611
|
end
|
614
612
|
end
|
@@ -673,7 +671,7 @@ class TestControllerHooks < Minitest::Test
|
|
673
671
|
|
674
672
|
require "mocha"
|
675
673
|
|
676
|
-
class DummyObject
|
674
|
+
class DummyObject
|
677
675
|
include Ruport::Controller::Hooks
|
678
676
|
renders_as_table
|
679
677
|
end
|
@@ -690,7 +688,7 @@ class TestControllerHooks < Minitest::Test
|
|
690
688
|
include Ruport::Controller::Hooks
|
691
689
|
renders_as_table
|
692
690
|
|
693
|
-
def renderable_data(
|
691
|
+
def renderable_data(_format)
|
694
692
|
1
|
695
693
|
end
|
696
694
|
end
|
@@ -706,7 +704,7 @@ class TestControllerHooks < Minitest::Test
|
|
706
704
|
class DummyObject3
|
707
705
|
include Ruport::Controller::Hooks
|
708
706
|
renders_as_table
|
709
|
-
|
707
|
+
|
710
708
|
def renderable_data
|
711
709
|
raise ArgumentError
|
712
710
|
end
|