flatrack 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2 -2
  3. data/README.md +14 -2
  4. data/{templates → error_pages}/404.html +0 -0
  5. data/{templates → error_pages}/500.html +0 -0
  6. data/flatrack.gemspec +4 -0
  7. data/{templates → lib/flatrack/cli/templates}/.gitignore +0 -0
  8. data/{templates → lib/flatrack/cli/templates}/.keep +0 -0
  9. data/{templates → lib/flatrack/cli/templates}/Gemfile.erb +0 -0
  10. data/{templates → lib/flatrack/cli/templates}/Rakefile +0 -0
  11. data/{templates → lib/flatrack/cli/templates}/boot.rb +0 -0
  12. data/{templates → lib/flatrack/cli/templates}/config.ru +0 -0
  13. data/{templates → lib/flatrack/cli/templates}/javascript.js.coffee +0 -0
  14. data/{templates → lib/flatrack/cli/templates}/layout.html.erb +0 -0
  15. data/{logo.png → lib/flatrack/cli/templates/logo.png} +0 -0
  16. data/{templates → lib/flatrack/cli/templates}/page.html.erb +0 -0
  17. data/{templates → lib/flatrack/cli/templates}/stylesheet.css.scss +0 -0
  18. data/lib/flatrack/cli.rb +10 -1
  19. data/lib/flatrack/request.rb +2 -2
  20. data/lib/flatrack/response.rb +6 -8
  21. data/lib/flatrack/site.rb +0 -2
  22. data/lib/flatrack/template/erubis/handler.rb +76 -0
  23. data/lib/flatrack/template/erubis.rb +20 -0
  24. data/lib/flatrack/template/html.rb +11 -0
  25. data/lib/flatrack/template/rb.rb +13 -0
  26. data/lib/flatrack/template.rb +35 -0
  27. data/lib/flatrack/version.rb +1 -1
  28. data/lib/flatrack/view/capture_helper.rb +30 -0
  29. data/lib/flatrack/view/link_helper.rb +28 -0
  30. data/lib/flatrack/view/output_buffer.rb +24 -0
  31. data/lib/flatrack/view/render_helper.rb +9 -0
  32. data/lib/flatrack/view/request_helper.rb +13 -0
  33. data/lib/flatrack/view/tag_helper.rb +102 -0
  34. data/lib/flatrack/view.rb +30 -0
  35. data/lib/flatrack.rb +3 -9
  36. data/lib/rake/asset_tasks.rb +31 -23
  37. data/spec/fixtures/assets/sample.css.scss +2 -0
  38. data/spec/fixtures/assets/{application.js.coffee → sample.js.coffee} +1 -1
  39. data/spec/fixtures/templates/html_tag.html +5 -0
  40. data/spec/fixtures/templates/html_tag.html.erb +9 -0
  41. data/spec/fixtures/templates/html_tag.html.rb +5 -0
  42. data/spec/fixtures/templates/image_tag.html +2 -0
  43. data/spec/fixtures/templates/image_tag.html.erb +2 -0
  44. data/spec/fixtures/templates/image_tag.html.rb +2 -0
  45. data/spec/fixtures/templates/javascript_tag.html +2 -0
  46. data/spec/fixtures/templates/javascript_tag.html.erb +2 -0
  47. data/spec/fixtures/templates/javascript_tag.html.rb +2 -0
  48. data/spec/fixtures/templates/link_to.html +9 -0
  49. data/spec/fixtures/templates/link_to.html.erb +11 -0
  50. data/spec/fixtures/templates/link_to.html.rb +7 -0
  51. data/spec/fixtures/templates/stylesheet_tag.html +2 -0
  52. data/spec/fixtures/templates/stylesheet_tag.html.erb +2 -0
  53. data/spec/fixtures/templates/stylesheet_tag.html.rb +2 -0
  54. data/spec/lib/flatrack/asset_extensions_spec.rb +2 -2
  55. data/spec/lib/flatrack/cli_spec.rb +8 -6
  56. data/spec/lib/flatrack/request_spec.rb +4 -4
  57. data/spec/lib/flatrack/response_spec.rb +4 -4
  58. data/spec/lib/flatrack/site_spec.rb +10 -5
  59. data/spec/lib/flatrack/view/link_helper_spec.rb +25 -0
  60. data/spec/lib/flatrack/view/tag_helper_spec.rb +81 -0
  61. data/spec/lib/flatrack/view_spec.rb +52 -0
  62. data/spec/lib/flatrack_spec.rb +1 -1
  63. data/spec/lib/rake/asset_tasks_spec.rb +8 -8
  64. data/spec/spec_helper.rb +3 -2
  65. data/spec/support/fixture_helper.rb +29 -0
  66. data/spec/support/site_helper.rb +43 -39
  67. metadata +126 -33
  68. data/lib/flatrack/renderer/base.rb +0 -19
  69. data/lib/flatrack/renderer.rb +0 -30
  70. data/lib/flatrack/response/view_context.rb +0 -67
  71. data/renderers/erb.rb +0 -9
  72. data/renderers/html.rb +0 -9
  73. data/renderers/rb.rb +0 -19
  74. data/spec/lib/flatrack/renderer/base_spec.rb +0 -4
  75. data/spec/lib/flatrack/response/view_context_spec.rb +0 -93
  76. data/spec/renderers/erb_spec.rb +0 -21
  77. data/spec/renderers/html_spec.rb +0 -21
  78. data/spec/renderers/rb_spec.rb +0 -21
@@ -17,6 +17,33 @@ module Rake
17
17
 
18
18
  delegate :paths, to: :environment
19
19
 
20
+ DEFINED_TASKS = proc do
21
+
22
+ namespace :assets do
23
+ desc 'precompile assets'
24
+ task :precompile do
25
+ with_logger do
26
+ manifest.compile(assets)
27
+ end
28
+ end
29
+
30
+ desc 'Remove all assets'
31
+ task :clobber do
32
+ with_logger do
33
+ manifest.clobber
34
+ end
35
+ end
36
+
37
+ desc 'Clean old assets'
38
+ task :clean do
39
+ with_logger do
40
+ manifest.clean(keep)
41
+ end
42
+ end
43
+ end
44
+
45
+ end
46
+
20
47
  # Number of old assets to keep.
21
48
 
22
49
  # Logger to use during rake tasks. Defaults to using stderr.
@@ -56,7 +83,9 @@ module Rake
56
83
  end
57
84
 
58
85
  def assets
59
- files = paths.reduce([]) { |a, p| a + Dir[File.join p, '**', '*'] }
86
+ files = paths.reduce([]) do |ary, path|
87
+ ary + Dir[File.join path, '**', '*']
88
+ end
60
89
  files.map do |file|
61
90
  file_basename = File.basename file
62
91
  parts = file_basename.split('.').size
@@ -67,28 +96,7 @@ module Rake
67
96
 
68
97
  # Define tasks
69
98
  def define
70
- namespace :assets do
71
- desc 'precompile assets'
72
- task :precompile do
73
- with_logger do
74
- manifest.compile(assets)
75
- end
76
- end
77
-
78
- desc 'Remove all assets'
79
- task :clobber do
80
- with_logger do
81
- manifest.clobber
82
- end
83
- end
84
-
85
- desc 'Clean old assets'
86
- task :clean do
87
- with_logger do
88
- manifest.clean(keep)
89
- end
90
- end
91
- end
99
+ instance_eval(&DEFINED_TASKS)
92
100
  end
93
101
 
94
102
  private
@@ -0,0 +1,2 @@
1
+ //= require_self
2
+ //= require_tree
@@ -1,2 +1,2 @@
1
1
  #= require_self
2
- #= require_tree
2
+ #= require_tree
@@ -0,0 +1,5 @@
1
+ <div>something amazing</div>
2
+ <div data-enabled="true">something amazing</div>
3
+ <div default="default">something amazing</div>
4
+ <div>Hello World</div>
5
+ <div>Goodbye Humanity</div>
@@ -0,0 +1,9 @@
1
+ <%== html_tag :div, 'something amazing' %>
2
+ <%= html_tag :div, 'something amazing', data: { enabled: true } %>
3
+ <%= html_tag :div, 'something amazing', default: true %>
4
+ <%= html_tag(:div) do %>
5
+ Hello World
6
+ <% end %>
7
+ <%== html_tag(:div) do %>
8
+ Goodbye Humanity
9
+ <% end %>
@@ -0,0 +1,5 @@
1
+ html_tag(:div, 'something amazing') +
2
+ html_tag(:div, 'something amazing', data: { enabled: true }) +
3
+ html_tag(:div, 'something amazing', default: true) +
4
+ html_tag(:div) { 'Hello World' } +
5
+ html_tag(:div) { 'Goodbye Humanity' }
@@ -0,0 +1,2 @@
1
+ <img src="http://example.com/image.jpg"/>
2
+ <img src="/assets/logo.png"/>
@@ -0,0 +1,2 @@
1
+ <%= image_tag 'http://example.com/image.jpg' %>
2
+ <%= image_tag 'logo.png' %>
@@ -0,0 +1,2 @@
1
+ image_tag('http://example.com/image.jpg') +
2
+ image_tag('logo.png')
@@ -0,0 +1,2 @@
1
+ <script src="http://example.com/example.js" type="application/javascript"></script>
2
+ <script src="/assets/main.js" type="application/javascript"></script>
@@ -0,0 +1,2 @@
1
+ <%= javascript_tag 'http://example.com/example.js' %>
2
+ <%= javascript_tag :main %>
@@ -0,0 +1,2 @@
1
+ javascript_tag('http://example.com/example.js') +
2
+ javascript_tag(:main)
@@ -0,0 +1,9 @@
1
+ <a href="http://example1.org">example</a>
2
+ <a href="http://example2.org">http://example2.org</a>
3
+ <a href="http://example3.org">Hello World</a>
4
+ <a href="http://example4.org">
5
+ <img src="http://example.org/sample.jpg"/>
6
+ </a>
7
+ <a href="http://example5.org">
8
+ <img src="/assets/sample.jpg"/>
9
+ </a>
@@ -0,0 +1,11 @@
1
+ <%= link_to('example', 'http://example1.org') %>
2
+ <%= link_to('http://example2.org') %>
3
+ <%= link_to('http://example3.org') do %>
4
+ Hello World
5
+ <% end %>
6
+ <%= link_to('http://example4.org') do %>
7
+ <%= image_tag('http://example.org/sample.jpg') %>
8
+ <% end %>
9
+ <%= link_to('http://example5.org') do %>
10
+ <%= image_tag('sample.jpg') %>
11
+ <% end %>
@@ -0,0 +1,7 @@
1
+ link_to('example', 'http://example1.org') +
2
+ link_to('http://example2.org') +
3
+ link_to('http://example3.org') { 'Hello World' } +
4
+ link_to('http://example4.org') do
5
+ image_tag('http://example.org/sample.jpg')
6
+ end +
7
+ link_to('http://example5.org') { image_tag('sample.jpg') }
@@ -0,0 +1,2 @@
1
+ <link href="http://example.com/example.css" rel="stylesheet" type="text/css"/>
2
+ <link href="/assets/main.css" rel="stylesheet" type="text/css"/>
@@ -0,0 +1,2 @@
1
+ <%= stylesheet_tag 'http://example.com/example.css' %>
2
+ <%= stylesheet_tag :main %>
@@ -0,0 +1,2 @@
1
+ stylesheet_tag('http://example.com/example.css') +
2
+ stylesheet_tag(:main)
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Flatrack::AssetExtensions do
4
4
 
5
- subject(:instance){ double.extend described_class }
5
+ subject(:instance) { double.extend described_class }
6
6
 
7
7
  describe '#asset_path' do
8
8
  it 'should be a path to the asset' do
@@ -10,4 +10,4 @@ describe Flatrack::AssetExtensions do
10
10
  end
11
11
  end
12
12
 
13
- end
13
+ end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Flatrack::CLI do
4
4
  extend FileUtils
5
- include SiteHelper
5
+ include Flatrack::SiteHelper
6
6
 
7
7
  describe '#new' do
8
8
  it 'should create a new site' do
@@ -20,7 +20,7 @@ describe Flatrack::CLI do
20
20
  expect do
21
21
  site do
22
22
  thread = Thread.new do
23
- Flatrack::CLI.start(['start', '--verbose', 'false'])
23
+ Flatrack::CLI.start(%w(start --verbose false))
24
24
  end
25
25
  retries = 0
26
26
  begin
@@ -28,7 +28,8 @@ describe Flatrack::CLI do
28
28
  thread.kill
29
29
  rescue Errno::ECONNREFUSED => error
30
30
  retries += 1
31
- sleep 0.1 and retry unless retries > 100
31
+ sleep 0.1
32
+ retry unless retries > 100
32
33
  raise error
33
34
  end
34
35
  end
@@ -39,7 +40,7 @@ describe Flatrack::CLI do
39
40
  expect do
40
41
  site do
41
42
  thread = Thread.new do
42
- Flatrack::CLI.start(['start', '--port', '8282', '--verbose', 'false'])
43
+ Flatrack::CLI.start(%w(start --port 8282 --verbose false))
43
44
  end
44
45
  retries = 0
45
46
  begin
@@ -47,7 +48,8 @@ describe Flatrack::CLI do
47
48
  thread.kill
48
49
  rescue Errno::ECONNREFUSED => error
49
50
  retries += 1
50
- sleep 0.1 and retry unless retries > 100
51
+ sleep 0.1
52
+ retry unless retries > 100
51
53
  raise error
52
54
  end
53
55
  end
@@ -55,4 +57,4 @@ describe Flatrack::CLI do
55
57
  end
56
58
  end
57
59
 
58
- end
60
+ end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Flatrack::Request do
4
- include SiteHelper
4
+ include Flatrack::SiteHelper
5
5
 
6
6
  describe '#response' do
7
7
  it 'should return a 404 for page not found' do
8
8
  site do
9
- status, headers, body = get_page_response('cant_find_me')
9
+ status, _, _ = get_page_response('cant_find_me')
10
10
  expect(status).to eq 404
11
11
  end
12
12
  end
@@ -14,9 +14,9 @@ describe Flatrack::Request do
14
14
  it 'should render a page without a layout' do
15
15
  site do
16
16
  touch 'pages/bad_renderer.html.bad'
17
- status, headers, body = get_page_response('bad_renderer')
17
+ status, _, _ = get_page_response('bad_renderer')
18
18
  expect(status).to eq 500
19
19
  end
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Flatrack::Response do
4
- include SiteHelper
4
+ include Flatrack::SiteHelper
5
5
 
6
6
  describe '#render' do
7
7
  it 'should render a page with a layout' do
8
8
  site do
9
- status, headers, body = get_page_response('index')
9
+ status, _, _ = get_page_response('index')
10
10
  expect(status).to eq 200
11
11
  end
12
12
  end
@@ -14,9 +14,9 @@ describe Flatrack::Response do
14
14
  it 'should render a page without a layout' do
15
15
  site do
16
16
  rm_rf 'layouts/layout.html.erb'
17
- status, headers, body = get_page_response('index')
17
+ status, _, _ = get_page_response('index')
18
18
  expect(status).to eq 200
19
19
  end
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Flatrack::Site do
4
- let(:mock_app){ ->(env){ [200,{},['ok']]} }
5
- let(:mock_env){ Rack::MockRequest.env_for('example.org', {}) }
4
+ let(:mock_app) { ->(env) { [200, {}, ['ok']] } }
5
+ let(:mock_env) { Rack::MockRequest.env_for('example.org', {}) }
6
6
 
7
7
  it 'should be a rack app' do
8
8
  expect(described_class).to respond_to :call
@@ -13,8 +13,13 @@ describe Flatrack::Site do
13
13
 
14
14
  middlewares = 2.times.map do
15
15
  Class.new do
16
- def initialize(app) @app = app end
17
- def call(env) @app.call(env) end
16
+ def initialize(app)
17
+ @app = app
18
+ end
19
+
20
+ def call(env)
21
+ @app.call(env)
22
+ end
18
23
  end
19
24
  end
20
25
 
@@ -36,4 +41,4 @@ describe Flatrack::Site do
36
41
  expect_any_instance_of(Flatrack::Request).to receive(:response)
37
42
  Flatrack::Site.call(mock_env)
38
43
  end
39
- end
44
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Flatrack::View::LinkHelper do
4
+ include Flatrack::FixtureHelper
5
+
6
+ describe '#link_to' do
7
+
8
+ context 'using erb' do
9
+ it 'should properly render' do
10
+ template_content = render_template 'link_to.html.erb'
11
+ expected_content = render_template 'link_to.html'
12
+ expect(template_content).to eq expected_content
13
+ end
14
+ end
15
+
16
+ context 'using rb' do
17
+ it 'should properly render' do
18
+ template_content = render_template 'link_to.html.rb'
19
+ expected_content = render_template 'link_to.html'
20
+ expect(template_content).to eq expected_content
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+
3
+ describe Flatrack::View::TagHelper do
4
+ include Flatrack::FixtureHelper
5
+
6
+ describe '#html_tag' do
7
+ let(:expected) { render_template 'html_tag.html' }
8
+
9
+ context 'using erb' do
10
+ it 'should properly render' do
11
+ template_content = render_template 'html_tag.html.erb'
12
+ expect(template_content).to eq expected
13
+ end
14
+ end
15
+
16
+ context 'using rb' do
17
+ it 'should properly render' do
18
+ template_content = render_template 'html_tag.html.rb'
19
+ expect(template_content).to eq expected
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+ describe '#image_tag' do
26
+ let(:expected) { render_template 'image_tag.html' }
27
+
28
+ context 'using erb' do
29
+ it 'should properly render' do
30
+ template_content = render_template 'image_tag.html.erb'
31
+ expect(template_content).to eq expected
32
+ end
33
+ end
34
+
35
+ context 'using rb' do
36
+ it 'should properly render' do
37
+ template_content = render_template 'image_tag.html.rb'
38
+ expect(template_content).to eq expected
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ describe '#javascript_tag' do
45
+ let(:expected) { render_template 'javascript_tag.html' }
46
+
47
+ context 'using erb' do
48
+ it 'should properly render' do
49
+ template_content = render_template 'javascript_tag.html.erb'
50
+ expect(template_content).to eq expected
51
+ end
52
+ end
53
+
54
+ context 'using rb' do
55
+ it 'should properly render' do
56
+ template_content = render_template 'javascript_tag.html.rb'
57
+ expect(template_content).to eq expected
58
+ end
59
+ end
60
+
61
+ end
62
+
63
+ describe '#stylesheet_tag' do
64
+ let(:expected) { render_template 'stylesheet_tag.html' }
65
+
66
+ context 'using erb' do
67
+ it 'should properly render' do
68
+ template_content = render_template 'stylesheet_tag.html.erb'
69
+ expect(template_content).to eq expected
70
+ end
71
+ end
72
+
73
+ context 'using rb' do
74
+ it 'should properly render' do
75
+ template_content = render_template 'stylesheet_tag.html.rb'
76
+ expect(template_content).to eq expected
77
+ end
78
+ end
79
+
80
+ end
81
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe Flatrack::View do
4
+ include Flatrack::SiteHelper
5
+
6
+ let(:uri) { URI.parse 'http://example.org/index.html' }
7
+ let(:env) { Rack::MockRequest.env_for uri.to_s }
8
+ let(:request) { Flatrack::Request.new env }
9
+ let(:response) { Flatrack::Response.new request }
10
+ subject(:view) { described_class.new response }
11
+
12
+ describe '#initialize' do
13
+ it 'should set the response' do
14
+ view = described_class.allocate
15
+ expect do
16
+ view.send :initialize, response
17
+ end.to change {
18
+ view.instance_variable_get :@response
19
+ }.to response
20
+ end
21
+ end
22
+
23
+ describe '#params' do
24
+ let(:uri) { URI.parse 'http://example.org/index.html?foo=bar' }
25
+ it 'should be extracted from the uri path' do
26
+ expect(view.params).to include foo: 'bar'
27
+ end
28
+ end
29
+
30
+ describe '#path' do
31
+ it 'should be extracted from the uri path' do
32
+ expect(view.path).to eq uri.path
33
+ end
34
+ end
35
+
36
+ describe '#render' do
37
+ let(:template) do
38
+ <<-ERB
39
+ <%= 'Hello World'.reverse %>
40
+ ERB
41
+ end
42
+
43
+ it 'should properly render a partial' do
44
+ site do
45
+ write(:partial, 'sample.erb', template)
46
+ result = view.render(:sample)
47
+ expect(result).to include 'Hello World'.reverse
48
+ end
49
+ end
50
+ end
51
+
52
+ end
@@ -25,4 +25,4 @@ describe Flatrack do
25
25
  end
26
26
  end
27
27
 
28
- end
28
+ end
@@ -4,7 +4,7 @@ require 'rake/asset_tasks'
4
4
 
5
5
  describe Rake::AssetTasks do
6
6
  include FileUtils
7
- include SiteHelper
7
+ include Flatrack::SiteHelper
8
8
 
9
9
  before(:all) do
10
10
  @sha = site(clean: false) do
@@ -12,7 +12,7 @@ describe Rake::AssetTasks do
12
12
  Rake.application = @rake
13
13
 
14
14
  @env = Flatrack.assets
15
- @dir = File.join(Dir::tmpdir, 'sprockets/manifest')
15
+ @dir = File.join(Dir.tmpdir, 'sprockets/manifest')
16
16
 
17
17
  Rake::AssetTasks.new do |t|
18
18
  t.output = @dir
@@ -43,7 +43,7 @@ describe Rake::AssetTasks do
43
43
 
44
44
  describe 'tasks' do
45
45
 
46
- it "should precompile" do
46
+ it 'should precompile' do
47
47
  digest_path = @env['main.js'].digest_path
48
48
  expect(File.exist? "#{@dir}/#{digest_path}").to be false
49
49
 
@@ -53,7 +53,7 @@ describe Rake::AssetTasks do
53
53
  expect(File.exist? "#{@dir}/#{digest_path}").to be true
54
54
  end
55
55
 
56
- it "should clobber" do
56
+ it 'should clobber' do
57
57
  digest_path = @env['main.js'].digest_path
58
58
 
59
59
  @rake['assets:precompile'].invoke
@@ -63,11 +63,11 @@ describe Rake::AssetTasks do
63
63
  expect(File.exist? "#{@dir}/#{digest_path}").to be false
64
64
  end
65
65
 
66
- it "should clean" do
67
- expect {
66
+ it 'should clean' do
67
+ expect do
68
68
  @rake['assets:clean'].invoke
69
- }.to_not raise_error
69
+ end.to_not raise_error
70
70
  end
71
71
 
72
72
  end
73
- end
73
+ end
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,7 @@ $LOAD_PATH.unshift File.expand_path File.dirname(__FILE__)
2
2
 
3
3
  require 'simplecov'
4
4
  require 'coveralls'
5
+ require 'pry'
5
6
 
6
7
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
8
  SimpleCov::Formatter::HTMLFormatter,
@@ -12,10 +13,10 @@ SimpleCov.start do
12
13
  end
13
14
 
14
15
  require 'flatrack'
15
- Dir["./spec/support/**/*.rb"].sort.each {|f| require f}
16
+ Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
16
17
 
17
18
  RSpec.configure do |config|
18
19
  config.run_all_when_everything_filtered = true
19
20
  config.filter_run focus: true
20
- config.before(:each){ Flatrack.reset! }
21
+ config.before(:each) { Flatrack.reset! }
21
22
  end
@@ -0,0 +1,29 @@
1
+ class Flatrack
2
+ module FixtureHelper
3
+ extend FileUtils
4
+ include FileUtils
5
+
6
+ def render_template(fixture)
7
+ path = File.join Flatrack.gem_root, '../spec/fixtures/templates', fixture
8
+ view.render(path).lines.map(&:strip).join
9
+ end
10
+
11
+ private
12
+
13
+ def response
14
+ Flatrack::Response.new request
15
+ end
16
+
17
+ def request
18
+ Flatrack::Request.new env
19
+ end
20
+
21
+ def view
22
+ Flatrack::View.new response
23
+ end
24
+
25
+ def env
26
+ Rack::MockRequest.env_for 'http://example.org/index.html'
27
+ end
28
+ end
29
+ end