true-web 0.1.3 → 0.1.4

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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- true-web (0.1.2)
4
+ true-web (0.1.3)
5
5
  activesupport (>= 3.0.0)
6
6
  honkster-addressable (>= 2.2.3)
7
7
  mustache
@@ -38,6 +38,9 @@ module TrueWeb
38
38
 
39
39
  error(500) do
40
40
  env["rack.exception"] = env["sinatra.error"]
41
+ if env["rack.logger"]
42
+ env["rack.logger"].error "#{env["sinatra.error"].message}\n#{env["sinatra.error"].backtrace.join("\n\t")}"
43
+ end
41
44
  "<div>Oops, an error occurred.</div>"
42
45
  end
43
46
 
@@ -1,3 +1,3 @@
1
1
  module TrueWeb
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -3,11 +3,13 @@ module FixtureApp
3
3
 
4
4
  def self.app
5
5
  @app ||= Rack::Builder.new do
6
+ use Rack::Logger
6
7
  run ::FixtureApp::Controller
7
8
  end.to_app
8
9
  end
9
10
 
10
11
  class Controller < ::TrueWeb::Controller
12
+ set :dump_errors, false
11
13
  end
12
14
 
13
15
  class Views < ::TrueWeb::Views
@@ -0,0 +1,6 @@
1
+ FixtureApp::Controller.define_routes do
2
+ def authentication_error_page; end
3
+ get path(:authentication_error_page, "/authentication/error-page") do
4
+ raise "An Error"
5
+ end
6
+ end
@@ -0,0 +1,47 @@
1
+ RSpec::Core::ExampleGroup.class_eval do
2
+ include Capybara
3
+
4
+ def app
5
+ FixtureApp::Controller
6
+ end
7
+
8
+ def uris
9
+ @uris ||= FixtureApp::Routes.instance
10
+ end
11
+ alias_method :named_routes, :uris
12
+
13
+ def views
14
+ @views ||= begin
15
+ app_instance = Capybara.app.allocate
16
+ app_instance.send(:initialize)
17
+ app_instance.session_data = session_data
18
+ ::FixtureApp::Views.new(app_instance)
19
+ end
20
+ end
21
+
22
+ [
23
+ :request, :last_request, :response, :last_response, :follow_redirect!,
24
+ :rack_mock_session
25
+ ].each do |method_name|
26
+ class_eval((<<-RUBY), __FILE__, __LINE__+1)
27
+ def #{method_name}(*args, &block)
28
+ page.driver.#{method_name}(*args, &block)
29
+ end
30
+ RUBY
31
+ end
32
+
33
+ [:get, :put, :post, :delete].each do |method_name|
34
+ class_eval((<<-RUBY), __FILE__, __LINE__+1)
35
+ def #{method_name}(*args, &block)
36
+ (res = page.driver.#{method_name}(*args, &block)).tap do
37
+ puts res.errors if res.status == 500
38
+ end
39
+ end
40
+ RUBY
41
+ end
42
+
43
+ def current_path
44
+ Addressable::URI.parse(current_url).path
45
+ end
46
+
47
+ end
@@ -0,0 +1,36 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
2
+
3
+ module TrueWeb
4
+ describe Controller do
5
+ describe "GET /authentication/error-page" do
6
+ context "when there is not a rack.logger" do
7
+ it "responds with a 500" do
8
+ any_instance_of(FixtureApp::Controller) do |controller|
9
+ stub.proxy(controller).env do |env|
10
+ env.delete("rack.logger")
11
+ env
12
+ end
13
+ end
14
+ get uris.authentication_error_page
15
+
16
+ response.status.should == 500
17
+ end
18
+ end
19
+
20
+ context "when there is a rack.logger" do
21
+ it "responds with a 500 and logs the message" do
22
+ message = nil
23
+ any_instance_of(Logger) do |l|
24
+ stub(l).error(is_a(String)) do |*args|
25
+ message = args.first
26
+ end
27
+ end
28
+ get uris.authentication_error_page
29
+
30
+ response.status.should == 500
31
+ message.should include("An Error")
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: true-web
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.3
5
+ version: 0.1.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Brian Takita
@@ -181,12 +181,15 @@ files:
181
181
  - lib/true-web/version.rb
182
182
  - lib/true-web/views.rb
183
183
  - spec/fixture-app/app.rb
184
+ - spec/fixture-app/services/authentication/app/controllers/authentication.rb
184
185
  - spec/fixture-app/services/authentication/app/presenters/index.html.ms.rb
185
186
  - spec/fixture-app/services/authentication/app/templates/index.html.ms
186
187
  - spec/fixture-app/services/authentication/init.rb
187
188
  - spec/fixture-app/services/authentication/public/javascripts/foo.js
188
189
  - spec/spec_helper.rb
190
+ - spec/spec_helpers/example_group.rb
189
191
  - spec/spec_suite.rb
192
+ - spec/true-web/controller_spec.rb
190
193
  - spec/true-web/service_spec.rb
191
194
  - spec/true-web/views_spec.rb
192
195
  - true-web.gemspec