adhearsion 2.5.4 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/CHANGELOG.md +15 -0
  4. data/README.markdown +2 -1
  5. data/Rakefile +1 -6
  6. data/adhearsion.gemspec +4 -3
  7. data/features/cli_daemon.feature +2 -4
  8. data/features/cli_restart.feature +14 -5
  9. data/features/cli_start.feature +0 -2
  10. data/features/cli_stop.feature +15 -6
  11. data/lib/adhearsion.rb +21 -23
  12. data/lib/adhearsion/call.rb +49 -5
  13. data/lib/adhearsion/call_controller.rb +29 -11
  14. data/lib/adhearsion/call_controller/dial.rb +21 -9
  15. data/lib/adhearsion/call_controller/menu_dsl.rb +12 -12
  16. data/lib/adhearsion/call_controller/menu_dsl/array_match_calculator.rb +1 -1
  17. data/lib/adhearsion/call_controller/menu_dsl/fixnum_match_calculator.rb +1 -0
  18. data/lib/adhearsion/call_controller/menu_dsl/string_match_calculator.rb +1 -1
  19. data/lib/adhearsion/call_controller/output.rb +36 -7
  20. data/lib/adhearsion/call_controller/output/abstract_player.rb +4 -0
  21. data/lib/adhearsion/call_controller/record.rb +1 -0
  22. data/lib/adhearsion/cli_commands/ahn_command.rb +7 -4
  23. data/lib/adhearsion/cli_commands/plugin_command.rb +2 -0
  24. data/lib/adhearsion/generators.rb +2 -4
  25. data/lib/adhearsion/generators/app/templates/simon_game_spec.rb +20 -20
  26. data/lib/adhearsion/initializer.rb +2 -2
  27. data/lib/adhearsion/plugin.rb +6 -6
  28. data/lib/adhearsion/punchblock_plugin.rb +3 -4
  29. data/lib/adhearsion/punchblock_plugin/initializer.rb +2 -1
  30. data/lib/adhearsion/router.rb +7 -7
  31. data/lib/adhearsion/router/route.rb +10 -4
  32. data/lib/adhearsion/rspec.rb +2 -0
  33. data/lib/adhearsion/version.rb +1 -1
  34. data/spec/adhearsion/call_controller/dial_spec.rb +589 -557
  35. data/spec/adhearsion/call_controller/input_spec.rb +91 -91
  36. data/spec/adhearsion/call_controller/menu_dsl/array_match_calculator_spec.rb +29 -29
  37. data/spec/adhearsion/call_controller/menu_dsl/calculated_match_collection_spec.rb +6 -6
  38. data/spec/adhearsion/call_controller/menu_dsl/calculated_match_spec.rb +19 -19
  39. data/spec/adhearsion/call_controller/menu_dsl/fixnum_match_calculator_spec.rb +6 -6
  40. data/spec/adhearsion/call_controller/menu_dsl/match_calculator_spec.rb +1 -1
  41. data/spec/adhearsion/call_controller/menu_dsl/menu_builder_spec.rb +21 -17
  42. data/spec/adhearsion/call_controller/menu_dsl/menu_spec.rb +96 -83
  43. data/spec/adhearsion/call_controller/menu_dsl/range_match_calculator_spec.rb +5 -5
  44. data/spec/adhearsion/call_controller/menu_dsl/string_match_calculator_spec.rb +9 -9
  45. data/spec/adhearsion/call_controller/output/async_player_spec.rb +14 -4
  46. data/spec/adhearsion/call_controller/output/formatter_spec.rb +14 -14
  47. data/spec/adhearsion/call_controller/output/player_spec.rb +15 -5
  48. data/spec/adhearsion/call_controller/output_spec.rb +126 -78
  49. data/spec/adhearsion/call_controller/record_spec.rb +38 -26
  50. data/spec/adhearsion/call_controller/utility_spec.rb +11 -11
  51. data/spec/adhearsion/call_controller_spec.rb +176 -136
  52. data/spec/adhearsion/call_spec.rb +443 -218
  53. data/spec/adhearsion/calls_spec.rb +33 -33
  54. data/spec/adhearsion/configuration_spec.rb +61 -61
  55. data/spec/adhearsion/console_spec.rb +29 -29
  56. data/spec/adhearsion/events_spec.rb +14 -14
  57. data/spec/adhearsion/generators_spec.rb +1 -1
  58. data/spec/adhearsion/initializer_spec.rb +42 -42
  59. data/spec/adhearsion/logging_spec.rb +33 -33
  60. data/spec/adhearsion/outbound_call_spec.rb +69 -55
  61. data/spec/adhearsion/plugin_spec.rb +53 -44
  62. data/spec/adhearsion/process_spec.rb +21 -21
  63. data/spec/adhearsion/punchblock_plugin/initializer_spec.rb +68 -52
  64. data/spec/adhearsion/punchblock_plugin_spec.rb +6 -6
  65. data/spec/adhearsion/router/evented_route_spec.rb +2 -2
  66. data/spec/adhearsion/router/openended_route_spec.rb +9 -9
  67. data/spec/adhearsion/router/route_spec.rb +61 -31
  68. data/spec/adhearsion/router/unaccepting_route_spec.rb +13 -13
  69. data/spec/adhearsion/router_spec.rb +47 -33
  70. data/spec/adhearsion/statistics/dump_spec.rb +6 -6
  71. data/spec/adhearsion/statistics_spec.rb +9 -9
  72. data/spec/adhearsion_spec.rb +23 -20
  73. data/spec/spec_helper.rb +3 -6
  74. data/spec/support/call_controller_test_helpers.rb +7 -7
  75. data/spec/support/initializer_stubs.rb +1 -1
  76. data/spec/support/punchblock_mocks.rb +1 -1
  77. metadata +22 -10
  78. data/features/support/utils.rb +0 -9
@@ -13,7 +13,7 @@ module Adhearsion
13
13
  end
14
14
 
15
15
  it "should have a GirlFriday::Queue to handle events" do
16
- Events.queue.should be_a GirlFriday::WorkQueue
16
+ expect(Events.queue).to be_a GirlFriday::WorkQueue
17
17
  end
18
18
 
19
19
  it "should allow adding events to the queue and handle them appropriately" do
@@ -21,7 +21,7 @@ module Adhearsion
21
21
  o = nil
22
22
  latch = CountDownLatch.new 1
23
23
 
24
- Events.instance.should_receive(:handle_message).and_return do |message|
24
+ expect(Events.instance).to receive(:handle_message) do |message|
25
25
  t = message.type
26
26
  o = message.object
27
27
  latch.countdown!
@@ -29,16 +29,16 @@ module Adhearsion
29
29
 
30
30
  Events.trigger :event, :foo
31
31
 
32
- latch.wait(2).should be_true
33
- t.should be == :event
34
- o.should be == :foo
32
+ expect(latch.wait(2)).to be_truthy
33
+ expect(t).to eq(:event)
34
+ expect(o).to eq(:foo)
35
35
  end
36
36
 
37
37
  it "should allow executing events immediately" do
38
38
  t = nil
39
39
  o = nil
40
40
 
41
- Events.instance.should_receive(:handle_message).and_return do |message|
41
+ expect(Events.instance).to receive(:handle_message) do |message|
42
42
  sleep 0.25
43
43
  t = message.type
44
44
  o = message.object
@@ -46,8 +46,8 @@ module Adhearsion
46
46
 
47
47
  Events.trigger_immediately :event, :foo
48
48
 
49
- t.should be == :event
50
- o.should be == :foo
49
+ expect(t).to eq(:event)
50
+ expect(o).to eq(:foo)
51
51
  end
52
52
 
53
53
  it "should handle events using registered guarded handlers" do
@@ -59,13 +59,13 @@ module Adhearsion
59
59
 
60
60
  Events.trigger_immediately :event, EventClass.new
61
61
 
62
- result.should be == :foo
62
+ expect(result).to eq(:foo)
63
63
 
64
64
  Events.clear_handlers :event, EventClass
65
65
  end
66
66
 
67
67
  it "should handle exceptions in event processing by raising the exception as an event" do
68
- Events.instance.should_receive(:trigger).with(:exception, kind_of(ExceptionClass)).once
68
+ expect(Events.instance).to receive(:trigger).with(:exception, kind_of(ExceptionClass)).once
69
69
 
70
70
  Events.register_handler :event, EventClass do |event|
71
71
  raise ExceptionClass
@@ -88,7 +88,7 @@ module Adhearsion
88
88
 
89
89
  Events.trigger_immediately :event, EventClass.new
90
90
 
91
- result.should be == :bar
91
+ expect(result).to eq(:bar)
92
92
 
93
93
  Events.clear_handlers :event, EventClass
94
94
  end
@@ -97,8 +97,8 @@ module Adhearsion
97
97
  Events.register_handler :event_type_1 do |event|
98
98
  end
99
99
 
100
- Events.should respond_to(:event_type_1)
101
- Events.should_not respond_to(:event_type_2)
100
+ expect(Events).to respond_to(:event_type_1)
101
+ expect(Events).not_to respond_to(:event_type_2)
102
102
  end
103
103
 
104
104
  describe '#draw' do
@@ -112,7 +112,7 @@ module Adhearsion
112
112
 
113
113
  Events.trigger_immediately :event
114
114
 
115
- result.should be == :foo
115
+ expect(result).to eq(:foo)
116
116
 
117
117
  Events.clear_handlers :event
118
118
  end
@@ -12,7 +12,7 @@ module Adhearsion
12
12
  DummyGenerator = Class.new
13
13
 
14
14
  Generators.add_generator generator_key, DummyGenerator
15
- Generators.mappings[generator_key].should be == DummyGenerator
15
+ expect(Generators.mappings[generator_key]).to eq(DummyGenerator)
16
16
  end
17
17
  end
18
18
  end
@@ -12,8 +12,8 @@ describe Adhearsion::Initializer do
12
12
  describe "#start" do
13
13
  before do
14
14
  ::Logging.reset
15
- Adhearsion::Logging.should_receive(:start).once.and_return('')
16
- ::Logging::Appenders.stub(:file => nil)
15
+ expect(Adhearsion::Logging).to receive(:start).once.and_return('')
16
+ allow(::Logging::Appenders).to receive_messages(:file => nil)
17
17
  Adhearsion.config = nil
18
18
  end
19
19
 
@@ -34,7 +34,7 @@ describe Adhearsion::Initializer do
34
34
  end
35
35
 
36
36
  it "should start the stats aggregator" do
37
- Adhearsion.should_receive(:statistics).at_least(:once)
37
+ expect(Adhearsion).to receive(:statistics).at_least(:once)
38
38
  stub_behavior_for_initializer_with_no_path_changing_behavior do
39
39
  Adhearsion::Initializer.start
40
40
  end
@@ -42,33 +42,33 @@ describe Adhearsion::Initializer do
42
42
 
43
43
  it "should create a pid file in the app's path when given 'true' as the pid_file hash key argument" do
44
44
  stub_behavior_for_initializer_with_no_path_changing_behavior do
45
- File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
45
+ expect(File).to receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
46
46
  ahn = Adhearsion::Initializer.start :pid_file => true
47
- ahn.pid_file[0, path.length].should be == path
47
+ expect(ahn.pid_file[0, path.length]).to eq(path)
48
48
  end
49
49
  end
50
50
 
51
51
  it "should NOT create a pid file in the app's path when given 'false' as the pid_file hash key argument" do
52
52
  stub_behavior_for_initializer_with_no_path_changing_behavior do
53
53
  ahn = Adhearsion::Initializer.start :pid_file => false
54
- ahn.pid_file.should be nil
54
+ expect(ahn.pid_file).to be nil
55
55
  end
56
56
  end
57
57
 
58
58
  it "should create a pid file in the app's path by default when daemonizing" do
59
59
  stub_behavior_for_initializer_with_no_path_changing_behavior do
60
- Adhearsion::CustomDaemonizer.should_receive(:daemonize).and_yield '123'
61
- File.should_receive(:open).once.with(File.join(path, 'adhearsion.pid'), 'w')
60
+ expect(Adhearsion::CustomDaemonizer).to receive(:daemonize).and_yield '123'
61
+ expect(File).to receive(:open).once.with(File.join(path, 'adhearsion.pid'), 'w')
62
62
  ahn = Adhearsion::Initializer.start :mode => :daemon
63
- ahn.pid_file[0, path.size].should be == path
63
+ expect(ahn.pid_file[0, path.size]).to eq(path)
64
64
  end
65
65
  end
66
66
 
67
67
  it "should NOT create a pid file in the app's path when daemonizing and :pid_file is given as false" do
68
68
  stub_behavior_for_initializer_with_no_path_changing_behavior do
69
- Adhearsion::CustomDaemonizer.should_receive(:daemonize).and_yield '123'
69
+ expect(Adhearsion::CustomDaemonizer).to receive(:daemonize).and_yield '123'
70
70
  ahn = Adhearsion::Initializer.start :mode => :daemon, :pid_file => false
71
- ahn.pid_file.should be nil
71
+ expect(ahn.pid_file).to be nil
72
72
  end
73
73
  end
74
74
 
@@ -76,63 +76,63 @@ describe Adhearsion::Initializer do
76
76
  random_file = "/tmp/AHN_TEST_#{rand 100000}.pid"
77
77
  stub_behavior_for_initializer_with_no_path_changing_behavior do
78
78
  ahn = Adhearsion::Initializer.start :pid_file => random_file
79
- ahn.pid_file.should be == random_file
80
- File.exists?(random_file).should be true
79
+ expect(ahn.pid_file).to eq(random_file)
80
+ expect(File.exists?(random_file)).to be true
81
81
  File.delete random_file
82
82
  end
83
83
  end
84
84
 
85
85
  it "should resolve the log file path to daemonize" do
86
86
  stub_behavior_for_initializer_with_no_path_changing_behavior do
87
- File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
87
+ expect(File).to receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
88
88
  ahn = Adhearsion::Initializer.start :pid_file => true
89
- ahn.resolve_log_file_path.should be == path + Adhearsion.config.platform.logging.outputters[0]
89
+ expect(ahn.resolve_log_file_path).to eq(path + Adhearsion.config.platform.logging.outputters[0])
90
90
  end
91
91
  end
92
92
 
93
93
  it "should resolve the log file path to daemonize when outputters is an Array" do
94
94
  Adhearsion.config.platform.logging.outputters = ["log/my_application.log", "log/adhearsion.log"]
95
95
  stub_behavior_for_initializer_with_no_path_changing_behavior do
96
- File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
96
+ expect(File).to receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
97
97
  ahn = Adhearsion::Initializer.start :pid_file => true
98
- ahn.resolve_log_file_path.should be == path + Adhearsion.config.platform.logging.outputters[0]
98
+ expect(ahn.resolve_log_file_path).to eq(path + Adhearsion.config.platform.logging.outputters[0])
99
99
  end
100
100
  end
101
101
 
102
102
  it "should return a valid appenders array" do
103
103
  stub_behavior_for_initializer_with_no_path_changing_behavior do
104
- File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
104
+ expect(File).to receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
105
105
  ahn = Adhearsion::Initializer.start :pid_file => true
106
106
  appenders = ahn.init_get_logging_appenders
107
- appenders.should have(2).items
108
- appenders[1].should be_instance_of Logging::Appenders::Stdout
107
+ expect(appenders.size).to eq(2)
108
+ expect(appenders[1]).to be_instance_of Logging::Appenders::Stdout
109
109
  end
110
110
  end
111
111
 
112
112
  it "should initialize properly the log paths" do
113
113
  ahn = stub_behavior_for_initializer_with_no_path_changing_behavior do
114
- File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
114
+ expect(File).to receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
115
115
  Adhearsion::Initializer.start :pid_file => true
116
116
  end
117
- Dir.should_receive(:mkdir).with("log/")
117
+ expect(Dir).to receive(:mkdir).with("log/")
118
118
  ahn.initialize_log_paths
119
119
  end
120
120
 
121
121
  it "should initialize properly the log paths when outputters is an array" do
122
122
  Adhearsion.config.platform.logging.outputters = ["log/my_application.log", "log/test/adhearsion.log"]
123
123
  ahn = stub_behavior_for_initializer_with_no_path_changing_behavior do
124
- File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
124
+ expect(File).to receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
125
125
  Adhearsion::Initializer.start :pid_file => true
126
126
  end
127
- Dir.should_receive(:mkdir).with("log/").twice
128
- Dir.should_receive(:mkdir).with("log/test/").once
127
+ expect(Dir).to receive(:mkdir).with("log/").twice
128
+ expect(Dir).to receive(:mkdir).with("log/test/").once
129
129
  ahn.initialize_log_paths
130
130
  end
131
131
 
132
132
  it "should set the adhearsion proc name" do
133
133
  stub_behavior_for_initializer_with_no_path_changing_behavior do
134
- File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
135
- Adhearsion::LinuxProcName.should_receive(:set_proc_name).with(Adhearsion.config.platform.process_name)
134
+ expect(File).to receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
135
+ expect(Adhearsion::LinuxProcName).to receive(:set_proc_name).with(Adhearsion.config.platform.process_name)
136
136
  Adhearsion::Initializer.start :pid_file => true
137
137
  end
138
138
  end
@@ -141,14 +141,14 @@ describe Adhearsion::Initializer do
141
141
  stub_behavior_for_initializer_with_no_path_changing_behavior do
142
142
  Adhearsion::Initializer.start :pid_file => true
143
143
  end
144
- $0.should be == Adhearsion.config.platform.process_name
144
+ expect($0).to eq(Adhearsion.config.platform.process_name)
145
145
  end
146
146
  end
147
147
 
148
148
  describe "Initializing logger" do
149
149
  before do
150
150
  ::Logging.reset
151
- ::Logging::Appenders.should_receive(:file).and_return(nil)
151
+ expect(::Logging::Appenders).to receive(:file).and_return(nil)
152
152
  Adhearsion.config = nil
153
153
  end
154
154
 
@@ -161,8 +161,8 @@ describe Adhearsion::Initializer do
161
161
 
162
162
  it "should start logging with valid parameters" do
163
163
  stub_behavior_for_initializer_with_no_path_changing_behavior do
164
- File.should_receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
165
- Adhearsion::Logging.should_receive(:start).once.with(kind_of(Array), :info, nil).and_return('')
164
+ expect(File).to receive(:open).with(File.join(path, 'adhearsion.pid'), 'w').at_least(:once)
165
+ expect(Adhearsion::Logging).to receive(:start).once.with(kind_of(Array), :info, nil).and_return('')
166
166
  Adhearsion::Initializer.start :pid_file => true
167
167
  end
168
168
  end
@@ -174,24 +174,24 @@ describe Adhearsion::Initializer do
174
174
  end
175
175
 
176
176
  it "should load the contents of lib directory" do
177
- Dir.should_receive(:chdir).with(File.join(path, "lib")).and_return []
177
+ expect(Dir).to receive(:chdir).with(File.join(path, "lib")).and_return []
178
178
  Adhearsion::Initializer.new.load_lib_folder
179
179
  end
180
180
 
181
181
  it "should return false if folder does not exist" do
182
182
  Adhearsion.config.platform.lib = "my_random_lib_directory"
183
- Adhearsion::Initializer.new.load_lib_folder.should be == false
183
+ expect(Adhearsion::Initializer.new.load_lib_folder).to eq(false)
184
184
  end
185
185
 
186
186
  it "should return false and not load any file if config folder is set to nil" do
187
187
  Adhearsion.config.platform.lib = nil
188
- Adhearsion::Initializer.new.load_lib_folder.should be == false
188
+ expect(Adhearsion::Initializer.new.load_lib_folder).to eq(false)
189
189
  end
190
190
 
191
191
  it "should load the contents of the preconfigured directory" do
192
192
  Adhearsion.config.platform.lib = "foo"
193
- File.stub directory?: true
194
- Dir.should_receive(:chdir).with(File.join(path, "foo")).and_return []
193
+ allow(File).to receive_messages directory?: true
194
+ expect(Dir).to receive(:chdir).with(File.join(path, "foo")).and_return []
195
195
  Adhearsion::Initializer.new.load_lib_folder
196
196
  end
197
197
  end
@@ -202,8 +202,8 @@ describe "Updating RAILS_ENV variable" do
202
202
 
203
203
  before do
204
204
  ::Logging.reset
205
- Adhearsion::Logging.should_receive(:start).once.and_return('')
206
- ::Logging::Appenders.should_receive(:file).and_return(nil)
205
+ expect(Adhearsion::Logging).to receive(:start).once.and_return('')
206
+ expect(::Logging::Appenders).to receive(:file).and_return(nil)
207
207
  Adhearsion.config = nil
208
208
  end
209
209
 
@@ -226,7 +226,7 @@ describe "Updating RAILS_ENV variable" do
226
226
  ahn = Adhearsion::Initializer.start
227
227
  end
228
228
  ahn.update_rails_env_var
229
- ENV['RAILS_ENV'].should be == env.to_s
229
+ expect(ENV['RAILS_ENV']).to eq(env.to_s)
230
230
  end
231
231
  end
232
232
  end
@@ -244,7 +244,7 @@ describe "Updating RAILS_ENV variable" do
244
244
  ahn = Adhearsion::Initializer.start
245
245
  end
246
246
  ahn.update_rails_env_var
247
- ENV['RAILS_ENV'].should be == "test"
247
+ expect(ENV['RAILS_ENV']).to eq("test")
248
248
  end
249
249
  end
250
250
 
@@ -255,7 +255,7 @@ describe "Updating RAILS_ENV variable" do
255
255
  ahn = Adhearsion::Initializer.start
256
256
  end
257
257
  ahn.update_rails_env_var
258
- ENV['RAILS_ENV'].should be == "test"
258
+ expect(ENV['RAILS_ENV']).to eq("test")
259
259
  end
260
260
  end
261
261
  end
@@ -271,7 +271,7 @@ describe "Updating RAILS_ENV variable" do
271
271
  ahn = Adhearsion::Initializer.start
272
272
  end
273
273
  ahn.update_rails_env_var
274
- ENV['RAILS_ENV'].should be == "production"
274
+ expect(ENV['RAILS_ENV']).to eq("production")
275
275
  end
276
276
  end
277
277
 
@@ -20,73 +20,73 @@ describe Adhearsion::Logging do
20
20
  end
21
21
 
22
22
  it 'should be added to any Object' do
23
- Foo.should respond_to(:logger)
23
+ expect(Foo).to respond_to(:logger)
24
24
  end
25
25
 
26
26
  it 'should be added to any Object instance' do
27
- Foo.new.should respond_to :logger
27
+ expect(Foo.new).to respond_to :logger
28
28
  end
29
29
 
30
30
  it 'should create the predefined set of log levels' do
31
- ::Logging::LEVELS.keys.should be == Adhearsion::Logging::LOG_LEVELS.map(&:downcase)
31
+ expect(::Logging::LEVELS.keys).to eq(Adhearsion::Logging::LOG_LEVELS.map(&:downcase))
32
32
  end
33
33
 
34
34
  it "should log to the Object logger when given arguments" do
35
35
  message = "o hai. ur home erly."
36
36
  foo = Foo.new
37
- ::Logging.logger[Foo].should_receive(:info).once.with(message)
37
+ expect(::Logging.logger[Foo]).to receive(:info).once.with(message)
38
38
  foo.logger.info message
39
39
  end
40
40
 
41
41
  it "should log to the Object logger when given arguments (II)" do
42
42
  message = "o hai. ur home erly."
43
43
  bar = Foo::Bar.new
44
- ::Logging.logger[Foo::Bar].should_receive(:info).once.with(message)
44
+ expect(::Logging.logger[Foo::Bar]).to receive(:info).once.with(message)
45
45
  bar.logger.info message
46
46
  end
47
47
 
48
48
  it 'should create a new logger when given method_missing' do
49
49
  FooBar = Class.new Foo
50
- ::Logging::Repository.instance[FooBar].should be_nil
50
+ expect(::Logging::Repository.instance[FooBar]).to be_nil
51
51
  FooBar.logger.info "o hai. ur home erly."
52
- ::Logging::Repository.instance[FooBar].should_not be_nil
52
+ expect(::Logging::Repository.instance[FooBar]).not_to be_nil
53
53
  end
54
54
 
55
55
  it "initializes properly a Logging object" do
56
- ::Logging.logger.root.appenders.length.should eql(1)
57
- ::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::Stdout)}.length.should eql(1)
56
+ expect(::Logging.logger.root.appenders.length).to eql(1)
57
+ expect(::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::Stdout)}.length).to eql(1)
58
58
  end
59
59
 
60
60
  it "initializes properly a Logging object with appenders as parameter" do
61
61
  Adhearsion::Logging.start([::Logging.appenders.stdout, ::Logging.appenders.file('example.log')])
62
- ::Logging.logger.root.appenders.length.should eql(2)
63
- ::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::Stdout)}.length.should eql(1)
64
- ::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::File)}.length.should eql(1)
62
+ expect(::Logging.logger.root.appenders.length).to eql(2)
63
+ expect(::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::Stdout)}.length).to eql(1)
64
+ expect(::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::File)}.length).to eql(1)
65
65
  end
66
66
 
67
67
  it "initializes properly a Logging object with appenders and log level as parameter" do
68
68
  Adhearsion::Logging.start([::Logging.appenders.stdout, ::Logging.appenders.file('example.log')], :debug)
69
- ::Logging.logger.root.appenders.length.should eql(2)
70
- ::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::Stdout)}.length.should eql(1)
71
- ::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::File)}.length.should eql(1)
72
- ::Logging.logger.root.level.should eql(::Logging::LEVELS["debug"])
69
+ expect(::Logging.logger.root.appenders.length).to eql(2)
70
+ expect(::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::Stdout)}.length).to eql(1)
71
+ expect(::Logging.logger.root.appenders.select{|a| a.is_a?(::Logging::Appenders::File)}.length).to eql(1)
72
+ expect(::Logging.logger.root.level).to eql(::Logging::LEVELS["debug"])
73
73
  end
74
74
 
75
75
  it "should create only a Logging object per Class (reuse per all the instances)" do
76
76
  _logger = Foo.new.logger
77
77
  10.times do
78
- Foo.new.logger.object_id.should eql(_logger.object_id)
78
+ expect(Foo.new.logger.object_id).to eql(_logger.object_id)
79
79
  end
80
80
  end
81
81
 
82
82
  it "should reuse a Logging instance in all Class instances but not with child instances" do
83
83
  _foo_logger = Foo.new.logger
84
84
  _bar_logger = Foo::Bar.new.logger
85
- _foo_logger.object_id.should_not eql(_bar_logger)
85
+ expect(_foo_logger.object_id).not_to eql(_bar_logger)
86
86
  end
87
87
 
88
88
  it 'should reopen logfiles' do
89
- ::Logging.should_receive(:reopen).once
89
+ expect(::Logging).to receive(:reopen).once
90
90
  Adhearsion::Logging.reopen_logs
91
91
  end
92
92
 
@@ -95,9 +95,9 @@ describe Adhearsion::Logging do
95
95
  Adhearsion.config.platform.logging['level'] = :warn
96
96
  Adhearsion::Logging.level = :warn
97
97
  Adhearsion::Logging.toggle_trace!
98
- Adhearsion::Logging.level.should be == 0
98
+ expect(Adhearsion::Logging.level).to eq(0)
99
99
  Adhearsion::Logging.toggle_trace!
100
- Adhearsion::Logging.level.should be == 3
100
+ expect(Adhearsion::Logging.level).to eq(3)
101
101
  Adhearsion.config.platform.logging['level'] = orig_level
102
102
  end
103
103
 
@@ -108,40 +108,40 @@ describe Adhearsion::Logging do
108
108
 
109
109
  it 'changing the logging level should affect all loggers' do
110
110
  loggers = [::Foo.logger, ::Foo::Bar.logger]
111
- loggers.map(&:level).should_not be == [Adhearsion::Logging::DEBUG] * 2
112
- loggers.map(&:level).should be == [Adhearsion::Logging::INFO] * 2
111
+ expect(loggers.map(&:level)).not_to eq([Adhearsion::Logging::DEBUG] * 2)
112
+ expect(loggers.map(&:level)).to eq([Adhearsion::Logging::INFO] * 2)
113
113
  Adhearsion::Logging.logging_level = :warn
114
- loggers.map(&:level).should be == [Adhearsion::Logging::WARN] * 2
114
+ expect(loggers.map(&:level)).to eq([Adhearsion::Logging::WARN] * 2)
115
115
  end
116
116
 
117
117
  it 'changing the logging level, using level=, should affect all loggers' do
118
118
  loggers = [Foo.logger, ::Foo::Bar.logger]
119
- loggers.map(&:level).should_not be == [::Logging::LEVELS["debug"]] * 2
120
- loggers.map(&:level).should be == [::Logging::LEVELS["info"]] * 2
119
+ expect(loggers.map(&:level)).not_to eq([::Logging::LEVELS["debug"]] * 2)
120
+ expect(loggers.map(&:level)).to eq([::Logging::LEVELS["info"]] * 2)
121
121
  Adhearsion::Logging.level = :warn
122
- loggers.map(&:level).should be == [::Logging::LEVELS["warn"]] * 2
122
+ expect(loggers.map(&:level)).to eq([::Logging::LEVELS["warn"]] * 2)
123
123
  end
124
124
 
125
125
  it 'should change all the Logger instance level' do
126
- Foo.logger.level.should be Adhearsion::Logging::INFO
126
+ expect(Foo.logger.level).to be Adhearsion::Logging::INFO
127
127
  Adhearsion::Logging.logging_level = :fatal
128
- Foo.logger.level.should be Adhearsion::Logging::FATAL
128
+ expect(Foo.logger.level).to be Adhearsion::Logging::FATAL
129
129
  end
130
130
 
131
131
  it 'a new logger should have the :root logging level' do
132
- Foo.logger.level.should be Adhearsion::Logging::INFO
132
+ expect(Foo.logger.level).to be Adhearsion::Logging::INFO
133
133
  Adhearsion::Logging.logging_level = :fatal
134
- Foo::Bar.logger.level.should be Adhearsion::Logging::FATAL
134
+ expect(Foo::Bar.logger.level).to be Adhearsion::Logging::FATAL
135
135
  end
136
136
 
137
137
  it '#silence! should change the level to be FATAL' do
138
138
  Adhearsion::Logging.silence!
139
- Adhearsion::Logging.logging_level.should be(Adhearsion::Logging::FATAL)
139
+ expect(Adhearsion::Logging.logging_level).to be(Adhearsion::Logging::FATAL)
140
140
  end
141
141
 
142
142
  it '#unsilence! should change the level to be INFO' do
143
143
  Adhearsion::Logging.unsilence!
144
- Adhearsion::Logging.logging_level.should be(Adhearsion::Logging::INFO)
144
+ expect(Adhearsion::Logging.logging_level).to be(Adhearsion::Logging::INFO)
145
145
  end
146
146
 
147
147
  end