rita 0.1.0 → 5.0.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +19 -0
  3. data/.rubocop.yml +51 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +16 -0
  6. data/CONTRIBUTING.md +18 -0
  7. data/Gemfile +5 -0
  8. data/{LICENSE.txt → LICENSE} +1 -3
  9. data/README.md +17 -24
  10. data/Rakefile +5 -5
  11. data/bin/lita +7 -0
  12. data/lib/lita/adapter.rb +147 -0
  13. data/lib/lita/adapters/shell.rb +126 -0
  14. data/lib/lita/adapters/test.rb +62 -0
  15. data/lib/lita/authorization.rb +112 -0
  16. data/lib/lita/callback.rb +39 -0
  17. data/lib/lita/cli.rb +218 -0
  18. data/lib/lita/configurable.rb +47 -0
  19. data/lib/lita/configuration_builder.rb +247 -0
  20. data/lib/lita/configuration_validator.rb +95 -0
  21. data/lib/lita/default_configuration.rb +122 -0
  22. data/lib/lita/errors.rb +25 -0
  23. data/lib/lita/handler/chat_router.rb +141 -0
  24. data/lib/lita/handler/common.rb +208 -0
  25. data/lib/lita/handler/event_router.rb +84 -0
  26. data/lib/lita/handler/http_router.rb +31 -0
  27. data/lib/lita/handler.rb +15 -0
  28. data/lib/lita/handlers/authorization.rb +129 -0
  29. data/lib/lita/handlers/help.rb +171 -0
  30. data/lib/lita/handlers/info.rb +66 -0
  31. data/lib/lita/handlers/room.rb +36 -0
  32. data/lib/lita/handlers/users.rb +37 -0
  33. data/lib/lita/http_callback.rb +46 -0
  34. data/lib/lita/http_route.rb +83 -0
  35. data/lib/lita/logger.rb +43 -0
  36. data/lib/lita/message.rb +124 -0
  37. data/lib/lita/middleware_registry.rb +39 -0
  38. data/lib/lita/namespace.rb +29 -0
  39. data/lib/lita/plugin_builder.rb +43 -0
  40. data/lib/lita/rack_app.rb +100 -0
  41. data/lib/lita/registry.rb +164 -0
  42. data/lib/lita/response.rb +65 -0
  43. data/lib/lita/robot.rb +273 -0
  44. data/lib/lita/room.rb +119 -0
  45. data/lib/lita/route_validator.rb +82 -0
  46. data/lib/lita/rspec/handler.rb +127 -0
  47. data/lib/lita/rspec/matchers/chat_route_matcher.rb +53 -0
  48. data/lib/lita/rspec/matchers/event_route_matcher.rb +29 -0
  49. data/lib/lita/rspec/matchers/http_route_matcher.rb +34 -0
  50. data/lib/lita/rspec.rb +48 -0
  51. data/lib/lita/source.rb +81 -0
  52. data/lib/lita/store.rb +23 -0
  53. data/lib/lita/target.rb +3 -0
  54. data/lib/lita/template.rb +71 -0
  55. data/lib/lita/template_resolver.rb +52 -0
  56. data/lib/lita/timer.rb +49 -0
  57. data/lib/lita/user.rb +157 -0
  58. data/lib/lita/util.rb +31 -0
  59. data/lib/lita/version.rb +6 -0
  60. data/lib/lita.rb +166 -0
  61. data/lib/rita.rb +2 -7
  62. data/rita.gemspec +50 -0
  63. data/spec/lita/adapter_spec.rb +54 -0
  64. data/spec/lita/adapters/shell_spec.rb +99 -0
  65. data/spec/lita/authorization_spec.rb +122 -0
  66. data/spec/lita/configuration_builder_spec.rb +247 -0
  67. data/spec/lita/configuration_validator_spec.rb +114 -0
  68. data/spec/lita/default_configuration_spec.rb +242 -0
  69. data/spec/lita/handler/chat_router_spec.rb +236 -0
  70. data/spec/lita/handler/common_spec.rb +289 -0
  71. data/spec/lita/handler/event_router_spec.rb +121 -0
  72. data/spec/lita/handler/http_router_spec.rb +155 -0
  73. data/spec/lita/handler_spec.rb +62 -0
  74. data/spec/lita/handlers/authorization_spec.rb +111 -0
  75. data/spec/lita/handlers/help_spec.rb +124 -0
  76. data/spec/lita/handlers/info_spec.rb +67 -0
  77. data/spec/lita/handlers/room_spec.rb +24 -0
  78. data/spec/lita/handlers/users_spec.rb +35 -0
  79. data/spec/lita/logger_spec.rb +28 -0
  80. data/spec/lita/message_spec.rb +178 -0
  81. data/spec/lita/plugin_builder_spec.rb +41 -0
  82. data/spec/lita/response_spec.rb +62 -0
  83. data/spec/lita/robot_spec.rb +285 -0
  84. data/spec/lita/room_spec.rb +136 -0
  85. data/spec/lita/rspec/handler_spec.rb +33 -0
  86. data/spec/lita/rspec_spec.rb +162 -0
  87. data/spec/lita/source_spec.rb +68 -0
  88. data/spec/lita/store_spec.rb +23 -0
  89. data/spec/lita/template_resolver_spec.rb +42 -0
  90. data/spec/lita/template_spec.rb +52 -0
  91. data/spec/lita/timer_spec.rb +32 -0
  92. data/spec/lita/user_spec.rb +167 -0
  93. data/spec/lita/util_spec.rb +18 -0
  94. data/spec/lita_spec.rb +227 -0
  95. data/spec/spec_helper.rb +35 -0
  96. data/spec/templates/basic.erb +1 -0
  97. data/spec/templates/basic.irc.erb +1 -0
  98. data/spec/templates/helpers.erb +1 -0
  99. data/spec/templates/interpolated.erb +1 -0
  100. data/templates/locales/en.yml +137 -0
  101. data/templates/plugin/Gemfile +5 -0
  102. data/templates/plugin/README.tt +29 -0
  103. data/templates/plugin/Rakefile +8 -0
  104. data/templates/plugin/gemspec.tt +27 -0
  105. data/templates/plugin/gitignore +18 -0
  106. data/templates/plugin/lib/lita/plugin_type/plugin.tt +19 -0
  107. data/templates/plugin/lib/plugin.tt +16 -0
  108. data/templates/plugin/locales/en.yml.tt +4 -0
  109. data/templates/plugin/spec/lita/plugin_type/plugin_spec.tt +6 -0
  110. data/templates/plugin/spec/spec_helper.tt +8 -0
  111. data/templates/plugin/templates/gitkeep +0 -0
  112. data/templates/robot/Gemfile +5 -0
  113. data/templates/robot/lita_config.rb +28 -0
  114. metadata +386 -20
  115. data/.standard.yml +0 -3
  116. data/CHANGELOG.md +0 -5
  117. data/CODE_OF_CONDUCT.md +0 -132
  118. data/lib/rita/version.rb +0 -5
  119. data/sig/rita.rbs +0 -4
@@ -0,0 +1,247 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ describe Lita::ConfigurationBuilder do
6
+ let(:config) { subject.build }
7
+
8
+ describe ".load_user_config" do
9
+ it "loads and evals lita_config.rb" do
10
+ allow(File).to receive(:exist?).and_return(true)
11
+ allow(described_class).to receive(:load) do
12
+ Lita.configure { |c| c.robot.name = "Not Lita" }
13
+ end
14
+ described_class.load_user_config
15
+ expect(Lita.config.robot.name).to eq("Not Lita")
16
+ end
17
+
18
+ it "doesn't attempt to load lita_config.rb if it doesn't exist" do
19
+ allow(File).to receive(:exist?).and_return(false)
20
+ expect(described_class).not_to receive(:load)
21
+ described_class.load_user_config
22
+ end
23
+
24
+ it "raises an exception if lita_config.rb raises a non-config-validation exception" do
25
+ allow(File).to receive(:exist?).and_return(true)
26
+ allow(described_class).to receive(:load) { Lita.non_existent_method }
27
+ expect(Lita.logger).to receive(:fatal).with(/could not be processed/)
28
+ expect { described_class.load_user_config }.to raise_error(SystemExit)
29
+ end
30
+ end
31
+
32
+ describe "a simple attribute" do
33
+ before { subject.config :simple }
34
+
35
+ it "is nil by default" do
36
+ expect(config.simple).to be_nil
37
+ end
38
+
39
+ it "can be set to anything" do
40
+ config.simple = 1
41
+ expect(config.simple).to eq(1)
42
+ end
43
+ end
44
+
45
+ describe "a typed attribute" do
46
+ before { subject.config :simple, type: Symbol }
47
+
48
+ it "is nil by default" do
49
+ expect(config.simple).to be_nil
50
+ end
51
+
52
+ it "can be set to a value of the type" do
53
+ config.simple = :foo
54
+ expect(config.simple).to eq(:foo)
55
+ end
56
+
57
+ it "raises if set to a value of the wrong type" do
58
+ expect(Lita.logger).to receive(:fatal).with(
59
+ /Configuration type error: "simple" must be one of: Symbol/
60
+ )
61
+ expect { config.simple = "foo" }.to raise_error(Lita::ValidationError)
62
+ end
63
+ end
64
+
65
+ describe "a composite typed attribute" do
66
+ before { subject.config :simple, types: [Symbol, String] }
67
+
68
+ it "is nil by default" do
69
+ expect(config.simple).to be_nil
70
+ end
71
+
72
+ it "can be set to a value of the first type" do
73
+ config.simple = :foo
74
+ expect(config.simple).to eq(:foo)
75
+ end
76
+
77
+ it "can be set to a value of the second type" do
78
+ config.simple = "foo"
79
+ expect(config.simple).to eq("foo")
80
+ end
81
+
82
+ it "raises if set to a value of the wrong type" do
83
+ expect(Lita.logger).to receive(:fatal).with(
84
+ /Configuration type error: "simple" must be one of: Symbol, String/
85
+ )
86
+ expect { config.simple = 1 }.to raise_error(Lita::ValidationError)
87
+ end
88
+ end
89
+
90
+ describe "an attribute with a default value" do
91
+ before { subject.config :simple, default: :foo }
92
+
93
+ it "starts with the default value" do
94
+ expect(config.simple).to eq(:foo)
95
+ end
96
+
97
+ it "can be reassigned" do
98
+ config.simple = :bar
99
+ expect(config.simple).to eq(:bar)
100
+ end
101
+ end
102
+
103
+ describe "a typed attribute with a default value" do
104
+ it "starts with the default value" do
105
+ subject.config :simple, type: Symbol, default: :foo
106
+ expect(config.simple).to eq(:foo)
107
+ end
108
+
109
+ it "raises if the default is a value of the wrong type" do
110
+ expect { subject.config :simple, type: Symbol, default: "foo" }.to raise_error(TypeError)
111
+ end
112
+ end
113
+
114
+ describe "a validated attribute" do
115
+ before do
116
+ subject.config :simple do
117
+ validate { |value| "must be 'foo'" unless value == "foo" }
118
+ end
119
+ end
120
+
121
+ it "can be set to a value that passes validation" do
122
+ config.simple = "foo"
123
+ expect(config.simple).to eq("foo")
124
+ end
125
+
126
+ it "raises if the validator raises due to an invalid value" do
127
+ expect(Lita.logger).to receive(:fatal).with(
128
+ /Validation error on attribute "simple": must be 'foo'/
129
+ )
130
+ expect { config.simple = "bar" }.to raise_error(Lita::ValidationError)
131
+ end
132
+ end
133
+
134
+ describe "a validated attribute with a conflicting default value" do
135
+ it "raises a ValidationError" do
136
+ expect do
137
+ subject.config :simple, default: :foo do
138
+ validate { |value| "must be :bar" unless value == :bar }
139
+ end
140
+ end.to raise_error(Lita::ValidationError, /must be :bar/)
141
+ end
142
+ end
143
+
144
+ describe "a simple nested attribute" do
145
+ before do
146
+ subject.config :nested do
147
+ config :foo
148
+ end
149
+ end
150
+
151
+ it "is nil by default" do
152
+ expect(config.nested.foo).to be_nil
153
+ end
154
+
155
+ it "can be set to anything" do
156
+ config.nested.foo = :bar
157
+ expect(config.nested.foo).to eq(:bar)
158
+ end
159
+
160
+ it "prevents the parent from being assigned" do
161
+ expect { config.nested = "impossible" }.to raise_error(NoMethodError)
162
+ end
163
+ end
164
+
165
+ describe "an attribute with all the options and nested attributes" do
166
+ before do
167
+ subject.config :nested, type: Symbol, default: :foo do
168
+ config :foo
169
+ end
170
+ end
171
+
172
+ it "cannot be set" do
173
+ expect { config.nested = "impossible" }.to raise_error(NoMethodError)
174
+ end
175
+ end
176
+
177
+ describe "multiple nested attributes with options" do
178
+ before do
179
+ subject.config :nested do
180
+ config :foo, default: "bar" do
181
+ validate { |value| "must include bar" unless value.include?("bar") }
182
+ end
183
+
184
+ config :bar, type: Symbol
185
+ end
186
+ end
187
+
188
+ it "can get the first nested attribute" do
189
+ expect(config.nested.foo).to eq("bar")
190
+ end
191
+
192
+ it "can set the first nested attribute" do
193
+ config.nested.foo = "foo bar baz"
194
+ expect(config.nested.foo).to eq("foo bar baz")
195
+ end
196
+
197
+ it "has working validation" do
198
+ expect(Lita.logger).to receive(:fatal).with(
199
+ /Validation error on attribute "foo": must include bar/
200
+ )
201
+ expect { config.nested.foo = "baz" }.to raise_error(Lita::ValidationError)
202
+ end
203
+
204
+ it "can get the second nested attribute" do
205
+ expect(config.nested.bar).to be_nil
206
+ end
207
+
208
+ it "can set the second nested attribute and options take effect" do
209
+ expect(Lita.logger).to receive(:fatal).with(
210
+ /Configuration type error: "bar" must be one of: Symbol/
211
+ )
212
+ expect { config.nested.bar = "not a symbol" }.to raise_error(Lita::ValidationError)
213
+ end
214
+ end
215
+
216
+ describe "#has_children?" do
217
+ it "is true when any attribute has been created" do
218
+ subject.config :foo
219
+
220
+ expect(subject.children?).to be_truthy
221
+ end
222
+
223
+ it "is false when no attributes have been created" do
224
+ expect(subject.children?).to be_falsy
225
+ end
226
+ end
227
+
228
+ describe "#combine" do
229
+ let(:config_2) do
230
+ config_2 = described_class.new
231
+ config_2.config(:bar)
232
+ config_2
233
+ end
234
+
235
+ it "sets the provided configuration as the value of the provided attribute" do
236
+ subject.combine(:foo, config_2)
237
+
238
+ expect(config.foo.bar).to be_nil
239
+ end
240
+
241
+ it "does not allow the combined configuration to be reassigned" do
242
+ subject.combine(:foo, config_2)
243
+
244
+ expect { config.foo = "bar" }.to raise_error(NoMethodError)
245
+ end
246
+ end
247
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ describe Lita::ConfigurationValidator, lita: true do
6
+ subject { described_class.new(registry) }
7
+
8
+ describe "#call" do
9
+ it "has no effect if there are no plugins registered" do
10
+ expect { subject.call }.not_to raise_error
11
+ end
12
+
13
+ it "has no effect if all adapters have valid configuration" do
14
+ registry.register_adapter(:config_validator_test) do
15
+ config :foo, required: true, default: :bar
16
+ end
17
+
18
+ expect { subject.call }.not_to raise_error
19
+ end
20
+
21
+ it "raises if a required adapter configuration attribute is missing" do
22
+ registry.register_adapter(:config_validator_test) do
23
+ config :foo, required: true
24
+ end
25
+
26
+ expect(Lita.logger).to receive(:fatal).with(
27
+ /Configuration attribute "foo" is required for "config_validator_test" adapter/
28
+ )
29
+ expect { subject.call }.to raise_error(SystemExit)
30
+ end
31
+
32
+ it "has no effect if all adapters with nested configuration have valid configuration" do
33
+ registry.register_adapter(:config_validator_test) do
34
+ config :foo do
35
+ config :bar, required: true, default: :baz
36
+ end
37
+ end
38
+
39
+ expect { subject.call }.not_to raise_error
40
+ end
41
+
42
+ it "raises if a required nested adapter configuration attribute is missing" do
43
+ registry.register_adapter(:config_validator_test) do
44
+ config :foo do
45
+ config :bar, required: true
46
+ end
47
+ end
48
+
49
+ expect(Lita.logger).to receive(:fatal).with(
50
+ /Configuration attribute "foo\.bar" is required for "config_validator_test" adapter/
51
+ )
52
+ expect { subject.call }.to raise_error(SystemExit)
53
+ end
54
+
55
+ it "uses the right namespace for a nested attribute when a previous nesting has been visited" do
56
+ registry.register_adapter(:config_validator_test) do
57
+ config :foo do
58
+ config :bar
59
+ end
60
+
61
+ config :one do
62
+ config :two, required: true
63
+ end
64
+ end
65
+
66
+ expect(Lita.logger).to receive(:fatal).with(
67
+ /Configuration attribute "one\.two" is required for "config_validator_test" adapter/
68
+ )
69
+ expect { subject.call }.to raise_error(SystemExit)
70
+ end
71
+
72
+ it "has no effect if all handlers have valid configuration" do
73
+ registry.register_handler(:config_validator_test) do
74
+ config :foo, required: true, default: :bar
75
+ end
76
+
77
+ expect { subject.call }.not_to raise_error
78
+ end
79
+
80
+ it "raises if a required handler configuration attribute is missing" do
81
+ registry.register_handler(:config_validator_test) do
82
+ config :foo, required: true
83
+ end
84
+
85
+ expect(Lita.logger).to receive(:fatal).with(
86
+ /Configuration attribute "foo" is required for "config_validator_test" handler/
87
+ )
88
+ expect { subject.call }.to raise_error(SystemExit)
89
+ end
90
+
91
+ it "has no effect if all handlers with nested configuration have valid configuration" do
92
+ registry.register_handler(:config_validator_test) do
93
+ config :foo do
94
+ config :bar, required: true, default: :baz
95
+ end
96
+ end
97
+
98
+ expect { subject.call }.not_to raise_error
99
+ end
100
+
101
+ it "raises if a required nested handler configuration attribute is missing" do
102
+ registry.register_handler(:config_validator_test) do
103
+ config :foo do
104
+ config :bar, required: true
105
+ end
106
+ end
107
+
108
+ expect(Lita.logger).to receive(:fatal).with(
109
+ /Configuration attribute "foo\.bar" is required for "config_validator_test" handler/
110
+ )
111
+ expect { subject.call }.to raise_error(SystemExit)
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,242 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ describe Lita::DefaultConfiguration, lita: true do
6
+ subject { described_class.new(registry) }
7
+
8
+ let(:config) { subject.build }
9
+
10
+ describe "adapters config" do
11
+ context "with no adapters with config attributes" do
12
+ it "has an adapters attribute" do
13
+ expect(config).to respond_to(:adapters)
14
+ end
15
+ end
16
+
17
+ context "with one adapter with no configuration" do
18
+ it "has an attribute for the adapter" do
19
+ # rubocop:disable Lint/EmptyBlock
20
+ registry.register_adapter(:foo) {}
21
+ # rubocop:enable Lint/EmptyBlock
22
+
23
+ expect(config.adapters).to respond_to(:foo)
24
+ end
25
+ end
26
+
27
+ context "with an adapter with configuration" do
28
+ it "has an attribute for the handler with its own attributes" do
29
+ registry.register_adapter(:foo) { config :bar, default: :baz }
30
+
31
+ expect(config.adapters.foo.bar).to eq(:baz)
32
+ end
33
+ end
34
+ end
35
+
36
+ describe "handlers config" do
37
+ context "with no handlers with config attributes" do
38
+ it "has a handlers attribute" do
39
+ expect(config).to respond_to(:handlers)
40
+ end
41
+ end
42
+
43
+ context "with one handler with no configuration" do
44
+ it "has no attribute for the handler" do
45
+ # rubocop:disable Lint/EmptyBlock
46
+ registry.register_handler(:foo) {}
47
+ # rubocop:enable Lint/EmptyBlock
48
+
49
+ expect(config.handlers).not_to respond_to(:foo)
50
+ end
51
+ end
52
+
53
+ context "with a handler with configuration" do
54
+ it "has an attribute for the handler with its own attributes" do
55
+ registry.register_handler(:foo) { config :bar, default: :baz }
56
+
57
+ expect(config.handlers.foo.bar).to eq(:baz)
58
+ end
59
+ end
60
+ end
61
+
62
+ describe "http config" do
63
+ it "has a default host" do
64
+ expect(config.http.host).to eq("0.0.0.0")
65
+ end
66
+
67
+ it "can set the host" do
68
+ config.http.host = "127.0.0.1"
69
+
70
+ expect(config.http.host).to eq("127.0.0.1")
71
+ end
72
+
73
+ it "has a default port" do
74
+ expect(config.http.port).to eq(8080)
75
+ end
76
+
77
+ it "can set the port" do
78
+ config.http.port = 80
79
+
80
+ expect(config.http.port).to eq(80)
81
+ end
82
+
83
+ it "has a default minimum thread count" do
84
+ expect(config.http.min_threads).to eq(0)
85
+ end
86
+
87
+ it "can set the minimum threads" do
88
+ config.http.min_threads = 4
89
+
90
+ expect(config.http.min_threads).to eq(4)
91
+ end
92
+
93
+ it "has a default maximum thread count" do
94
+ expect(config.http.max_threads).to eq(16)
95
+ end
96
+
97
+ it "can set the maximum threads" do
98
+ config.http.max_threads = 8
99
+
100
+ expect(config.http.max_threads).to eq(8)
101
+ end
102
+
103
+ it "has an empty middleware stack" do
104
+ expect(config.http.middleware).to be_empty
105
+ end
106
+
107
+ it "can add middleware to the stack" do
108
+ middleware = double("a rack middleware")
109
+
110
+ config.http.middleware.push(middleware)
111
+
112
+ expect(config.http.middleware).not_to be_empty
113
+ end
114
+
115
+ it "can add middleware with arguments" do
116
+ middleware = double("a rack middleware")
117
+
118
+ config.http.middleware.use(middleware, "argument") do
119
+ "block"
120
+ end
121
+
122
+ expect(config.http.middleware).not_to be_empty
123
+ end
124
+ end
125
+
126
+ describe "redis config" do
127
+ it "has empty default options" do
128
+ expect(config.redis).to eq({})
129
+ end
130
+
131
+ it "can set options" do
132
+ options = { port: 1234, password: "secret" }
133
+
134
+ config.redis = options
135
+
136
+ expect(config.redis).to eq(options)
137
+ end
138
+ end
139
+
140
+ describe "robot config" do
141
+ it "has a default name" do
142
+ expect(config.robot.name).to eq("Lita")
143
+ end
144
+
145
+ it "can set a name" do
146
+ config.robot.name = "Not Lita"
147
+
148
+ expect(config.robot.name).to eq("Not Lita")
149
+ end
150
+
151
+ it "has no default mention name" do
152
+ expect(config.robot.mention_name).to be_nil
153
+ end
154
+
155
+ it "can set a mention name" do
156
+ config.robot.mention_name = "notlita"
157
+
158
+ expect(config.robot.mention_name).to eq("notlita")
159
+ end
160
+
161
+ it "has no default alias" do
162
+ expect(config.robot.alias).to be_nil
163
+ end
164
+
165
+ it "can set an alias" do
166
+ config.robot.alias = "/"
167
+
168
+ expect(config.robot.alias).to eq("/")
169
+ end
170
+
171
+ it "has a default adapter" do
172
+ expect(config.robot.adapter).to eq(:shell)
173
+ end
174
+
175
+ it "can set an adapter" do
176
+ config.robot.adapter = :hipchat
177
+
178
+ expect(config.robot.adapter).to eq(:hipchat)
179
+ end
180
+
181
+ it "has no default locale" do
182
+ expect(config.robot.locale).to be_nil
183
+ end
184
+
185
+ it "can set a locale" do
186
+ config.robot.locale = :es
187
+
188
+ expect(config.robot.locale).to eq(:es)
189
+ end
190
+
191
+ it "has no default locale" do
192
+ expect(config.robot.default_locale).to be_nil
193
+ end
194
+
195
+ it "can set a default locale" do
196
+ config.robot.default_locale = :es
197
+
198
+ expect(config.robot.default_locale).to eq(:es)
199
+ end
200
+
201
+ it "has a default log level" do
202
+ expect(config.robot.log_level).to eq(:info)
203
+ end
204
+
205
+ it "can set a log level" do
206
+ config.robot.log_level = :debug
207
+
208
+ expect(config.robot.log_level).to eq(:debug)
209
+ end
210
+
211
+ it "has a default redis namespace" do
212
+ expect(config.robot.redis_namespace).to eq("lita.test")
213
+ end
214
+
215
+ it "can set a redis namespace" do
216
+ config.robot.redis_namespace = "mylitabot"
217
+
218
+ expect(config.robot.redis_namespace).to eq("mylitabot")
219
+ end
220
+
221
+ it "allows strings and mixed case as log levels" do
222
+ expect { config.robot.log_level = "dEbUg" }.not_to raise_error
223
+ end
224
+
225
+ it "raises a validation error for invalid log levels" do
226
+ expect(Lita.logger).to receive(:fatal).with(
227
+ /Validation error on attribute "log_level": must be one of/
228
+ )
229
+ expect { config.robot.log_level = :not_a_level }.to raise_error(Lita::ValidationError)
230
+ end
231
+
232
+ it "has no default admins" do
233
+ expect(config.robot.admins).to be_nil
234
+ end
235
+
236
+ it "can set admins" do
237
+ config.robot.admins = %w[1 2 3]
238
+
239
+ expect(config.robot.admins).to eq(%w[1 2 3])
240
+ end
241
+ end
242
+ end