deas 0.36.0 → 0.37.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.
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: c4676b93d32b63bba485b4137c0983725b08ad0b
4
- data.tar.gz: 4047d05f7b72713a7a999b19d50d808366180bfb
5
- SHA512:
6
- metadata.gz: a3eb2b3a29678f4de02bfe510b4801669740130773c74e377770e3f9cd8df08b3a088aca928eda3555a37c34a1fa232a2b5b01dafff2d6038f1addcf29e80c34
7
- data.tar.gz: 7ae9da0d7f9a45110001b374fd9a23fd10b18232f3da04a90462ac0f406cac335eb5cd9746e9cf9fd444596c5278d69b20b4f895389a1046a0295d0e7cfe8889
@@ -1,154 +0,0 @@
1
- require 'assert'
2
- require 'deas/server'
3
-
4
- require 'deas/exceptions'
5
- require 'deas/logger'
6
- require 'deas/router'
7
- require 'deas/template_source'
8
- require 'test/support/view_handlers'
9
-
10
- class Deas::Server::Configuration
11
-
12
- class UnitTests < Assert::Context
13
- desc "Deas::Server::Configuration"
14
- setup do
15
- @configuration = Deas::Server::Configuration.new
16
- @configuration.root = TEST_SUPPORT_ROOT
17
- end
18
- subject{ @configuration }
19
-
20
- # sinatra-based options
21
-
22
- should have_imeths :env, :root, :public_root, :views_root
23
- should have_imeths :dump_errors, :method_override, :sessions, :show_exceptions
24
- should have_imeths :static_files, :reload_templates, :default_encoding
25
-
26
- # server handling options
27
-
28
- should have_imeths :verbose_logging, :logger, :template_source
29
-
30
- should have_accessors :settings, :error_procs, :init_procs, :template_helpers
31
- should have_accessors :middlewares, :router
32
- should have_imeths :valid?, :validate!, :urls, :routes
33
-
34
- should "default the env to 'development'" do
35
- assert_equal 'development', subject.env
36
- end
37
-
38
- should "default the public and views folders based off the root" do
39
- assert_equal subject.root.join('public'), subject.public_root
40
- assert_equal subject.root.join('views'), subject.views_root
41
- end
42
-
43
- should "default the Sinatra flags" do
44
- assert_equal false, subject.dump_errors
45
- assert_equal true, subject.method_override
46
- assert_equal false, subject.sessions
47
- assert_equal false, subject.show_exceptions
48
- assert_equal true, subject.static_files
49
- assert_equal false, subject.reload_templates
50
- end
51
-
52
- should "default the handling options" do
53
- assert_equal true, subject.verbose_logging
54
- assert_instance_of Deas::NullLogger, subject.logger
55
- assert_instance_of Deas::NullTemplateSource, subject.template_source
56
- end
57
-
58
- should "default its stored configuration" do
59
- assert_empty subject.settings
60
- assert_empty subject.error_procs
61
- assert_empty subject.init_procs
62
- assert_empty subject.template_helpers
63
- assert_empty subject.middlewares
64
- assert_empty subject.routes
65
- assert_empty subject.urls
66
- assert_kind_of Deas::Router, subject.router
67
- end
68
-
69
- should "not be valid until validate! has been run" do
70
- assert_not subject.valid?
71
-
72
- subject.validate!
73
- assert subject.valid?
74
- end
75
-
76
- should "complain if validating and `root` isn't set" do
77
- config = Deas::Server::Configuration.new
78
- assert_raises(Deas::ServerRootError){ config.validate! }
79
- assert_nothing_raised{ config.root '/path/to/root'; config.validate! }
80
- end
81
-
82
- should "use `utf-8` as the default encoding by default" do
83
- assert_equal 'utf-8', subject.default_encoding
84
- end
85
-
86
- end
87
-
88
- class ValidationTests < UnitTests
89
- desc "when successfully validated"
90
- setup do
91
- @initialized = false
92
- @other_initialized = false
93
- @router = Deas::Router.new
94
- @route = @router.get('/something', 'EmptyViewHandler')
95
- @proxy = @route.handler_proxies[@router.default_request_type_name]
96
-
97
- @configuration = Deas::Server::Configuration.new.tap do |c|
98
- c.env = 'staging'
99
- c.root = 'path/to/somewhere'
100
- c.dump_errors = true
101
- c.method_override = false
102
- c.sessions = false
103
- c.show_exceptions = true
104
- c.static = true
105
- c.reload_templates = true
106
- c.middlewares = [ ['MyMiddleware'] ]
107
- c.router = @router
108
- end
109
- @configuration.init_procs << proc{ @initialized = true }
110
- @configuration.init_procs << proc{ @other_initialized = true }
111
- end
112
-
113
- should "call init procs" do
114
- assert_equal false, @initialized
115
- assert_equal false, @other_initialized
116
-
117
- subject.validate!
118
-
119
- assert_equal true, @initialized
120
- assert_equal true, @other_initialized
121
- end
122
-
123
- should "call validate! on all routes" do
124
- assert_nil @proxy.handler_class
125
-
126
- subject.validate!
127
- assert_equal EmptyViewHandler, @proxy.handler_class
128
- end
129
-
130
- should "default the :erb :outvar setting in the SinatraApp it creates" do
131
- assert_nil subject.settings[:erb]
132
-
133
- subject.validate!
134
-
135
- assert_kind_of ::Hash, subject.settings[:erb]
136
- assert_equal '@_out_buf', subject.settings[:erb][:outvar]
137
- end
138
-
139
- should "add the Logging and ShowExceptions middleware to the end" do
140
- num_middlewares = subject.middlewares.size
141
- assert subject.verbose_logging
142
- assert_not_equal [Deas::ShowExceptions], subject.middlewares[-2]
143
- assert_not_equal [Deas::VerboseLogging], subject.middlewares[-1]
144
-
145
- subject.validate!
146
-
147
- assert_equal (num_middlewares+2), subject.middlewares.size
148
- assert_equal [Deas::ShowExceptions], subject.middlewares[-2]
149
- assert_equal [Deas::VerboseLogging], subject.middlewares[-1]
150
- end
151
-
152
- end
153
-
154
- end