Commit d3fcb0ca authored by Wandenberg's avatar Wandenberg

update gems and corresponding tests syntax

parent be0ae92b
source "https://rubygems.org"
gem 'rake', '~> 10.0.3'
ruby '2.1.2'
gem 'rake'
group :test do
gem 'rspec', '~> 2.14.1'
gem 'em-http-request', '~> 1.0.3'
gem 'nginx_test_helper', '~> 0.3.0'
gem 'jshintrb', '~> 0.2.1'
gem 'rspec'
gem 'nginx_test_helper', '~> 0.4.0'
gem 'jshintrb'
gem 'therubyracer'
gem 'jasmine', '~> 1.3.1'
gem 'listen', '~> 0.7.2'
gem 'rb-inotify', '~> 0.9.4', :require => RUBY_PLATFORM.include?('linux') && 'rb-inotify'
gem 'rb-fsevent', '~> 0.9', :require => RUBY_PLATFORM.include?('darwin') && 'rb-fsevent'
gem 'json', '~> 1.8.1'
gem 'thin', '~> 1.5.1'
gem 'net-http-persistent', '~> 2.9', :require => 'net/http/persistent'
gem 'jasmine'
gem 'listen'
gem 'rb-inotify', require: RUBY_PLATFORM.include?('linux') && 'rb-inotify'
gem 'rb-fsevent', require: RUBY_PLATFORM.include?('darwin') && 'rb-fsevent'
gem 'json'
gem 'thin'
gem 'net-http-persistent', require: 'net/http/persistent'
gem 'websocket-eventmachine-client'
gem 'em-eventsource'
gem 'byebug', '~> 1.3.1'
gem 'byebug'
end
group :docs do
gem 'github-markup', '~> 0.7.5', :require => 'github/markup'
gem 'RedCloth', '~> 4.2.9'
gem 'nokogiri', '~> 1.5.6'
gem 'github-markup', require: 'github/markup'
gem 'RedCloth'
gem 'nokogiri'
gem 'filewatcher'
end
......@@ -3,86 +3,92 @@ GEM
specs:
Platform (0.4.0)
RedCloth (4.2.9)
addressable (2.3.7)
byebug (1.3.1)
columnize (~> 0.3.6)
debugger-linecache (~> 1.2.0)
childprocess (0.5.5)
ffi (~> 1.0, >= 1.0.11)
columnize (0.3.6)
addressable (2.3.8)
byebug (4.0.5)
columnize (= 0.9.0)
celluloid (0.16.0)
timers (~> 4.0.0)
columnize (0.9.0)
cookiejar (0.3.2)
daemons (1.1.9)
debugger-linecache (1.2.0)
daemons (1.2.2)
diff-lcs (1.2.5)
em-eventsource (0.2.0)
em-http-request (>= 1.0.0)
eventmachine (>= 1.0.0.beta3)
em-http-request (1.0.3)
addressable (>= 2.2.3)
em-http-request (1.1.2)
addressable (>= 2.3.4)
cookiejar
em-socksify
eventmachine (>= 1.0.0.beta.4)
http_parser.rb (>= 0.5.3)
em-socksify (>= 0.3)
eventmachine (>= 1.0.3)
http_parser.rb (>= 0.6.0)
em-socksify (0.3.0)
eventmachine (>= 1.0.0.beta.4)
eventmachine (1.0.7)
execjs (2.0.2)
ffi (1.9.6)
filewatcher (0.3.4)
execjs (2.5.0)
ffi (1.9.8)
filewatcher (0.4.0)
trollop (~> 2.0)
github-markup (0.7.5)
github-markup (1.3.3)
hitimes (1.2.2)
http_parser.rb (0.6.0)
jasmine (1.3.2)
jasmine-core (~> 1.3.1)
rack (~> 1.0)
rspec (>= 1.3.1)
selenium-webdriver (>= 0.1.3)
jasmine-core (1.3.1)
jshintrb (0.2.4)
jasmine (2.2.0)
jasmine-core (~> 2.2)
phantomjs
rack (>= 1.2.1)
rake
jasmine-core (2.2.0)
jshintrb (0.3.0)
execjs
multi_json (>= 1.3)
rake
json (1.8.1)
libv8 (3.16.14.3)
listen (0.7.3)
multi_json (1.9.3)
json (1.8.2)
libv8 (3.16.14.7)
listen (2.10.0)
celluloid (~> 0.16.0)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
mini_portile (0.6.2)
multi_json (1.11.0)
net-http-persistent (2.9.4)
nginx_test_helper (0.3.0)
nginx_test_helper (0.4.1)
popen4
nokogiri (1.5.11)
open4 (1.3.3)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
open4 (1.3.4)
phantomjs (1.9.8.0)
popen4 (0.1.2)
Platform (>= 0.4.0)
open4 (>= 0.4.0)
rack (1.5.2)
rake (10.0.4)
rack (1.6.0)
rake (10.4.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
ref (1.0.5)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rubyzip (1.1.3)
selenium-webdriver (2.41.0)
childprocess (>= 0.5.0)
multi_json (~> 1.0)
rubyzip (~> 1.0)
websocket (~> 1.0.4)
therubyracer (0.12.1)
rspec (3.2.0)
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec-core (3.2.3)
rspec-support (~> 3.2.0)
rspec-expectations (3.2.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-mocks (3.2.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
thin (1.5.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
trollop (2.0)
websocket (1.0.7)
thin (1.6.3)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0)
rack (~> 1.0)
timers (4.0.1)
hitimes
trollop (2.1.2)
websocket (1.2.1)
websocket-eventmachine-base (1.1.0)
eventmachine (~> 1.0)
websocket (~> 1.0)
......@@ -95,23 +101,22 @@ PLATFORMS
ruby
DEPENDENCIES
RedCloth (~> 4.2.9)
byebug (~> 1.3.1)
RedCloth
byebug
em-eventsource
em-http-request (~> 1.0.3)
filewatcher
github-markup (~> 0.7.5)
jasmine (~> 1.3.1)
jshintrb (~> 0.2.1)
json (~> 1.8.1)
listen (~> 0.7.2)
net-http-persistent (~> 2.9)
nginx_test_helper (~> 0.3.0)
nokogiri (~> 1.5.6)
rake (~> 10.0.3)
rb-fsevent (~> 0.9)
rb-inotify (~> 0.9.4)
rspec (~> 2.14.1)
github-markup
jasmine
jshintrb
json
listen
net-http-persistent
nginx_test_helper (~> 0.4.0)
nokogiri
rake
rb-fsevent
rb-inotify
rspec
therubyracer
thin (~> 1.5.1)
thin
websocket-eventmachine-client
......@@ -40,7 +40,7 @@ begin
end
task :monitor_js do
copy_inner_js = Proc.new do |modified, added, removed|
def copy_inner_js(modified, added, removed)
modified.each do |file|
destiny_path = File.dirname(file).gsub(/.*\/js\/?/, File.expand_path('pushstream/js', Dir.tmpdir))
FileUtils.mkdir_p(destiny_path)
......@@ -50,10 +50,11 @@ begin
end
end
copy_inner_js.call([[File.expand_path('misc/js/pushstream.js', project_dir)], [], []])
listener = Listen.to(File.expand_path('misc/js', project_dir), :filter => /\.js$/)
listener.change(&copy_inner_js)
listener.start(false)
copy_inner_js([File.expand_path('misc/js/pushstream.js', project_dir)], [], [])
listener = Listen.to(File.expand_path('misc/js', project_dir), :filter => /\.js$/) do |modified, added, removed|
copy_inner_js(modified, added, removed)
end
listener.start
end
task :test_server do
......
describe("PushStream", function() {
var originalTimeout;
beforeEach(function() {
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
});
afterEach(function() {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
});
describe("when defining library external interface", function() {
......@@ -284,7 +291,7 @@ describe("PushStream", function() {
});
describe("when connecting", function() {
it("should call onstatuschange callback", function() {
it("should call onstatuschange callback", function(done) {
var status = [];
pushstream = new PushStream({
modes: mode,
......@@ -297,30 +304,31 @@ describe("PushStream", function() {
});
pushstream.addChannel(channelName);
runs(function() {
pushstream.connect();
});
waitsFor(function() {
return status.length >= 2;
}, "The callback was not called", 1000);
waitsForAndRuns(
function() { return status.length >= 2; },
runs(function() {
function() {
expect(status).toEqual([PushStream.CONNECTING, PushStream.OPEN]);
setTimeout(function() {
$.ajax({
url: "http://" + nginxServer + "/pub?id=" + channelName,
success: function(data) {
expect(data.subscribers).toBe("1");
done();
}
});
}, 1000);
});
},
1000
);
});
});
describe("when receiving a message", function() {
it("should call onmessage callback", function() {
it("should call onmessage callback", function(done) {
var receivedMessage = false;
pushstream = new PushStream({
modes: mode,
......@@ -334,22 +342,22 @@ describe("PushStream", function() {
});
pushstream.addChannel(channelName);
runs(function() {
pushstream.connect();
setTimeout(function() {
$.post("http://" + nginxServer + "/pub?id=" + channelName, "a test message");
}, 500);
});
waitsFor(function() {
return receivedMessage;
}, "The callback was not called", 1000);
waitsForAndRuns(
function() { return receivedMessage; },
function() { done(); },
1000
);
});
});
describe("when disconnecting", function() {
it("should call onstatuschange callback with CLOSED status", function() {
it("should call onstatuschange callback with CLOSED status", function(done) {
var status = null;
pushstream = new PushStream({
modes: mode,
......@@ -362,7 +370,6 @@ describe("PushStream", function() {
});
pushstream.addChannel(channelName);
runs(function() {
pushstream.connect();
setTimeout(function() {
......@@ -374,28 +381,23 @@ describe("PushStream", function() {
}
});
}, 500);
});
waitsFor(function() {
return status == PushStream.CLOSED;
}, "The callback was not called", 1000);
runs(function() {
waitsForAndRuns(
function() { return status == PushStream.CLOSED; },
function() {
expect(pushstream.readyState).toBe(PushStream.CLOSED);
setTimeout(function() {
$.ajax({
url: "http://" + nginxServer + "/pub?id=" + channelName,
success: function(data) {
expect(data.subscribers).toBe("0");
}
});
}, 5000);
});
done();
},
1000
);
});
});
describe("when adding a new channel", function() {
it("should reconnect", function() {
it("should reconnect", function(done) {
var status = [];
var messages = [];
pushstream = new PushStream({
......@@ -407,21 +409,21 @@ describe("PushStream", function() {
status.push(st);
},
onmessage: function(text, id, channel, eventid, isLastMessageFromBatch) {
messages.push(arguments);
messages.push([text, id, channel, eventid, isLastMessageFromBatch]);
}
});
pushstream.addChannel(channelName);
runs(function() {
pushstream.connect();
setTimeout(function() {
pushstream.addChannel("other_" + channelName);
}, 200);
});
waitsFor(function() { return pushstream.channelsCount >= 2; }, "Channel not added", 300);
runs(function() {
waitsForAndRuns(
function() { return pushstream.channelsCount >= 2; },
function() {
setTimeout(function() {
$.post("http://" + nginxServer + "/pub?id=" + channelName, "a test message", function() {
setTimeout(function() {
......@@ -429,22 +431,28 @@ describe("PushStream", function() {
}, 700);
});
}, 700);
});
},
waitsFor(function() {
return messages.length >= 2;
}, "The callback was not called", 2500);
300
);
runs(function() {
waitsForAndRuns(
function() { return messages.length >= 2; },
function() {
expect(status).toEqual([PushStream.CONNECTING, PushStream.OPEN, PushStream.CLOSED, PushStream.CONNECTING, PushStream.OPEN]);
expect(messages[0]).toEqual(["a test message", 1, channelName, "", true]);
expect(messages[1]).toEqual(["message on other channel", 1, "other_" + channelName, "", true]);
});
done();
},
2500
);
});
});
describe("when deleting a channel", function() {
it("should call onchanneldeleted callback", function() {
it("should call onchanneldeleted callback", function(done) {
var channel = null;
pushstream = new PushStream({
modes: mode,
......@@ -457,19 +465,16 @@ describe("PushStream", function() {
});
pushstream.addChannel(channelName);
runs(function() {
pushstream.connect();
setTimeout(function() {
$.ajax({type: "DELETE", url: "http://" + nginxServer + "/pub?id=" + channelName});
}, 500);
});
waitsFor(function() {
return channel !== null;
}, "The callback was not called", 1000);
waitsForAndRuns(
function() { return channel !== null; },
runs(function() {
function() {
$.post("http://" + nginxServer + "/pub?id=" + channelName, "a test message", function() {
$.ajax({
url: "http://" + nginxServer + "/pub?id=" + channelName,
......@@ -479,12 +484,16 @@ describe("PushStream", function() {
});
});
expect(channel).toBe(channelName);
});
done();
},
1000
);
});
});
describe("when sending extra params", function() {
it("should call extraParams function", function() {
it("should call extraParams function", function(done) {
var receivedMessage = false;
pushstream = new PushStream({
modes: mode,
......@@ -501,22 +510,22 @@ describe("PushStream", function() {
});
pushstream.addChannel(channelName);
runs(function() {
pushstream.connect();
setTimeout(function() {
$.post("http://" + nginxServer + "/pub?id=" + "test_" + channelName, "a test message");
}, 500);
});
waitsFor(function() {
return receivedMessage;
}, "The callback was not called", 1000);
waitsForAndRuns(
function() { return receivedMessage; },
function() { done(); },
1000
);
});
});
describe("when an error on connecting happens", function() {
it("should call onerror callback with a load error type", function() {
it("should call onerror callback with a load error type", function(done) {
var error = null;
pushstream = new PushStream({
modes: mode,
......@@ -532,23 +541,24 @@ describe("PushStream", function() {
});
pushstream.addChannel(channelName);
runs(function() {
pushstream.connect();
});
waitsFor(function() {
return error !== null;
}, "The callback was not called", 3000);
waitsForAndRuns(
function() { return error !== null; },
runs(function() {
function() {
expect(pushstream.readyState).toBe(PushStream.CLOSED);
expect(error.type).toBe("load");
});
done();
},
3000
);
});
});
describe("when getting old messages", function() {
it("should be possible use time", function() {
it("should be possible use time", function(done) {
var messages = [];
var receivedMessage = receivedMessage2 = false;
var finished = false;
......@@ -576,17 +586,14 @@ describe("PushStream", function() {
});
pushstream.addChannel(channelName);
runs(function() {
$.post("http://" + nginxServer + "/pub?id=" + channelName, "a test message", function() {
pushstream.connect();
});
});
waitsFor(function() {
return receivedMessage;
}, "The callback was not called", 2000);
waitsForAndRuns(
function() { return receivedMessage; },
runs(function() {
function() {
setTimeout(function() {
$.ajax({
url: "http://" + nginxServer + "/pub?id=" + channelName,
......@@ -598,26 +605,33 @@ describe("PushStream", function() {
}
});
}, 1500);
});
},
2000
);
waitsFor(function() {
return receivedMessage2;
}, "The callback was not called", 3000);
waitsForAndRuns(
function() { return receivedMessage2; },
runs(function() {
function() {
setTimeout(function() {
expect(messages[0]).toEqual(["a test message", 1, channelName, "", true]);
expect(messages[1]).toEqual(["another test message", 2, channelName, "", true]);
finished = true;
}, 500);
});
},
3000
);
waitsFor(function() {
return finished;
}, "The callback was not called", 5000);
waitsForAndRuns(
function() { return finished; },
function() { done(); },
5000
);
});
it("should be possible use a Date object", function() {
it("should be possible use a Date object", function(done) {
var messages = [];
var receivedMessage = receivedMessage2 = false;
var finished = false;
......@@ -646,17 +660,14 @@ describe("PushStream", function() {
});
pushstream.addChannel(channelName);
runs(function() {
$.post("http://" + nginxServer + "/pub?id=" + channelName, "a test message", function() {
pushstream.connect();
});
});
waitsFor(function() {
return receivedMessage;
}, "The callback was not called", 2000);
waitsForAndRuns(
function() { return receivedMessage; },
runs(function() {
function() {
setTimeout(function() {
$.ajax({
url: "http://" + nginxServer + "/pub?id=" + channelName,
......@@ -668,26 +679,33 @@ describe("PushStream", function() {
}
});
}, 1500);
});
},
waitsFor(function() {
return receivedMessage2;
}, "The callback was not called", 3000);
2000
);
runs(function() {
waitsForAndRuns(
function() { return receivedMessage2; },
function() {
setTimeout(function() {
expect(messages[0]).toEqual(["a test message", 1, channelName, "", true]);
expect(messages[1]).toEqual(["another test message", 2, channelName, "", true]);
finished = true;
}, 500);
});
},
3000
);
waitsFor(function() {
return finished;
}, "The callback was not called", 5000);
waitsForAndRuns(
function() { return finished; },
function() { done(); },
5000
);
});
it("should be possible use a negative value to get messages since epoch time", function() {
it("should be possible use a negative value to get messages since epoch time", function(done) {
var messages = [];
var receivedMessage = receivedMessage2 = false;
var finished = false;
......@@ -718,19 +736,16 @@ describe("PushStream", function() {
});
pushstream.addChannel(channelName);
runs(function() {
$.post("http://" + nginxServer + "/pub?id=" + channelName, "a test message 1", function() {
$.post("http://" + nginxServer + "/pub?id=" + channelName, "a test message 2", function() {
pushstream.connect();
});
});
});
waitsFor(function() {
return receivedMessage;
}, "The callback was not called", 2000);
waitsForAndRuns(
function() { return receivedMessage; },
runs(function() {
function() {
setTimeout(function() {
$.ajax({
url: "http://" + nginxServer + "/pub?id=" + channelName,
......@@ -744,13 +759,15 @@ describe("PushStream", function() {
}
});
}, 1500);
});
},
waitsFor(function() {
return receivedMessage2;
}, "The callback was not called", 3000);
2000
);
runs(function() {
waitsForAndRuns(
function() { return receivedMessage2; },
function() {
setTimeout(function() {
expect(messages[0]).toEqual(["a test message 1", 1, channelName, "", (pushstream.wrapper.type === "LongPolling") ? false : true]);
expect(messages[1]).toEqual(["a test message 2", 2, channelName, "", true]);
......@@ -758,14 +775,19 @@ describe("PushStream", function() {
expect(messages[3]).toEqual(["another test message 2", 4, channelName, "", true]);
finished = true;
}, 500);
});
},
waitsFor(function() {
return finished;
}, "The callback was not called", 5000);
3000
);
waitsForAndRuns(
function() { return finished; },
function() { done(); },
5000
);
});
it("should be possible use backtrack", function() {
it("should be possible use backtrack", function(done) {
var messages = [];
var receivedMessage = receivedMessage2 = false;
var finished = false;
......@@ -791,19 +813,16 @@ describe("PushStream", function() {
});
pushstream.addChannel(channelName, {backtrack: 1});
runs(function() {
$.post("http://" + nginxServer + "/pub?id=" + channelName, "a test message 1", function() {
$.post("http://" + nginxServer + "/pub?id=" + channelName, "a test message 2", function() {
pushstream.connect();
});
});
});
waitsFor(function() {
return receivedMessage;
}, "The callback was not called", 2000);
waitsForAndRuns(
function() { return receivedMessage; },
runs(function() {
function() {
setTimeout(function() {
$.ajax({
url: "http://" + nginxServer + "/pub?id=" + channelName,
......@@ -817,13 +836,15 @@ describe("PushStream", function() {
}
});
}, 1500);
});
},
2000
);
waitsFor(function() {
return receivedMessage2;
}, "The callback was not called", 3000);
waitsForAndRuns(
function() { return receivedMessage2; },
runs(function() {
function() {
setTimeout(function() {
expect(messages[0]).toEqual(["a test message 2", 2, channelName, "", true]);
if (jsonp) {
......@@ -834,14 +855,19 @@ describe("PushStream", function() {
}
finished = true;
}, 500);
});
},
waitsFor(function() {
return finished;
}, "The callback was not called", 5000);
3000
);
waitsForAndRuns(
function() { return finished; },
function() { done(); },
5000
);
});
it("should be possible use event_id", function() {
it("should be possible use event_id", function(done) {
var messages = [];
var receivedMessage = receivedMessage2 = false;
var finished = false;
......@@ -869,7 +895,6 @@ describe("PushStream", function() {
});
pushstream.addChannel(channelName);
runs(function() {
$.post("http://" + nginxServer + "/pub?id=" + channelName, "a test message 1", function() {
$.ajax({ url: "http://" + nginxServer + "/pub?id=" + channelName,
type: "POST", data: "a test message 2",
......@@ -885,13 +910,11 @@ describe("PushStream", function() {
}
});
});
});
waitsFor(function() {
return receivedMessage;
}, "The callback was not called", 2000);
waitsForAndRuns(
function() { return receivedMessage; },
runs(function() {
function() {
setTimeout(function() {
$.ajax({
url: "http://" + nginxServer + "/pub?id=" + channelName,
......@@ -911,27 +934,34 @@ describe("PushStream", function() {
}
});
}, 1500);
});
},
2000
);
waitsFor(function() {
return receivedMessage2;
}, "The callback was not called", 3000);
waitsForAndRuns(
function() { return receivedMessage2; },
runs(function() {
function() {
setTimeout(function() {
expect(messages[0]).toEqual(["a test message 3", 3, channelName, "some_event_id_2", true]);
expect(messages[1]).toEqual(["another test message 1", 4, channelName, "", (pushstream.wrapper.type !== "LongPolling")]);
expect(messages[2]).toEqual(["another test message 2", 5, channelName, "some_other_event_id", true]);
finished = true;
}, 500);
});
},
3000
);
waitsFor(function() {
return finished;
}, "The callback was not called", 5000);
waitsForAndRuns(
function() { return finished; },
function() { done(); },
5000
);
});
it("should be possible mix backtrack and time", function() {
it("should be possible mix backtrack and time", function(done) {
var messages = [];
var receivedMessage = receivedMessage2 = false;
var finished = false;
......@@ -958,19 +988,16 @@ describe("PushStream", function() {
});
pushstream.addChannel(channelName, {backtrack: 1});
runs(function() {
$.post("http://" + nginxServer + "/pub?id=" + channelName, "a test message 1", function() {
$.post("http://" + nginxServer + "/pub?id=" + channelName, "a test message 2", function() {
pushstream.connect();
});
});
});
waitsFor(function() {
return receivedMessage;
}, "The callback was not called", 2000);
waitsForAndRuns(
function() { return receivedMessage; },
runs(function() {
function() {
setTimeout(function() {
$.ajax({
url: "http://" + nginxServer + "/pub?id=" + channelName,
......@@ -984,24 +1011,31 @@ describe("PushStream", function() {
}
});
}, 1500);
});
},
2000
);
waitsFor(function() {
return receivedMessage2;
}, "The callback was not called", 3000);
waitsForAndRuns(
function() { return receivedMessage2; },
runs(function() {
function() {
setTimeout(function() {
expect(messages[0]).toEqual(["a test message 2", 2, channelName, "", true]);
expect(messages[1]).toEqual(["another test message 1", 3, channelName, "", (pushstream.wrapper.type !== "LongPolling")]);
expect(messages[2]).toEqual(["another test message 2", 4, channelName, "", true]);
finished = true;
}, 500);
});
},
3000
);
waitsFor(function() {
return finished;
}, "The callback was not called", 5000);
waitsForAndRuns(
function() { return finished; },
function() { done(); },
5000
);
});
});
};
......
beforeEach(function() {
this.addMatchers({
});
});
(function() {
var D = new Date('2011-06-02T09:34:29+02:00');
if (!D || +D !== 1307000069000) {
......@@ -37,3 +31,29 @@ beforeEach(function() {
};
}
})();
// This is the equivalent of the old waitsFor/runs syntax
// which was removed from Jasmine 2
var waitsForAndRuns = function(escapeFunction, runFunction, escapeTime) {
// check the escapeFunction every millisecond so as soon as it is met we can escape the function
var interval = setInterval(function() {
if (escapeFunction()) {
clearMe();
runFunction();
}
}, 1);
// in case we never reach the escapeFunction, we will time out
// at the escapeTime
var timeOut = setTimeout(function() {
clearMe();
runFunction();
}, escapeTime);
// clear the interval and the timeout
function clearMe(){
clearInterval(interval);
clearTimeout(timeOut);
}
};
# src_files
#
# Return an array of filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# src_files:
# - lib/source1.js
# - lib/source2.js
# - dist/**/*.js
#
src_files:
- public/javascripts/**/*.js
# stylesheets
#
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# stylesheets:
# - css/style.css
# - stylesheets/*.css
#
stylesheets:
- stylesheets/**/*.css
# helpers
#
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
# Default: ["helpers/**/*.js"]
#
# EXAMPLE:
#
# helpers:
# - helpers/**/*.js
#
helpers:
- 'helpers/**/*.js'
# spec_files
#
# Return an array of filepaths relative to spec_dir to include.
# Default: ["**/*[sS]pec.js"]
#
# EXAMPLE:
#
# spec_files:
# - **/*[sS]pec.js
#
spec_files:
- '**/*[sS]pec.js'
# src_dir
#
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
# Default: project root
#
# EXAMPLE:
#
# src_dir: public
#
src_dir:
# spec_dir
#
# Spec directory path. Your spec_files must be returned relative to this path.
# Default: spec/javascripts
#
# EXAMPLE:
#
# spec_dir: spec/javascripts
#
spec_dir:
# spec_helper
#
# Ruby file that Jasmine server will require before starting.
# Returned relative to your root path
# Default spec/javascripts/support/jasmine_helper.rb
#
# EXAMPLE:
#
# spec_helper: spec/javascripts/support/jasmine_helper.rb
#
spec_helper: spec/javascripts/support/jasmine_helper.rb
# boot_dir
#
# Boot directory path. Your boot_files must be returned relative to this path.
# Default: Built in boot file
#
# EXAMPLE:
#
# boot_dir: spec/javascripts/support/boot
#
boot_dir:
# boot_files
#
# Return an array of filepaths relative to boot_dir to include in order to boot Jasmine
# Default: Built in boot file
#
# EXAMPLE
#
# boot_files:
# - '**/*.js'
#
boot_files:
# rack_options
#
# Extra options to be passed to the rack server
# by default, Port and AccessLog are passed.
#
# This is an advanced options, and left empty by default
#
# EXAMPLE
#
# rack_options:
# server: 'thin'
Jasmine.configure do |config|
project_dir = File.expand_path('../../../../misc/..', File.dirname(__FILE__))
config.spec_dir = project_dir
config.spec_files = lambda { Dir["#{project_dir}/misc/spec/javascripts/helpers/**/*.js"] + Dir["#{project_dir}/misc/js/jquery.min.js"] + Dir["#{project_dir}/misc/**/*[sS]pec.js"] }
js_tmp_dir = File.expand_path('pushstream/js', Dir.tmpdir)
config.src_dir = js_tmp_dir
config.src_files = lambda { Dir["#{js_tmp_dir}/**/*.js"] }
end
......@@ -13,7 +13,7 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_1.callback do
pub_1.should be_http_status(404).without_body
expect(pub_1).to be_http_status(404).without_body
EventMachine.stop
end
end
......@@ -35,18 +35,18 @@ shared_examples_for "statistics location" do
actual_response << chunk
end
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
if (conf.gzip == "on")
pub_2.response_header["CONTENT_ENCODING"].should eql("gzip")
expect(pub_2.response_header["CONTENT_ENCODING"]).to eql("gzip")
actual_response = Zlib::GzipReader.new(StringIO.new(actual_response)).read
end
response = JSON.parse(actual_response)
response["channel"].to_s.should eql(channel)
response["published_messages"].to_i.should eql(1)
response["stored_messages"].to_i.should eql(1)
response["subscribers"].to_i.should eql(0)
expect(response["channel"].to_s).to eql(channel)
expect(response["published_messages"].to_i).to eql(1)
expect(response["stored_messages"].to_i).to eql(1)
expect(response["subscribers"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -61,12 +61,12 @@ shared_examples_for "statistics location" do
create_channel_by_subscribe(channel, headers) do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_1.callback do
pub_1.should be_http_status(200)
expect(pub_1).to be_http_status(200)
response = JSON.parse(pub_1.response)
response["channel"].to_s.should eql(channel)
response["published_messages"].to_i.should eql(0)
response["stored_messages"].to_i.should eql(0)
response["subscribers"].to_i.should eql(1)
expect(response["channel"].to_s).to eql(channel)
expect(response["published_messages"].to_i).to eql(0)
expect(response["stored_messages"].to_i).to eql(0)
expect(response["subscribers"].to_i).to eql(1)
EventMachine.stop
end
end
......@@ -78,9 +78,9 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
response = JSON.parse(pub_2.response)
response["infos"].length.should eql(0)
expect(response["infos"].length).to eql(0)
EventMachine.stop
end
end
......@@ -102,19 +102,19 @@ shared_examples_for "statistics location" do
actual_response << chunk
end
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
if (conf.gzip == "on")
pub_2.response_header["CONTENT_ENCODING"].should eql("gzip")
expect(pub_2.response_header["CONTENT_ENCODING"]).to eql("gzip")
actual_response = Zlib::GzipReader.new(StringIO.new(actual_response)).read
end
response = JSON.parse(actual_response)
response["infos"].length.should eql(1)
response["infos"][0]["channel"].to_s.should eql(channel)
response["infos"][0]["published_messages"].to_i.should eql(1)
response["infos"][0]["stored_messages"].to_i.should eql(1)
response["infos"][0]["subscribers"].to_i.should eql(0)
expect(response["infos"].length).to eql(1)
expect(response["infos"][0]["channel"].to_s).to eql(channel)
expect(response["infos"][0]["published_messages"].to_i).to eql(1)
expect(response["infos"][0]["stored_messages"].to_i).to eql(1)
expect(response["infos"][0]["subscribers"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -132,15 +132,15 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
response = JSON.parse(pub_2.response)
response["infos"].length.should eql(1)
response["channels"].to_i.should eql(0)
response["wildcard_channels"].to_i.should eql(1)
response["infos"][0]["channel"].to_s.should eql(channel)
response["infos"][0]["published_messages"].to_i.should eql(1)
response["infos"][0]["stored_messages"].to_i.should eql(1)
response["infos"][0]["subscribers"].to_i.should eql(0)
expect(response["infos"].length).to eql(1)
expect(response["channels"].to_i).to eql(0)
expect(response["wildcard_channels"].to_i).to eql(1)
expect(response["infos"][0]["channel"].to_s).to eql(channel)
expect(response["infos"][0]["published_messages"].to_i).to eql(1)
expect(response["infos"][0]["stored_messages"].to_i).to eql(1)
expect(response["infos"][0]["subscribers"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -155,13 +155,13 @@ shared_examples_for "statistics location" do
create_channel_by_subscribe(channel, headers) do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers
pub_1.callback do
pub_1.should be_http_status(200)
expect(pub_1).to be_http_status(200)
response = JSON.parse(pub_1.response)
response["infos"].length.should eql(1)
response["infos"][0]["channel"].to_s.should eql(channel)
response["infos"][0]["published_messages"].to_i.should eql(0)
response["infos"][0]["stored_messages"].to_i.should eql(0)
response["infos"][0]["subscribers"].to_i.should eql(1)
expect(response["infos"].length).to eql(1)
expect(response["infos"][0]["channel"].to_s).to eql(channel)
expect(response["infos"][0]["published_messages"].to_i).to eql(0)
expect(response["infos"][0]["stored_messages"].to_i).to eql(0)
expect(response["infos"][0]["subscribers"].to_i).to eql(1)
EventMachine.stop
end
end
......@@ -173,10 +173,10 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_1.callback do
pub_1.should be_http_status(200)
expect(pub_1).to be_http_status(200)
response = JSON.parse(pub_1.response)
response.has_key?("channels").should be_true
response["channels"].to_i.should eql(0)
expect(response.has_key?("channels")).to be_truthy
expect(response["channels"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -198,18 +198,18 @@ shared_examples_for "statistics location" do
actual_response << chunk
end
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
if (conf.gzip == "on")
pub_2.response_header["CONTENT_ENCODING"].should eql("gzip")
expect(pub_2.response_header["CONTENT_ENCODING"]).to eql("gzip")
actual_response = Zlib::GzipReader.new(StringIO.new(actual_response)).read
end
response = JSON.parse(actual_response)
response.has_key?("channels").should be_true
response["channels"].to_i.should eql(1)
response["published_messages"].to_i.should eql(1)
response["subscribers"].to_i.should eql(0)
expect(response.has_key?("channels")).to be_truthy
expect(response["channels"].to_i).to eql(1)
expect(response["published_messages"].to_i).to eql(1)
expect(response["subscribers"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -227,13 +227,13 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
response = JSON.parse(pub_2.response)
response.has_key?("channels").should be_true
response["channels"].to_i.should eql(0)
response["wildcard_channels"].to_i.should eql(1)
response["published_messages"].to_i.should eql(1)
response["subscribers"].to_i.should eql(0)
expect(response.has_key?("channels")).to be_truthy
expect(response["channels"].to_i).to eql(0)
expect(response["wildcard_channels"].to_i).to eql(1)
expect(response["published_messages"].to_i).to eql(1)
expect(response["subscribers"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -248,12 +248,12 @@ shared_examples_for "statistics location" do
create_channel_by_subscribe(channel, headers) do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_1.callback do
pub_1.should be_http_status(200)
expect(pub_1).to be_http_status(200)
response = JSON.parse(pub_1.response)
response.has_key?("channels").should be_true
response["channels"].to_i.should eql(1)
response["published_messages"].to_i.should eql(0)
response["subscribers"].to_i.should eql(1)
expect(response.has_key?("channels")).to be_truthy
expect(response["channels"].to_i).to eql(1)
expect(response["published_messages"].to_i).to eql(0)
expect(response["subscribers"].to_i).to eql(1)
EventMachine.stop
end
end
......@@ -272,22 +272,22 @@ shared_examples_for "statistics location" do
multi.add(:e, EventMachine::HttpRequest.new(nginx_address + '/channels-stats').head)
multi.callback do
multi.responses[:callback].length.should eql(5)
expect(multi.responses[:callback].length).to eql(5)
multi.responses[:callback][:a].should_not be_http_status(405)
multi.responses[:callback][:a].req.method.should eql("GET")
expect(multi.responses[:callback][:a]).not_to be_http_status(405)
expect(multi.responses[:callback][:a].req.method).to eql("GET")
multi.responses[:callback][:b].should be_http_status(405)
multi.responses[:callback][:b].req.method.should eql("PUT")
expect(multi.responses[:callback][:b]).to be_http_status(405)
expect(multi.responses[:callback][:b].req.method).to eql("PUT")
multi.responses[:callback][:c].should be_http_status(405)
multi.responses[:callback][:c].req.method.should eql("POST")
expect(multi.responses[:callback][:c]).to be_http_status(405)
expect(multi.responses[:callback][:c].req.method).to eql("POST")
multi.responses[:callback][:d].should be_http_status(405)
multi.responses[:callback][:d].req.method.should eql("DELETE")
expect(multi.responses[:callback][:d]).to be_http_status(405)
expect(multi.responses[:callback][:d].req.method).to eql("DELETE")
multi.responses[:callback][:e].should be_http_status(405)
multi.responses[:callback][:e].req.method.should eql("HEAD")
expect(multi.responses[:callback][:e]).to be_http_status(405)
expect(multi.responses[:callback][:e].req.method).to eql("HEAD")
EventMachine.stop
end
......@@ -315,35 +315,35 @@ shared_examples_for "statistics location" do
multi.add(:g, EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get(:head => {'accept' => 'text/x-yaml'}))
multi.callback do
multi.responses[:callback].length.should eql(7)
expect(multi.responses[:callback].length).to eql(7)
multi.responses[:callback][:a].should be_http_status(200).with_body
multi.responses[:callback][:a].req.method.should eql("GET")
multi.responses[:callback][:a].response_header["CONTENT_TYPE"].should eql("application/json")
expect(multi.responses[:callback][:a]).to be_http_status(200).with_body
expect(multi.responses[:callback][:a].req.method).to eql("GET")
expect(multi.responses[:callback][:a].response_header["CONTENT_TYPE"]).to eql("application/json")
multi.responses[:callback][:b].should be_http_status(200).with_body
multi.responses[:callback][:b].req.method.should eql("GET")
multi.responses[:callback][:b].response_header["CONTENT_TYPE"].should eql("text/plain")
expect(multi.responses[:callback][:b]).to be_http_status(200).with_body
expect(multi.responses[:callback][:b].req.method).to eql("GET")
expect(multi.responses[:callback][:b].response_header["CONTENT_TYPE"]).to eql("text/plain")
multi.responses[:callback][:c].should be_http_status(200).with_body
multi.responses[:callback][:c].req.method.should eql("GET")
multi.responses[:callback][:c].response_header["CONTENT_TYPE"].should eql("application/json")
expect(multi.responses[:callback][:c]).to be_http_status(200).with_body
expect(multi.responses[:callback][:c].req.method).to eql("GET")
expect(multi.responses[:callback][:c].response_header["CONTENT_TYPE"]).to eql("application/json")
multi.responses[:callback][:d].should be_http_status(200).with_body
multi.responses[:callback][:d].req.method.should eql("GET")
multi.responses[:callback][:d].response_header["CONTENT_TYPE"].should eql("application/yaml")
expect(multi.responses[:callback][:d]).to be_http_status(200).with_body
expect(multi.responses[:callback][:d].req.method).to eql("GET")
expect(multi.responses[:callback][:d].response_header["CONTENT_TYPE"]).to eql("application/yaml")
multi.responses[:callback][:e].should be_http_status(200).with_body
multi.responses[:callback][:e].req.method.should eql("GET")
multi.responses[:callback][:e].response_header["CONTENT_TYPE"].should eql("application/xml")
expect(multi.responses[:callback][:e]).to be_http_status(200).with_body
expect(multi.responses[:callback][:e].req.method).to eql("GET")
expect(multi.responses[:callback][:e].response_header["CONTENT_TYPE"]).to eql("application/xml")
multi.responses[:callback][:f].should be_http_status(200).with_body
multi.responses[:callback][:f].req.method.should eql("GET")
multi.responses[:callback][:f].response_header["CONTENT_TYPE"].should eql("text/x-json")
expect(multi.responses[:callback][:f]).to be_http_status(200).with_body
expect(multi.responses[:callback][:f].req.method).to eql("GET")
expect(multi.responses[:callback][:f].response_header["CONTENT_TYPE"]).to eql("text/x-json")
multi.responses[:callback][:g].should be_http_status(200).with_body
multi.responses[:callback][:g].req.method.should eql("GET")
multi.responses[:callback][:g].response_header["CONTENT_TYPE"].should eql("text/x-yaml")
expect(multi.responses[:callback][:g]).to be_http_status(200).with_body
expect(multi.responses[:callback][:g].req.method).to eql("GET")
expect(multi.responses[:callback][:g].response_header["CONTENT_TYPE"]).to eql("text/x-yaml")
EventMachine.stop
end
......@@ -362,7 +362,7 @@ shared_examples_for "statistics location" do
socket = open_socket(nginx_host, nginx_port)
1.upto(1000) do |j|
headers, body = post_in_socket("/pub?id=#{channel}#{i + j}", body, socket, {:wait_for => "}\r\n"})
headers.should include("HTTP/1.1 200 OK")
expect(headers).to include("HTTP/1.1 200 OK")
end
socket.close
end
......@@ -370,9 +370,9 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
response = JSON.parse(pub_2.response)
response["infos"].length.should eql(number_of_channels)
expect(response["infos"].length).to eql(number_of_channels)
EventMachine.stop
end
end
......@@ -384,9 +384,9 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=prefix_*').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
response = JSON.parse(pub_2.response)
response["infos"].length.should eql(0)
expect(response["infos"].length).to eql(0)
EventMachine.stop
end
end
......@@ -406,13 +406,13 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ch_test_*').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
response = JSON.parse(pub_2.response)
response["infos"].length.should eql(1)
response["infos"][0]["channel"].to_s.should eql(channel)
response["infos"][0]["published_messages"].to_i.should eql(1)
response["infos"][0]["stored_messages"].to_i.should eql(1)
response["infos"][0]["subscribers"].to_i.should eql(0)
expect(response["infos"].length).to eql(1)
expect(response["infos"][0]["channel"].to_s).to eql(channel)
expect(response["infos"][0]["published_messages"].to_i).to eql(1)
expect(response["infos"][0]["stored_messages"].to_i).to eql(1)
expect(response["infos"][0]["subscribers"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -432,17 +432,17 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=*').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
response = JSON.parse(pub_2.response)
response["infos"].length.should eql(2)
response["infos"][0]["channel"].to_s.should eql(channel)
response["infos"][0]["published_messages"].to_i.should eql(1)
response["infos"][0]["stored_messages"].to_i.should eql(1)
response["infos"][0]["subscribers"].to_i.should eql(0)
response["infos"][1]["channel"].to_s.should eql(channel_1)
response["infos"][1]["published_messages"].to_i.should eql(1)
response["infos"][1]["stored_messages"].to_i.should eql(1)
response["infos"][1]["subscribers"].to_i.should eql(0)
expect(response["infos"].length).to eql(2)
expect(response["infos"][0]["channel"].to_s).to eql(channel)
expect(response["infos"][0]["published_messages"].to_i).to eql(1)
expect(response["infos"][0]["stored_messages"].to_i).to eql(1)
expect(response["infos"][0]["subscribers"].to_i).to eql(0)
expect(response["infos"][1]["channel"].to_s).to eql(channel_1)
expect(response["infos"][1]["published_messages"].to_i).to eql(1)
expect(response["infos"][1]["stored_messages"].to_i).to eql(1)
expect(response["infos"][1]["subscribers"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -460,15 +460,15 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=bd_test_*').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
response = JSON.parse(pub_2.response)
response["infos"].length.should eql(1)
response["channels"].to_i.should eql(0)
response["wildcard_channels"].to_i.should eql(1)
response["infos"][0]["channel"].to_s.should eql(channel)
response["infos"][0]["published_messages"].to_i.should eql(1)
response["infos"][0]["stored_messages"].to_i.should eql(1)
response["infos"][0]["subscribers"].to_i.should eql(0)
expect(response["infos"].length).to eql(1)
expect(response["channels"].to_i).to eql(0)
expect(response["wildcard_channels"].to_i).to eql(1)
expect(response["infos"][0]["channel"].to_s).to eql(channel)
expect(response["infos"][0]["published_messages"].to_i).to eql(1)
expect(response["infos"][0]["stored_messages"].to_i).to eql(1)
expect(response["infos"][0]["subscribers"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -483,13 +483,13 @@ shared_examples_for "statistics location" do
create_channel_by_subscribe(channel, headers) do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ch_test_*').get :head => headers
pub_1.callback do
pub_1.should be_http_status(200)
expect(pub_1).to be_http_status(200)
response = JSON.parse(pub_1.response)
response["infos"].length.should eql(1)
response["infos"][0]["channel"].to_s.should eql(channel)
response["infos"][0]["published_messages"].to_i.should eql(0)
response["infos"][0]["stored_messages"].to_i.should eql(0)
response["infos"][0]["subscribers"].to_i.should eql(1)
expect(response["infos"].length).to eql(1)
expect(response["infos"][0]["channel"].to_s).to eql(channel)
expect(response["infos"][0]["published_messages"].to_i).to eql(0)
expect(response["infos"][0]["stored_messages"].to_i).to eql(0)
expect(response["infos"][0]["subscribers"].to_i).to eql(1)
EventMachine.stop
end
end
......@@ -507,7 +507,7 @@ shared_examples_for "statistics location" do
socket = open_socket(nginx_host, nginx_port)
1.upto(1000) do |j|
headers, body = post_in_socket("/pub?id=#{channel}#{i + j}", body, socket, {:wait_for => "}\r\n"})
headers.should include("HTTP/1.1 200 OK")
expect(headers).to include("HTTP/1.1 200 OK")
end
socket.close
end
......@@ -515,9 +515,9 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ch_test_get_detailed_channels_statistics_to_many_channels_using_prefix_10*').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
response = JSON.parse(pub_2.response)
response["infos"].length.should eql(1111)
expect(response["infos"].length).to eql(1111)
EventMachine.stop
end
end
......@@ -535,21 +535,21 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
response = JSON.parse(pub_2.response)
response["hostname"].to_s.should_not be_empty
response["time"].to_s.should_not be_empty
response["channels"].to_s.should_not be_empty
response["wildcard_channels"].to_s.should_not be_empty
response["uptime"].to_s.should_not be_empty
response["infos"].to_s.should_not be_empty
expect(response["hostname"].to_s).not_to be_empty
expect(response["time"].to_s).not_to be_empty
expect(response["channels"].to_s).not_to be_empty
expect(response["wildcard_channels"].to_s).not_to be_empty
expect(response["uptime"].to_s).not_to be_empty
expect(response["infos"].to_s).not_to be_empty
sleep(2)
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers
pub_3.callback do
pub_3.should be_http_status(200)
expect(pub_3).to be_http_status(200)
response = JSON.parse(pub_3.response)
response["uptime"].to_i.should be_in_the_interval(2, 3)
expect(response["uptime"].to_i).to be_in_the_interval(2, 3)
EventMachine.stop
end
end
......@@ -568,26 +568,26 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
response = JSON.parse(pub_2.response)
response["hostname"].to_s.should_not be_empty
response["time"].to_s.should_not be_empty
response["channels"].to_s.should_not be_empty
response["wildcard_channels"].to_s.should_not be_empty
response["subscribers"].to_s.should_not be_empty
response["uptime"].to_s.should_not be_empty
response["by_worker"].to_s.should_not be_empty
response["by_worker"][0]["pid"].to_s.should_not be_empty
response["by_worker"][0]["subscribers"].to_s.should_not be_empty
response["by_worker"][0]["uptime"].to_s.should_not be_empty
expect(response["hostname"].to_s).not_to be_empty
expect(response["time"].to_s).not_to be_empty
expect(response["channels"].to_s).not_to be_empty
expect(response["wildcard_channels"].to_s).not_to be_empty
expect(response["subscribers"].to_s).not_to be_empty
expect(response["uptime"].to_s).not_to be_empty
expect(response["by_worker"].to_s).not_to be_empty
expect(response["by_worker"][0]["pid"].to_s).not_to be_empty
expect(response["by_worker"][0]["subscribers"].to_s).not_to be_empty
expect(response["by_worker"][0]["uptime"].to_s).not_to be_empty
sleep(2)
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_3.callback do
pub_3.should be_http_status(200)
expect(pub_3).to be_http_status(200)
response = JSON.parse(pub_3.response)
response["uptime"].to_i.should be_in_the_interval(2, 3)
response["by_worker"][0]["uptime"].to_i.should be_in_the_interval(2, 3)
expect(response["uptime"].to_i).to be_in_the_interval(2, 3)
expect(response["by_worker"][0]["uptime"].to_i).to be_in_the_interval(2, 3)
EventMachine.stop
end
end
......@@ -606,18 +606,18 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
response = JSON.parse(pub_2.response)
response["stored_messages"].to_i.should eql(1)
response["messages_in_trash"].to_i.should eql(0)
expect(response["stored_messages"].to_i).to eql(1)
expect(response["messages_in_trash"].to_i).to eql(0)
sleep(5)
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_3.callback do
pub_3.should be_http_status(200)
expect(pub_3).to be_http_status(200)
response = JSON.parse(pub_3.response)
response["stored_messages"].to_i.should eql(0)
response["messages_in_trash"].to_i.should eql(1)
expect(response["stored_messages"].to_i).to eql(0)
expect(response["messages_in_trash"].to_i).to eql(1)
EventMachine.stop
end
end
......@@ -638,25 +638,25 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
response = JSON.parse(pub_2.response)
response["channels"].to_i.should eql(2)
response["wildcard_channels"].to_i.should eql(1)
response["channels_in_trash"].to_i.should eql(0)
expect(response["channels"].to_i).to eql(2)
expect(response["wildcard_channels"].to_i).to eql(1)
expect(response["channels_in_trash"].to_i).to eql(0)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do
pub.should be_http_status(200).without_body
expect(pub).to be_http_status(200).without_body
sleep(5)
pub_3 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_3.callback do
pub_3.should be_http_status(200)
expect(pub_3).to be_http_status(200)
response = JSON.parse(pub_3.response)
response["channels"].to_i.should eql(1)
response["wildcard_channels"].to_i.should eql(1)
response["channels_in_trash"].to_i.should eql(1)
expect(response["channels"].to_i).to eql(1)
expect(response["wildcard_channels"].to_i).to eql(1)
expect(response["channels_in_trash"].to_i).to eql(1)
EventMachine.stop
end
end
......@@ -672,8 +672,8 @@ shared_examples_for "statistics location" do
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_1.callback do
pub_1.response_header["EXPIRES"].should eql("Thu, 01 Jan 1970 00:00:01 GMT")
pub_1.response_header["CACHE_CONTROL"].should eql("no-cache, no-store, must-revalidate")
expect(pub_1.response_header["EXPIRES"]).to eql("Thu, 01 Jan 1970 00:00:01 GMT")
expect(pub_1.response_header["CACHE_CONTROL"]).to eql("no-cache, no-store, must-revalidate")
EventMachine.stop
end
end
......@@ -697,24 +697,24 @@ shared_examples_for "statistics location" do
actual_response << chunk
end
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
if (conf.gzip == "on")
pub_2.response_header["CONTENT_ENCODING"].should eql("gzip")
expect(pub_2.response_header["CONTENT_ENCODING"]).to eql("gzip")
actual_response = Zlib::GzipReader.new(StringIO.new(actual_response)).read
end
response = JSON.parse(actual_response)
response["infos"].length.should eql(2)
response["infos"][0]["channel"].to_s.should eql("ch3")
response["infos"][0]["published_messages"].to_i.should eql(1)
response["infos"][0]["stored_messages"].to_i.should eql(1)
response["infos"][0]["subscribers"].to_i.should eql(0)
response["infos"][1]["channel"].to_s.should eql("ch1")
response["infos"][1]["published_messages"].to_i.should eql(1)
response["infos"][1]["stored_messages"].to_i.should eql(1)
response["infos"][1]["subscribers"].to_i.should eql(0)
expect(response["infos"].length).to eql(2)
expect(response["infos"][0]["channel"].to_s).to eql("ch3")
expect(response["infos"][0]["published_messages"].to_i).to eql(1)
expect(response["infos"][0]["stored_messages"].to_i).to eql(1)
expect(response["infos"][0]["subscribers"].to_i).to eql(0)
expect(response["infos"][1]["channel"].to_s).to eql("ch1")
expect(response["infos"][1]["published_messages"].to_i).to eql(1)
expect(response["infos"][1]["stored_messages"].to_i).to eql(1)
expect(response["infos"][1]["subscribers"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -737,24 +737,24 @@ shared_examples_for "statistics location" do
actual_response << chunk
end
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
if (conf.gzip == "on")
pub_2.response_header["CONTENT_ENCODING"].should eql("gzip")
expect(pub_2.response_header["CONTENT_ENCODING"]).to eql("gzip")
actual_response = Zlib::GzipReader.new(StringIO.new(actual_response)).read
end
response = JSON.parse(actual_response)
response["infos"].length.should eql(2)
response["infos"][0]["channel"].to_s.should eql("ch3")
response["infos"][0]["published_messages"].to_i.should eql(1)
response["infos"][0]["stored_messages"].to_i.should eql(1)
response["infos"][0]["subscribers"].to_i.should eql(0)
response["infos"][1]["channel"].to_s.should eql("ch2")
response["infos"][1]["published_messages"].to_i.should eql(1)
response["infos"][1]["stored_messages"].to_i.should eql(1)
response["infos"][1]["subscribers"].to_i.should eql(0)
expect(response["infos"].length).to eql(2)
expect(response["infos"][0]["channel"].to_s).to eql("ch3")
expect(response["infos"][0]["published_messages"].to_i).to eql(1)
expect(response["infos"][0]["stored_messages"].to_i).to eql(1)
expect(response["infos"][0]["subscribers"].to_i).to eql(0)
expect(response["infos"][1]["channel"].to_s).to eql("ch2")
expect(response["infos"][1]["published_messages"].to_i).to eql(1)
expect(response["infos"][1]["stored_messages"].to_i).to eql(1)
expect(response["infos"][1]["subscribers"].to_i).to eql(0)
EventMachine.stop
end
end
......
......@@ -31,16 +31,16 @@ describe "Cleanup Memory" do
start = Time.now
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
result = JSON.parse(pub_2.response)
stored_messages_setp_1 = result["stored_messages"].to_i
published_messages_setp_1 = result["published_messages"].to_i
messages_in_trash = result["messages_in_trash"].to_i
stored_messages_setp_1.should eql(conf.max_messages_stored_per_channel)
published_messages_setp_1.should be > (conf.max_messages_stored_per_channel)
stored_messages_setp_1.should_not eql(0)
published_messages_setp_1.should eql(stored_messages_setp_1 + messages_in_trash)
expect(stored_messages_setp_1).to eql(conf.max_messages_stored_per_channel)
expect(published_messages_setp_1).to be > (conf.max_messages_stored_per_channel)
expect(stored_messages_setp_1).not_to eql(0)
expect(published_messages_setp_1).to eql(stored_messages_setp_1 + messages_in_trash)
wait_until_trash_is_empty(start, expected_time_for_clear, {:check_stored_messages => true}) do
execute_changes_on_environment(conf) do
......@@ -51,7 +51,7 @@ describe "Cleanup Memory" do
start = Time.now
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i
fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2
......@@ -59,10 +59,10 @@ describe "Cleanup Memory" do
publish_messages_until_fill_the_memory(channel, body) do |status3, content3|
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_4.callback do
pub_4.should be_http_status(200).with_body
expect(pub_4).to be_http_status(200).with_body
result = JSON.parse(pub_4.response)
result["stored_messages"].to_i.should eql(stored_messages_setp_1)
(result["published_messages"].to_i - published_messages_setp_2).should eql(published_messages_setp_1)
expect(result["stored_messages"].to_i).to eql(stored_messages_setp_1)
expect(result["published_messages"].to_i - published_messages_setp_2).to eql(published_messages_setp_1)
EventMachine.stop
end
......@@ -94,18 +94,18 @@ describe "Cleanup Memory" do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_1.callback do
fill_memory_timer.cancel
pub_1.should be_http_status(200).with_body
expect(pub_1).to be_http_status(200).with_body
stored_messages_setp_1 = JSON.parse(pub_1.response)["stored_messages"].to_i
stored_messages_setp_1.should eql(messages_to_publish)
expect(stored_messages_setp_1).to eql(messages_to_publish)
execute_changes_on_environment(conf) do
EM.add_timer(3) do # wait cleanup timer to be executed one time
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
stored_messages_setp_2 = JSON.parse(pub_2.response)["stored_messages"].to_i
stored_messages_setp_2.should be <= stored_messages_setp_1
stored_messages_setp_2.should be > 0
expect(stored_messages_setp_2).to be <= stored_messages_setp_1
expect(stored_messages_setp_2).to be > 0
EventMachine.stop
end
......@@ -137,7 +137,7 @@ describe "Cleanup Memory" do
start = Time.now
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
result = JSON.parse(pub_2.response)
stored_messages_setp_1 = result["stored_messages"].to_i
published_messages_setp_1 = result["published_messages"].to_i
......@@ -153,7 +153,7 @@ describe "Cleanup Memory" do
start = Time.now
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i
fail("Don't publish more messages") if published_messages_setp_1 == published_messages_setp_2
......@@ -161,10 +161,10 @@ describe "Cleanup Memory" do
publish_messages_until_fill_the_memory(channel, body) do |status3, content3|
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_4.callback do
pub_4.should be_http_status(200).with_body
expect(pub_4).to be_http_status(200).with_body
result = JSON.parse(pub_4.response)
result["stored_messages"].to_i.should eql(stored_messages_setp_1)
(result["published_messages"].to_i - published_messages_setp_2).should eql(published_messages_setp_1)
expect(result["stored_messages"].to_i).to eql(stored_messages_setp_1)
expect(result["published_messages"].to_i - published_messages_setp_2).to eql(published_messages_setp_1)
EventMachine.stop
end
end
......@@ -194,7 +194,7 @@ describe "Cleanup Memory" do
start = Time.now
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
channels_setp_1 = JSON.parse(pub_2.response)["channels"].to_i
fail("Don't create any channel") if channels_setp_1 == 0
......@@ -204,17 +204,17 @@ describe "Cleanup Memory" do
start = Time.now
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
fail("Don't create more channel") if published_messages_setp_1 == JSON.parse(pub_2.response)["published_messages"].to_i
wait_until_trash_is_empty(start, expected_time_for_clear, {:check_stored_messages => true, :check_channels => true}) do
publish_messages_until_fill_the_memory(channel, body) do |status3, content3|
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_4.callback do
pub_4.should be_http_status(200).with_body
expect(pub_4).to be_http_status(200).with_body
channels_setp_2 = JSON.parse(pub_4.response)["channels"].to_i
channels_setp_2.should eql(channels_setp_1)
expect(channels_setp_2).to eql(channels_setp_1)
EventMachine.stop
end
end
......@@ -246,7 +246,7 @@ describe "Cleanup Memory" do
start = Time.now
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
result = JSON.parse(pub_2.response)
published_messages_setp_1 = result["published_messages"].to_i
......@@ -260,18 +260,18 @@ describe "Cleanup Memory" do
start = Time.now
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i
published_messages_setp_2.should_not eql(published_messages_setp_1)
expect(published_messages_setp_2).not_to eql(published_messages_setp_1)
wait_until_trash_is_empty(start, expected_time_for_clear, {:check_stored_messages => true}) do
publish_messages_until_fill_the_memory(channel, body) do |status3, content3|
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :head => headers
pub_4.callback do
pub_4.should be_http_status(200).with_body
expect(pub_4).to be_http_status(200).with_body
result = JSON.parse(pub_4.response)
(result["published_messages"].to_i - published_messages_setp_2).should eql(published_messages_setp_1)
expect(result["published_messages"].to_i - published_messages_setp_2).to eql(published_messages_setp_1)
EventMachine.stop
end
end
......@@ -301,7 +301,7 @@ describe "Cleanup Memory" do
start = Time.now
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
result = JSON.parse(pub_2.response)
published_messages_setp_1 = result["published_messages"].to_i
......@@ -311,7 +311,7 @@ describe "Cleanup Memory" do
start = Time.now
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
published_messages_setp_2 = JSON.parse(pub_2.response)["published_messages"].to_i
fail("Don't create more channel") if published_messages_setp_1 == published_messages_setp_2
......@@ -319,9 +319,9 @@ describe "Cleanup Memory" do
publish_messages_until_fill_the_memory(channel, body) do |status3, content3|
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_4.callback do
pub_4.should be_http_status(200).with_body
expect(pub_4).to be_http_status(200).with_body
result = JSON.parse(pub_4.response)
(result["published_messages"].to_i - published_messages_setp_2).should eql(published_messages_setp_1)
expect(result["published_messages"].to_i - published_messages_setp_2).to eql(published_messages_setp_1)
EventMachine.stop
end
end
......@@ -357,7 +357,7 @@ describe "Cleanup Memory" do
end
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
result = JSON.parse(pub_2.response)
published_messages_setp_1 = result["published_messages"].to_i
fail("Don't create any message") if published_messages_setp_1 == 0
......@@ -372,9 +372,9 @@ describe "Cleanup Memory" do
fill_memory_timer.cancel
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
result = JSON.parse(pub_2.response)
(result["published_messages"].to_i / 2).should eql(published_messages_setp_1)
expect(result["published_messages"].to_i / 2).to eql(published_messages_setp_1)
EventMachine.stop
end
end
......@@ -404,7 +404,7 @@ describe "Cleanup Memory" do
create_and_delete_channel_in_loop(channel, body, headers) do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
result = JSON.parse(pub_2.response)
published_messages_setp_1 = result["published_messages"].to_i
fail("Don't create any message") if published_messages_setp_1 == 0
......@@ -414,9 +414,9 @@ describe "Cleanup Memory" do
create_and_delete_channel_in_loop(channel, body, headers) do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
result = JSON.parse(pub_2.response)
(result["published_messages"].to_i / 2).should eql(published_messages_setp_1)
expect(result["published_messages"].to_i / 2).to eql(published_messages_setp_1)
EventMachine.stop
end
end
......@@ -447,9 +447,7 @@ describe "Cleanup Memory" do
def create_and_delete_channel_in_loop(channel, body, headers, &block)
create_and_delete_channel(channel, body, headers) do |status|
if status == :success
create_and_delete_channel_in_loop(channel, body, headers) do
yield
end
create_and_delete_channel_in_loop(channel, body, headers, &block)
else
block.call unless block.nil?
end
......@@ -460,13 +458,13 @@ describe "Cleanup Memory" do
check_timer = EventMachine::PeriodicTimer.new(1) do
stats = EventMachine::HttpRequest.new("#{nginx_address}/channels-stats").get :head => headers
stats.callback do
stats.should be_http_status(200).with_body
expect(stats).to be_http_status(200).with_body
result = JSON.parse(stats.response)
if (result["messages_in_trash"].to_i == 0) && (result["channels_in_trash"].to_i == 0)
if (!options[:check_stored_messages] || (result["stored_messages"].to_i == 0)) && (!options[:check_channels] || (result["channels"].to_i == 0))
check_timer.cancel
stop = Time.now
(stop - start_time).should be_within(5).of(expected_time_for_clear)
expect(stop - start_time).to be_within(5).of(expected_time_for_clear)
block.call
end
......@@ -501,20 +499,20 @@ describe "Cleanup Memory" do
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body
pub_1.callback do
pub_1.should be_http_status(200).with_body
expect(pub_1).to be_http_status(200).with_body
start = Time.now
timer = EventMachine::PeriodicTimer.new(1) do
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
stats.callback do
stats.should be_http_status(200).with_body
expect(stats).to be_http_status(200).with_body
response = JSON.parse(stats.response)
if response["channels"].to_i != 1
stop = Time.now
time_diff_sec(start, stop).should be_within(5).of(30)
response["channels_in_trash"].to_i.should eql(1)
response["channels"].to_i.should eql(0)
expect(time_diff_sec(start, stop)).to be_within(5).of(30)
expect(response["channels_in_trash"].to_i).to eql(1)
expect(response["channels"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -532,20 +530,20 @@ describe "Cleanup Memory" do
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body
pub_1.callback do
pub_1.should be_http_status(200).with_body
expect(pub_1).to be_http_status(200).with_body
start = Time.now
timer = EventMachine::PeriodicTimer.new(1) do
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
stats.callback do
stats.should be_http_status(200).with_body
expect(stats).to be_http_status(200).with_body
response = JSON.parse(stats.response)
if response["channels"].to_i != 1
stop = Time.now
time_diff_sec(start, stop).should be_within(3).of(5)
response["channels_in_trash"].to_i.should eql(1)
response["channels"].to_i.should eql(0)
expect(time_diff_sec(start, stop)).to be_within(3).of(5)
expect(response["channels_in_trash"].to_i).to eql(1)
expect(response["channels"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -570,9 +568,9 @@ describe "Cleanup Memory" do
def execute_changes_on_environment(conf, &block)
pub = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :timeout => 30
pub.callback do
pub.should be_http_status(200).with_body
expect(pub).to be_http_status(200).with_body
resp_1 = JSON.parse(pub.response)
resp_1["by_worker"].count.should eql(conf.workers)
expect(resp_1["by_worker"].count).to eql(conf.workers)
pids = resp_1["by_worker"].map{ |info| info['pid'].to_i }
# send kill signal
......@@ -594,9 +592,9 @@ describe "Cleanup Memory" do
def execute_changes_on_environment(conf, &block)
pub = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :timeout => 30
pub.callback do
pub.should be_http_status(200).with_body
expect(pub).to be_http_status(200).with_body
resp_1 = JSON.parse(pub.response)
resp_1["by_worker"].count.should eql(conf.workers)
expect(resp_1["by_worker"].count).to eql(conf.workers)
pids = resp_1["by_worker"].map{ |info| info['pid'].to_i }
# send reload signal
......
......@@ -27,16 +27,16 @@ describe "Keepalive" do
post_single = Net::HTTP::Post.new "/pub?id=#{channel}#{i + j}"
post_single.body = body
response_single = http_single.request(uri, post_single)
response_single.code.should eql("200")
response_single.body.should eql(%({"channel": "#{channel}#{i + j}", "published_messages": "1", "stored_messages": "1", "subscribers": "0"}\r\n))
expect(response_single.code).to eql("200")
expect(response_single.body).to eql(%({"channel": "#{channel}#{i + j}", "published_messages": "1", "stored_messages": "1", "subscribers": "0"}\r\n))
post_double = Net::HTTP::Post.new "/pub?id=#{channel}#{i + j}/#{channel}#{i}_#{j}"
post_double.body = body
response_double = http_double.request(uri, post_double)
response_double.code.should eql("200")
response_double.body.should match_the_pattern(/"hostname": "[^"]*", "time": "\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}", "channels": "#{(i + j) * 2}", "wildcard_channels": "0", "uptime": "[0-9]*", "infos": \[\r\n/)
response_double.body.should match_the_pattern(/"channel": "#{channel}#{i + j}", "published_messages": "2", "stored_messages": "2", "subscribers": "0"},\r\n/)
response_double.body.should match_the_pattern(/"channel": "#{channel}#{i}_#{j}", "published_messages": "1", "stored_messages": "1", "subscribers": "0"}\r\n/)
expect(response_double.code).to eql("200")
expect(response_double.body).to match_the_pattern(/"hostname": "[^"]*", "time": "\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}", "channels": "#{(i + j) * 2}", "wildcard_channels": "0", "uptime": "[0-9]*", "infos": \[\r\n/)
expect(response_double.body).to match_the_pattern(/"channel": "#{channel}#{i + j}", "published_messages": "2", "stored_messages": "2", "subscribers": "0"},\r\n/)
expect(response_double.body).to match_the_pattern(/"channel": "#{channel}#{i}_#{j}", "published_messages": "1", "stored_messages": "1", "subscribers": "0"}\r\n/)
end
end
end
......@@ -55,8 +55,8 @@ describe "Keepalive" do
post = Net::HTTP::Post.new "/pub?id=#{channel}#{i + j}"
post.body = body
response = http.request(uri, post)
response.code.should eql("200")
response.body.should eql("")
expect(response.code).to eql("200")
expect(response.body).to eql("")
end
end
end
......@@ -70,40 +70,40 @@ describe "Keepalive" do
socket = open_socket(nginx_host, nginx_port)
headers, body = get_in_socket("/pub", socket)
body.should eql("")
headers.should include("No channel id provided.")
expect(body).to eql("")
expect(headers).to include("No channel id provided.")
headers, body = post_in_socket("/pub?id=#{channel}", content, socket, {:wait_for => "}\r\n"})
body.should eql("{\"channel\": \"#{channel}\", \"published_messages\": \"1\", \"stored_messages\": \"1\", \"subscribers\": \"0\"}\r\n")
expect(body).to eql("{\"channel\": \"#{channel}\", \"published_messages\": \"1\", \"stored_messages\": \"1\", \"subscribers\": \"0\"}\r\n")
headers, body = get_in_socket("/channels-stats", socket)
body.should match_the_pattern(/"channels": "1", "wildcard_channels": "0", "published_messages": "1", "stored_messages": "1", "messages_in_trash": "0", "channels_in_trash": "0", "subscribers": "0", "uptime": "[0-9]*", "by_worker": \[\r\n/)
body.should match_the_pattern(/\{"pid": "[0-9]*", "subscribers": "0", "uptime": "[0-9]*"\}/)
expect(body).to match_the_pattern(/"channels": "1", "wildcard_channels": "0", "published_messages": "1", "stored_messages": "1", "messages_in_trash": "0", "channels_in_trash": "0", "subscribers": "0", "uptime": "[0-9]*", "by_worker": \[\r\n/)
expect(body).to match_the_pattern(/\{"pid": "[0-9]*", "subscribers": "0", "uptime": "[0-9]*"\}/)
socket.print("DELETE /pub?id=#{channel}_1 HTTP/1.1\r\nHost: test\r\n\r\n")
headers, body = read_response_on_socket(socket)
headers.should include("HTTP/1.1 404 Not Found")
expect(headers).to include("HTTP/1.1 404 Not Found")
headers, body = get_in_socket("/channels-stats?id=ALL", socket)
body.should match_the_pattern(/"hostname": "[^"]*", "time": "\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}", "channels": "1", "wildcard_channels": "0", "uptime": "[0-9]*", "infos": \[\r\n/)
body.should match_the_pattern(/"channel": "#{channel}", "published_messages": "1", "stored_messages": "1", "subscribers": "0"}\r\n/)
expect(body).to match_the_pattern(/"hostname": "[^"]*", "time": "\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}", "channels": "1", "wildcard_channels": "0", "uptime": "[0-9]*", "infos": \[\r\n/)
expect(body).to match_the_pattern(/"channel": "#{channel}", "published_messages": "1", "stored_messages": "1", "subscribers": "0"}\r\n/)
headers, body = get_in_socket("/pub?id=#{channel}", socket)
body.should eql("{\"channel\": \"#{channel}\", \"published_messages\": \"1\", \"stored_messages\": \"1\", \"subscribers\": \"0\"}\r\n")
expect(body).to eql("{\"channel\": \"#{channel}\", \"published_messages\": \"1\", \"stored_messages\": \"1\", \"subscribers\": \"0\"}\r\n")
headers, body = post_in_socket("/pub?id=#{channel}/broad_#{channel}", content, socket, {:wait_for => "}\r\n"})
body.should match_the_pattern(/"hostname": "[^"]*", "time": "\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}", "channels": "1", "wildcard_channels": "1", "uptime": "[0-9]*", "infos": \[\r\n/)
body.should match_the_pattern(/"channel": "#{channel}", "published_messages": "2", "stored_messages": "2", "subscribers": "0"},\r\n/)
body.should match_the_pattern(/"channel": "broad_#{channel}", "published_messages": "1", "stored_messages": "1", "subscribers": "0"}\r\n/)
expect(body).to match_the_pattern(/"hostname": "[^"]*", "time": "\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}", "channels": "1", "wildcard_channels": "1", "uptime": "[0-9]*", "infos": \[\r\n/)
expect(body).to match_the_pattern(/"channel": "#{channel}", "published_messages": "2", "stored_messages": "2", "subscribers": "0"},\r\n/)
expect(body).to match_the_pattern(/"channel": "broad_#{channel}", "published_messages": "1", "stored_messages": "1", "subscribers": "0"}\r\n/)
headers, body = get_in_socket("/channels-stats?id=#{channel}", socket)
body.should match_the_pattern(/{"channel": "#{channel}", "published_messages": "2", "stored_messages": "2", "subscribers": "0"}\r\n/)
expect(body).to match_the_pattern(/{"channel": "#{channel}", "published_messages": "2", "stored_messages": "2", "subscribers": "0"}\r\n/)
socket.print("DELETE /pub?id=#{channel} HTTP/1.1\r\nHost: test\r\n\r\n")
headers, body = read_response_on_socket(socket)
headers.should include("X-Nginx-PushStream-Explain: Channel deleted.")
expect(headers).to include("X-Nginx-PushStream-Explain: Channel deleted.")
socket.close
end
......@@ -122,7 +122,7 @@ describe "Keepalive" do
socket.print(get_messages)
post_in_socket("/pub?id=#{channel}", "#{body_prefix} #{j.to_s.rjust(3, '0')}", socket_pub, {:wait_for => "}\r\n"})
headers, body = read_response_on_socket(socket, "\r\n0\r\n\r\n")
body.should eql("16\r\nmessage to be sent #{j.to_s.rjust(3, '0')}\r\n0\r\n\r\n")
expect(body).to eql("16\r\nmessage to be sent #{j.to_s.rjust(3, '0')}\r\n0\r\n\r\n")
end
socket.close
......
......@@ -39,11 +39,11 @@ describe "Measure Memory" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
resp = JSON.parse(pub_2.response)
expected_message = shared_size / (message_estimate_size + body.size)
resp["published_messages"].to_i.should be_within(80).of(expected_message)
expect(resp["published_messages"].to_i).to be_within(80).of(expected_message)
EventMachine.stop
end
end
......@@ -71,11 +71,11 @@ describe "Measure Memory" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
resp = JSON.parse(pub_2.response)
expected_channel = (shared_size - ((body.size + message_estimate_size) * resp["published_messages"].to_i)) / (channel_estimate_size + 4) # 4 channel id size
resp["channels"].to_i.should be_within(10).of(expected_channel)
expect(resp["channels"].to_i).to be_within(10).of(expected_channel)
EventMachine.stop
end
end
......@@ -90,11 +90,11 @@ describe "Measure Memory" do
subscriber_in_loop(1000, headers) do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
resp = JSON.parse(pub_2.response)
expected_subscriber = (shared_size - ((channel_estimate_size + 4) * resp["channels"].to_i)) / subscriber_estimate_size # 4 channel id size
resp["subscribers"].to_i.should be_within(10).of(expected_subscriber)
expect(resp["subscribers"].to_i).to be_within(10).of(expected_subscriber)
EventMachine.stop
end
end
......@@ -127,17 +127,18 @@ describe "Measure Memory" do
end
end
per_subscriber.should be_within(100).of(subscriber_estimate_system_size)
expect(per_subscriber).to be_within(100).of(subscriber_estimate_system_size)
end
end
end
def subscriber_in_loop(channel, headers, &block)
called = false
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_i.to_s).get :head => headers
sub.stream do |chunk|
subscriber_in_loop(channel.to_i + 1, headers) do
yield block
end
next if called
called = true
subscriber_in_loop(channel.to_i + 1, headers, &block)
end
sub.callback do
block.call
......@@ -145,15 +146,15 @@ def subscriber_in_loop(channel, headers, &block)
end
def subscriber_in_loop_with_limit(channel, headers, start, limit, &block)
called = false
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_i.to_s).get :head => headers
sub.stream do |chunk|
if start == limit
block.call
EventMachine.stop
else
subscriber_in_loop_with_limit(channel, headers, start + 1, limit) do
yield block
end
next if called
called = true
subscriber_in_loop_with_limit(channel, headers, start + 1, limit, &block)
end
end
sub.callback do
......
......@@ -31,9 +31,9 @@ describe "Send Signals" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge('X-Nginx-PushStream-Mode' => 'long-polling')
sub_1.callback do
sub_1.should be_http_status(304).without_body
Time.parse(sub_1.response_header['LAST_MODIFIED'].to_s).utc.to_i.should be_in_the_interval(Time.now.utc.to_i-1, Time.now.utc.to_i)
sub_1.response_header['ETAG'].to_s.should eql("0")
expect(sub_1).to be_http_status(304).without_body
expect(Time.parse(sub_1.response_header['LAST_MODIFIED'].to_s).utc.to_i).to be_in_the_interval(Time.now.utc.to_i-1, Time.now.utc.to_i)
expect(sub_1.response_header['ETAG'].to_s).to eql("0")
end
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
......@@ -43,7 +43,7 @@ describe "Send Signals" do
response += chunk
end
sub_2.callback do
response.should include("FOOTER")
expect(response).to include("FOOTER")
EventMachine.stop
end
end
......@@ -71,11 +71,11 @@ describe "Send Signals" do
# check statistics
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_1.callback do
pub_1.should be_http_status(200).with_body
expect(pub_1).to be_http_status(200).with_body
resp_1 = JSON.parse(pub_1.response)
resp_1.has_key?("channels").should be_true
resp_1["channels"].to_i.should eql(1)
resp_1["by_worker"].count.should eql(1)
expect(resp_1.has_key?("channels")).to be_truthy
expect(resp_1["channels"].to_i).to eql(1)
expect(resp_1["by_worker"].count).to eql(1)
pid = resp_1["by_worker"][0]['pid'].to_i
open_sockets_1 = `lsof -p #{Process.getpgid pid} | grep socket | wc -l`.strip
......@@ -96,7 +96,7 @@ describe "Send Signals" do
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_4.callback do
resp_3 = JSON.parse(pub_4.response)
resp_3.has_key?("by_worker").should be_true
expect(resp_3.has_key?("by_worker")).to be_truthy
old_process_running = Process.getpgid(pid) rescue false
if !old_process_running && (resp_3["by_worker"].count == 1) && (pid != resp_3["by_worker"][0]['pid'].to_i)
......@@ -115,13 +115,13 @@ describe "Send Signals" do
pub_3.callback do
resp_2 = JSON.parse(pub_3.response)
resp_2.has_key?("channels").should be_true
resp_2["channels"].to_i.should eql(1)
resp_2["published_messages"].to_i.should eql(1)
resp_2["subscribers"].to_i.should eql(1)
expect(resp_2.has_key?("channels")).to be_truthy
expect(resp_2["channels"].to_i).to eql(1)
expect(resp_2["published_messages"].to_i).to eql(1)
expect(resp_2["subscribers"].to_i).to eql(1)
open_sockets_2 = `lsof -p #{Process.getpgid resp_3["by_worker"][0]['pid'].to_i} | grep socket | wc -l`.strip
open_sockets_2.should eql(open_sockets_1)
expect(open_sockets_2).to eql(open_sockets_1)
EventMachine.stop
......@@ -129,7 +129,7 @@ describe "Send Signals" do
`#{ nginx_executable } -c #{ conf.configuration_filename } -s stop > /dev/null 2>&1`
error_log_pos = File.readlines(conf.error_log)
(error_log_pos - error_log_pre).join.should_not include("open socket")
expect((error_log_pos - error_log_pre).join).not_to include("open socket")
socket.close unless socket.nil?
end
end
......@@ -158,11 +158,11 @@ describe "Send Signals" do
# check statistics
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_1.callback do
pub_1.should be_http_status(200).with_body
expect(pub_1).to be_http_status(200).with_body
resp_1 = JSON.parse(pub_1.response)
resp_1["subscribers"].to_i.should eql(1)
resp_1["channels"].to_i.should eql(1)
resp_1["by_worker"].count.should eql(1)
expect(resp_1["subscribers"].to_i).to eql(1)
expect(resp_1["channels"].to_i).to eql(1)
expect(resp_1["by_worker"].count).to eql(1)
pid = resp_1["by_worker"][0]['pid'].to_i
# send reload signal
......@@ -175,14 +175,14 @@ describe "Send Signals" do
pub_4 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_4.callback do
resp_3 = JSON.parse(pub_4.response)
resp_3.has_key?("by_worker").should be_true
expect(resp_3.has_key?("by_worker")).to be_truthy
if resp_3["by_worker"].count == 1
resp_3["subscribers"].to_i.should eql(0)
resp_3["channels"].to_i.should eql(1)
expect(resp_3["subscribers"].to_i).to eql(0)
expect(resp_3["channels"].to_i).to eql(1)
pid2 = resp_3["by_worker"][0]['pid'].to_i
pid.should_not eql(pid2)
expect(pid).not_to eql(pid2)
EventMachine.stop
end
end
......@@ -228,11 +228,11 @@ describe "Send Signals" do
# check statistics
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_1.callback do
pub_1.should be_http_status(200).with_body
expect(pub_1).to be_http_status(200).with_body
resp_1 = JSON.parse(pub_1.response)
resp_1.has_key?("channels").should be_true
resp_1["channels"].to_i.should eql(1)
resp_1["published_messages"].to_i.should eql(1)
expect(resp_1.has_key?("channels")).to be_truthy
expect(resp_1["channels"].to_i).to eql(1)
expect(resp_1["published_messages"].to_i).to eql(1)
conf.configuration[:shared_memory_size] = '20m'
conf.create_configuration_file
......@@ -244,14 +244,14 @@ describe "Send Signals" do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
resp_2 = JSON.parse(pub_2.response)
resp_2.has_key?("channels").should be_true
resp_2["channels"].to_i.should eql(1)
resp_2["published_messages"].to_i.should eql(1)
expect(resp_2.has_key?("channels")).to be_truthy
expect(resp_2["channels"].to_i).to eql(1)
expect(resp_2["published_messages"].to_i).to eql(1)
error_log = File.read(conf.error_log)
error_log.should include("Cannot change memory area size without restart, ignoring change")
expect(error_log).to include("Cannot change memory area size without restart, ignoring change")
EventMachine.stop
end
......
......@@ -2,56 +2,56 @@ require 'spec_helper'
describe "Setup Parameters" do
it "should not accept '0' as ping message interval" do
nginx_test_configuration({:ping_message_interval => 0}).should include("push_stream_ping_message_interval cannot be zero")
expect(nginx_test_configuration({:ping_message_interval => 0})).to include("push_stream_ping_message_interval cannot be zero")
end
it "should not accept a blank message template" do
nginx_test_configuration({:message_template => ""}).should include("push_stream_message_template cannot be blank")
expect(nginx_test_configuration({:message_template => ""})).to include("push_stream_message_template cannot be blank")
end
it "should not accept '0' as subscriber connection ttl" do
nginx_test_configuration({:subscriber_connection_ttl => 0}).should include("push_stream_subscriber_connection_ttl cannot be zero")
expect(nginx_test_configuration({:subscriber_connection_ttl => 0})).to include("push_stream_subscriber_connection_ttl cannot be zero")
end
it "should not accept '0' as long polling subscriber connection ttl" do
nginx_test_configuration({:longpolling_connection_ttl => 0}).should include("push_stream_longpolling_connection_ttl cannot be zero")
expect(nginx_test_configuration({:longpolling_connection_ttl => 0})).to include("push_stream_longpolling_connection_ttl cannot be zero")
end
it "should not accept '0' as max channel id length" do
nginx_test_configuration({:max_channel_id_length => 0}).should include("push_stream_max_channel_id_length cannot be zero")
expect(nginx_test_configuration({:max_channel_id_length => 0})).to include("push_stream_max_channel_id_length cannot be zero")
end
it "should not accept '0' as message ttl" do
nginx_test_configuration({:message_ttl => 0}).should include("push_stream_message_ttl cannot be zero")
expect(nginx_test_configuration({:message_ttl => 0})).to include("push_stream_message_ttl cannot be zero")
end
it "should not accept '0' as max subscribers per channel" do
nginx_test_configuration({:max_subscribers_per_channel => 0}).should include("push_stream_max_subscribers_per_channel cannot be zero")
expect(nginx_test_configuration({:max_subscribers_per_channel => 0})).to include("push_stream_max_subscribers_per_channel cannot be zero")
end
it "should not accept '0' as max messages stored per channel" do
nginx_test_configuration({:max_messages_stored_per_channel => 0}).should include("push_stream_max_messages_stored_per_channel cannot be zero")
expect(nginx_test_configuration({:max_messages_stored_per_channel => 0})).to include("push_stream_max_messages_stored_per_channel cannot be zero")
end
it "should not accept '0' as max number of channels" do
nginx_test_configuration({:max_number_of_channels => 0}).should include("push_stream_max_number_of_channels cannot be zero")
expect(nginx_test_configuration({:max_number_of_channels => 0})).to include("push_stream_max_number_of_channels cannot be zero")
end
it "should not accept '0' as max number of wildcard channels" do
nginx_test_configuration({:max_number_of_wildcard_channels => 0}).should include("push_stream_max_number_of_wildcard_channels cannot be zero")
expect(nginx_test_configuration({:max_number_of_wildcard_channels => 0})).to include("push_stream_max_number_of_wildcard_channels cannot be zero")
end
it "should not accept '0' as max wildcard channels" do
nginx_test_configuration({:wildcard_channel_max_qtd => 0}).should include("push_stream_wildcard_channel_max_qtd cannot be zero")
expect(nginx_test_configuration({:wildcard_channel_max_qtd => 0})).to include("push_stream_wildcard_channel_max_qtd cannot be zero")
end
it "should not set max wildcard channels without set boadcast channel prefix" do
nginx_test_configuration({:wildcard_channel_max_qtd => 1, :wildcard_channel_prefix => ""}).should include("cannot set wildcard channel max qtd if push_stream_wildcard_channel_prefix is not set or blank")
expect(nginx_test_configuration({:wildcard_channel_max_qtd => 1, :wildcard_channel_prefix => ""})).to include("cannot set wildcard channel max qtd if push_stream_wildcard_channel_prefix is not set or blank")
end
it "should not accept '0' as max number of wildcard channels" do
config = {:max_number_of_wildcard_channels => 3, :wildcard_channel_max_qtd => 4, :wildcard_channel_prefix => "broad_"}
nginx_test_configuration(config).should include("max number of wildcard channels cannot be smaller than value in push_stream_wildcard_channel_max_qtd")
expect(nginx_test_configuration(config)).to include("max number of wildcard channels cannot be smaller than value in push_stream_wildcard_channel_max_qtd")
end
it "should accept a configuration without http block" do
......@@ -70,48 +70,48 @@ describe "Setup Parameters" do
}
}
}
nginx_test_configuration(config).should include("ngx_http_push_stream_module will not be used with this configuration.")
expect(nginx_test_configuration(config)).to include("ngx_http_push_stream_module will not be used with this configuration.")
end
it "should not accept an invalid push mode" do
nginx_test_configuration({:subscriber_mode => "unknown"}).should include("invalid push_stream_subscriber mode value: unknown, accepted values (streaming, polling, long-polling, eventsource, websocket)")
expect(nginx_test_configuration({:subscriber_mode => "unknown"})).to include("invalid push_stream_subscriber mode value: unknown, accepted values (streaming, polling, long-polling, eventsource, websocket)")
end
it "should accept the known push modes" do
nginx_test_configuration({:subscriber_mode => ""}).should_not include("invalid push_stream_subscriber mode value")
nginx_test_configuration({:subscriber_mode => "streaming"}).should_not include("invalid push_stream_subscriber mode value")
nginx_test_configuration({:subscriber_mode => "polling"}).should_not include("invalid push_stream_subscriber mode value")
nginx_test_configuration({:subscriber_mode => "long-polling"}).should_not include("invalid push_stream_subscriber mode value")
nginx_test_configuration({:subscriber_mode => "eventsource"}).should_not include("invalid push_stream_subscriber mode value")
nginx_test_configuration({:subscriber_mode => "websocket"}).should_not include("invalid push_stream_subscriber mode value")
expect(nginx_test_configuration({:subscriber_mode => ""})).not_to include("invalid push_stream_subscriber mode value")
expect(nginx_test_configuration({:subscriber_mode => "streaming"})).not_to include("invalid push_stream_subscriber mode value")
expect(nginx_test_configuration({:subscriber_mode => "polling"})).not_to include("invalid push_stream_subscriber mode value")
expect(nginx_test_configuration({:subscriber_mode => "long-polling"})).not_to include("invalid push_stream_subscriber mode value")
expect(nginx_test_configuration({:subscriber_mode => "eventsource"})).not_to include("invalid push_stream_subscriber mode value")
expect(nginx_test_configuration({:subscriber_mode => "websocket"})).not_to include("invalid push_stream_subscriber mode value")
end
it "should not accept an invalid publisher mode" do
nginx_test_configuration({:publisher_mode => "unknown"}).should include("invalid push_stream_publisher mode value: unknown, accepted values (normal, admin)")
expect(nginx_test_configuration({:publisher_mode => "unknown"})).to include("invalid push_stream_publisher mode value: unknown, accepted values (normal, admin)")
end
it "should accept the known publisher modes" do
nginx_test_configuration({:publisher_mode => ""}).should_not include("invalid push_stream_publisher mode value")
nginx_test_configuration({:publisher_mode => "normal"}).should_not include("invalid push_stream_publisher mode value")
nginx_test_configuration({:publisher_mode => "admin"}).should_not include("invalid push_stream_publisher mode value")
expect(nginx_test_configuration({:publisher_mode => ""})).not_to include("invalid push_stream_publisher mode value")
expect(nginx_test_configuration({:publisher_mode => "normal"})).not_to include("invalid push_stream_publisher mode value")
expect(nginx_test_configuration({:publisher_mode => "admin"})).not_to include("invalid push_stream_publisher mode value")
end
it "should not accept an invalid pattern for padding by user agent" do
nginx_test_configuration({:padding_by_user_agent => "user_agent,as,df"}).should include("padding pattern not match the value user_agent,as,df")
nginx_test_configuration({:padding_by_user_agent => "user_agent;10;0"}).should include("padding pattern not match the value user_agent;10;0")
nginx_test_configuration({:padding_by_user_agent => "user_agent,10,0:other_user_agent;20;0:another_user_agent,30,0"}).should include("error applying padding pattern to other_user_agent;20;0:another_user_agent,30,0")
expect(nginx_test_configuration({:padding_by_user_agent => "user_agent,as,df"})).to include("padding pattern not match the value user_agent,as,df")
expect(nginx_test_configuration({:padding_by_user_agent => "user_agent;10;0"})).to include("padding pattern not match the value user_agent;10;0")
expect(nginx_test_configuration({:padding_by_user_agent => "user_agent,10,0:other_user_agent;20;0:another_user_agent,30,0"})).to include("error applying padding pattern to other_user_agent;20;0:another_user_agent,30,0")
end
it "should not accept an invalid shared memory size" do
nginx_test_configuration({:shared_memory_size => nil}).should include("push_stream_shared_memory_size must be set.")
expect(nginx_test_configuration({:shared_memory_size => nil})).to include("push_stream_shared_memory_size must be set.")
end
it "should not accept a small shared memory size" do
nginx_test_configuration({:shared_memory_size => "100k"}).should include("The push_stream_shared_memory_size value must be at least")
expect(nginx_test_configuration({:shared_memory_size => "100k"})).to include("The push_stream_shared_memory_size value must be at least")
end
it "should not accept an invalid channels path value" do
nginx_test_configuration({:channels_path => nil}).should include("push stream module: push_stream_channels_path must be set.")
nginx_test_configuration({:channels_path_for_pub => nil}).should include("push stream module: push_stream_channels_path must be set.")
expect(nginx_test_configuration({:channels_path => nil})).to include("push stream module: push_stream_channels_path must be set.")
expect(nginx_test_configuration({:channels_path_for_pub => nil})).to include("push stream module: push_stream_channels_path must be set.")
end
end
......@@ -22,11 +22,11 @@ describe "Wildcard Properties" do
pub.callback do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + channel_broad_fail).get :head => headers
sub_1.callback do |chunk|
sub_1.should be_http_status(403).without_body
expect(sub_1).to be_http_status(403).without_body
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + channel_broad).get :head => headers
sub_2.stream do |chunk2|
chunk2.should eql(conf.header_template)
expect(chunk2).to eql(conf.header_template)
EventMachine.stop
end
end
......@@ -48,7 +48,7 @@ describe "Wildcard Properties" do
pub.callback do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + channel_broad1 + '/' + channel_broad2 + '/' + channel_broad3).get :head => headers
sub_1.callback do |chunk|
sub_1.should be_http_status(403).without_body
expect(sub_1).to be_http_status(403).without_body
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + channel_broad1 + '/' + channel_broad2).get :head => headers
sub_2.stream do
EventMachine.stop
......
......@@ -10,7 +10,7 @@ describe "Publisher Channel id collision" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel).post :body => 'x'
pub.callback do
pub.should be_http_status(200)
expect(pub).to be_http_status(200)
EventMachine.stop
end
end
......@@ -20,7 +20,7 @@ describe "Publisher Channel id collision" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel).get :timeout => 30
pub.callback do
pub.should be_http_status(200)
expect(pub).to be_http_status(200)
EventMachine.stop
end
end
......
......@@ -8,8 +8,8 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=').get :head => headers
pub.callback do
pub.should be_http_status(400).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("No channel id provided.")
expect(pub).to be_http_status(400).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("No channel id provided.")
EventMachine.stop
end
end
......@@ -25,7 +25,7 @@ describe "Publisher Properties" do
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_1.to_s).get :head => headers
pub_1.callback do
pub_1.should be_http_status(404).without_body
expect(pub_1).to be_http_status(404).without_body
EventMachine.stop
end
end
......@@ -33,9 +33,9 @@ describe "Publisher Properties" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2.to_s ).post :head => headers, :body => body
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
response = JSON.parse(pub_2.response)
response["channel"].to_s.should eql(channel_2)
expect(response["channel"].to_s).to eql(channel_2)
EventMachine.stop
end
end
......@@ -51,9 +51,9 @@ describe "Publisher Properties" do
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body
pub_1.callback do
pub_1.should be_http_status(200).with_body
expect(pub_1).to be_http_status(200).with_body
response = JSON.parse(pub_1.response)
response["channel"].to_s.should eql(channel)
expect(response["channel"].to_s).to eql(channel)
EventMachine.stop
end
end
......@@ -61,9 +61,9 @@ describe "Publisher Properties" do
EventMachine.run do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).get :head => headers
pub_2.callback do
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
response = JSON.parse(pub_2.response)
response["channel"].to_s.should eql(channel)
expect(response["channel"].to_s).to eql(channel)
EventMachine.stop
end
end
......@@ -76,8 +76,8 @@ describe "Publisher Properties" do
socket = open_socket(nginx_host, nginx_port)
socket.print("OPTIONS /pub?id=ch_test_accepted_methods HTTP/1.0\r\n\r\n")
headers, body = read_response_on_socket(socket)
headers.should match_the_pattern(/HTTP\/1\.1 200 OK/)
headers.should match_the_pattern(/Content-Length: 0/)
expect(headers).to match_the_pattern(/HTTP\/1\.1 200 OK/)
expect(headers).to match_the_pattern(/Content-Length: 0/)
socket.close
EventMachine.run do
......@@ -90,28 +90,28 @@ describe "Publisher Properties" do
multi.add(:e, EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch_test_accepted_methods_5').head)
multi.callback do
multi.responses[:callback].length.should eql(5)
expect(multi.responses[:callback].length).to eql(5)
multi.responses[:callback][:a].should_not be_http_status(405)
multi.responses[:callback][:a].req.method.should eql("GET")
expect(multi.responses[:callback][:a]).not_to be_http_status(405)
expect(multi.responses[:callback][:a].req.method).to eql("GET")
multi.responses[:callback][:b].should_not be_http_status(405)
multi.responses[:callback][:b].req.method.should eql("PUT")
expect(multi.responses[:callback][:b]).not_to be_http_status(405)
expect(multi.responses[:callback][:b].req.method).to eql("PUT")
multi.responses[:callback][:c].should_not be_http_status(405)
multi.responses[:callback][:c].req.method.should eql("POST")
expect(multi.responses[:callback][:c]).not_to be_http_status(405)
expect(multi.responses[:callback][:c].req.method).to eql("POST")
multi.responses[:callback][:d].req.method.should eql("DELETE")
expect(multi.responses[:callback][:d].req.method).to eql("DELETE")
if conf.publisher_mode == 'admin'
multi.responses[:callback][:d].should_not be_http_status(405)
expect(multi.responses[:callback][:d]).not_to be_http_status(405)
else
multi.responses[:callback][:d].should be_http_status(405)
multi.responses[:callback][:d].response_header['ALLOW'].should eql(accepted_methods)
expect(multi.responses[:callback][:d]).to be_http_status(405)
expect(multi.responses[:callback][:d].response_header['ALLOW']).to eql(accepted_methods)
end
multi.responses[:callback][:e].should be_http_status(405)
multi.responses[:callback][:e].req.method.should eql("HEAD")
multi.responses[:callback][:e].response_header['ALLOW'].should eql(accepted_methods)
expect(multi.responses[:callback][:e]).to be_http_status(405)
expect(multi.responses[:callback][:e].req.method).to eql("HEAD")
expect(multi.responses[:callback][:e].response_header['ALLOW']).to eql(accepted_methods)
EventMachine.stop
end
......@@ -127,8 +127,8 @@ describe "Publisher Properties" do
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body
pub_1.callback do
pub_1.should be_http_status(403).without_body
pub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel id not authorized for this method.")
expect(pub_1).to be_http_status(403).without_body
expect(pub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel id not authorized for this method.")
EventMachine.stop
end
end
......@@ -149,10 +149,10 @@ describe "Publisher Properties" do
multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2).post(:head => headers, :body => body))
multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_3).post(:head => headers, :body => body))
multi.callback do
multi.responses[:callback].length.should eql(3)
expect(multi.responses[:callback].length).to eql(3)
multi.responses[:callback].each do |name, response|
response.should be_http_status(403).without_body
response.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel id not authorized for this method.")
expect(response).to be_http_status(403).without_body
expect(response.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel id not authorized for this method.")
end
EventMachine.stop
......@@ -173,7 +173,7 @@ describe "Publisher Properties" do
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body
pub_1.callback do
pub_1.should be_http_status(413)
expect(pub_1).to be_http_status(413)
EventMachine.stop
end
end
......@@ -192,7 +192,7 @@ describe "Publisher Properties" do
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body
pub_1.callback do
pub_1.should be_http_status(200).with_body
expect(pub_1).to be_http_status(200).with_body
fail("Let a file on client body temp dir") unless Dir.entries(conf.client_body_temp).select {|f| f if File.file?(File.expand_path(f, conf.client_body_temp)) }.empty?
EventMachine.stop
end
......@@ -212,7 +212,7 @@ describe "Publisher Properties" do
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body
pub_1.callback do
pub_1.should be_http_status(200).with_body
expect(pub_1).to be_http_status(200).with_body
fail("Let a file on client body temp dir") unless Dir.entries(conf.client_body_temp).select {|f| f if File.file?(File.expand_path(f, conf.client_body_temp)) }.empty?
EventMachine.stop
end
......@@ -229,12 +229,12 @@ describe "Publisher Properties" do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
pub_1.callback do
response = JSON.parse(pub_1.response)
response["stored_messages"].to_i.should eql(1)
expect(response["stored_messages"].to_i).to eql(1)
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
pub_2.callback do
response = JSON.parse(pub_2.response)
response["stored_messages"].to_i.should eql(2)
expect(response["stored_messages"].to_i).to eql(2)
EventMachine.stop
end
end
......@@ -251,7 +251,7 @@ describe "Publisher Properties" do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
pub.callback do
response = JSON.parse(pub.response)
response["stored_messages"].to_i.should eql(0)
expect(response["stored_messages"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -276,7 +276,7 @@ describe "Publisher Properties" do
stored_messages = response["stored_messages"].to_i
end
else
stored_messages.should eql(conf.max_messages_stored_per_channel)
expect(stored_messages).to eql(conf.max_messages_stored_per_channel)
EventMachine.stop
end
end
......@@ -292,8 +292,8 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
pub.callback do
pub.should be_http_status(400).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel id is too large.")
expect(pub).to be_http_status(400).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel id is too large.")
EventMachine.stop
end
end
......@@ -308,7 +308,7 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s + 1.to_s).post :head => headers, :body => body
pub.callback do
pub.should be_http_status(200).with_body
expect(pub).to be_http_status(200).with_body
EventMachine.stop
end
end
......@@ -316,8 +316,8 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s + 2.to_s).post :head => headers, :body => body
pub.callback do
pub.should be_http_status(403).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Number of channels were exceeded.")
expect(pub).to be_http_status(403).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Number of channels were exceeded.")
EventMachine.stop
end
end
......@@ -332,7 +332,7 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s + 1.to_s).post :head => headers, :body => body
pub.callback do
pub.should be_http_status(200).with_body
expect(pub).to be_http_status(200).with_body
EventMachine.stop
end
end
......@@ -340,8 +340,8 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s + 2.to_s).post :head => headers, :body => body
pub.callback do
pub.should be_http_status(403).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Number of channels were exceeded.")
expect(pub).to be_http_status(403).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Number of channels were exceeded.")
EventMachine.stop
end
end
......@@ -355,9 +355,9 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel).get :head => headers
pub.callback do
pub.response_header['ACCESS_CONTROL_ALLOW_ORIGIN'].should be_nil
pub.response_header['ACCESS_CONTROL_ALLOW_METHODS'].should be_nil
pub.response_header['ACCESS_CONTROL_ALLOW_HEADERS'].should be_nil
expect(pub.response_header['ACCESS_CONTROL_ALLOW_ORIGIN']).to be_nil
expect(pub.response_header['ACCESS_CONTROL_ALLOW_METHODS']).to be_nil
expect(pub.response_header['ACCESS_CONTROL_ALLOW_HEADERS']).to be_nil
EventMachine.stop
end
......@@ -373,9 +373,9 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel).get :head => headers
pub.callback do
pub.response_header['ACCESS_CONTROL_ALLOW_ORIGIN'].should eql("custom.domain.com")
pub.response_header['ACCESS_CONTROL_ALLOW_METHODS'].should eql(accepted_methods)
pub.response_header['ACCESS_CONTROL_ALLOW_HEADERS'].should eql("If-Modified-Since,If-None-Match,Etag,Event-Id,Event-Type,Last-Event-Id")
expect(pub.response_header['ACCESS_CONTROL_ALLOW_ORIGIN']).to eql("custom.domain.com")
expect(pub.response_header['ACCESS_CONTROL_ALLOW_METHODS']).to eql(accepted_methods)
expect(pub.response_header['ACCESS_CONTROL_ALLOW_HEADERS']).to eql("If-Modified-Since,If-None-Match,Etag,Event-Id,Event-Type,Last-Event-Id")
EventMachine.stop
end
......@@ -390,9 +390,9 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel + '&domain=test.com').get :head => headers
pub.callback do
pub.response_header['ACCESS_CONTROL_ALLOW_ORIGIN'].should eql("test.com")
pub.response_header['ACCESS_CONTROL_ALLOW_METHODS'].should eql(accepted_methods)
pub.response_header['ACCESS_CONTROL_ALLOW_HEADERS'].should eql("If-Modified-Since,If-None-Match,Etag,Event-Id,Event-Type,Last-Event-Id")
expect(pub.response_header['ACCESS_CONTROL_ALLOW_ORIGIN']).to eql("test.com")
expect(pub.response_header['ACCESS_CONTROL_ALLOW_METHODS']).to eql(accepted_methods)
expect(pub.response_header['ACCESS_CONTROL_ALLOW_HEADERS']).to eql("If-Modified-Since,If-None-Match,Etag,Event-Id,Event-Type,Last-Event-Id")
EventMachine.stop
end
......@@ -409,7 +409,7 @@ describe "Publisher Properties" do
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
pub_1.callback do
pub_1.should be_http_status(200).without_body
expect(pub_1).to be_http_status(200).without_body
EventMachine.stop
end
......@@ -452,8 +452,8 @@ describe "Publisher Properties" do
end
EM.add_timer(2) do
resp_1.should eql("<script>p(1,'channel_id_inside_if_block','published message');</script>")
resp_2.should eql("<script>p(1,'test_channel_id_inside_if_block','published message');</script>")
expect(resp_1).to eql("<script>p(1,'channel_id_inside_if_block','published message');</script>")
expect(resp_2).to eql("<script>p(1,'test_channel_id_inside_if_block','published message');</script>")
EventMachine.stop
end
......@@ -492,17 +492,17 @@ describe "Publisher Properties" do
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub2?id=' + channel.to_s).post :head => headers, :body => body
pub_1.callback do
pub_1.should be_http_status(200)
expect(pub_1).to be_http_status(200)
response = JSON.parse(pub_1.response)
response["published_messages"].to_i.should eql(1)
response["stored_messages"].to_i.should eql(0)
expect(response["published_messages"].to_i).to eql(1)
expect(response["stored_messages"].to_i).to eql(0)
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/pub2?id=' + channel.to_s + '&test=1').post :head => headers, :body => body
pub_2.callback do
pub_2.should be_http_status(200)
expect(pub_2).to be_http_status(200)
response = JSON.parse(pub_2.response)
response["published_messages"].to_i.should eql(2)
response["stored_messages"].to_i.should eql(1)
expect(response["published_messages"].to_i).to eql(2)
expect(response["stored_messages"].to_i).to eql(1)
EventMachine.stop
end
......@@ -518,8 +518,8 @@ describe "Publisher Properties" do
EventMachine.run do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).get :head => headers
pub_1.callback do
pub_1.response_header["EXPIRES"].should eql("Thu, 01 Jan 1970 00:00:01 GMT")
pub_1.response_header["CACHE_CONTROL"].should eql("no-cache, no-store, must-revalidate")
expect(pub_1.response_header["EXPIRES"]).to eql("Thu, 01 Jan 1970 00:00:01 GMT")
expect(pub_1.response_header["CACHE_CONTROL"]).to eql("no-cache, no-store, must-revalidate")
EventMachine.stop
end
end
......@@ -541,13 +541,13 @@ describe "Publisher Properties" do
actual_response << chunk
end
pub.callback do
pub.response_header.status.should eql(200)
pub.response_header.content_length.should_not eql(0)
pub.response_header["CONTENT_ENCODING"].should eql("gzip")
expect(pub.response_header.status).to eql(200)
expect(pub.response_header.content_length).not_to eql(0)
expect(pub.response_header["CONTENT_ENCODING"]).to eql("gzip")
actual_response = Zlib::GzipReader.new(StringIO.new(actual_response)).read
response = JSON.parse(actual_response)
response["channel"].to_s.should eql(channel)
expect(response["channel"].to_s).to eql(channel)
EventMachine.stop
end
end
......@@ -566,13 +566,13 @@ describe "Publisher Properties" do
actual_response << chunk
end
pub.callback do
pub.response_header.status.should eql(200)
pub.response_header.content_length.should_not eql(0)
pub.response_header["CONTENT_ENCODING"].should eql("gzip")
expect(pub.response_header.status).to eql(200)
expect(pub.response_header.content_length).not_to eql(0)
expect(pub.response_header["CONTENT_ENCODING"]).to eql("gzip")
actual_response = Zlib::GzipReader.new(StringIO.new(actual_response)).read
response = JSON.parse(actual_response)
response["channel"].to_s.should eql(channel)
expect(response["channel"].to_s).to eql(channel)
EventMachine.stop
end
end
......@@ -588,19 +588,19 @@ describe "Publisher Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + "_1").get :head => headers
sub_1.stream do |chunk|
chunk.should eql("#{body}|#{channel.to_s + "_1"}")
expect(chunk).to eql("#{body}|#{channel.to_s + "_1"}")
messages += 1
end
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + "_2").get :head => headers
sub_2.stream do |chunk|
chunk.should eql("#{body}|#{channel.to_s + "_2"}")
expect(chunk).to eql("#{body}|#{channel.to_s + "_2"}")
messages += 1
end
sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + "_3").get :head => headers
sub_3.stream do |chunk|
chunk.should eql("#{body}|#{channel.to_s + "_3"}")
expect(chunk).to eql("#{body}|#{channel.to_s + "_3"}")
messages += 1
end
......@@ -650,12 +650,12 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).get :head => headers
pub.callback do
pub.should be_http_status(404).without_body
expect(pub).to be_http_status(404).without_body
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub_1.callback do
pub_1.should be_http_status(404).without_body
pub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should be_nil
expect(pub_1).to be_http_status(404).without_body
expect(pub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to be_nil
EventMachine.stop
end
end
......@@ -670,8 +670,8 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=').delete :head => headers
pub.callback do
pub.should be_http_status(400).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("No channel id provided.")
expect(pub).to be_http_status(400).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("No channel id provided.")
EventMachine.stop
end
end
......@@ -685,8 +685,8 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).delete :head => headers
pub.callback do
pub.should be_http_status(400).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel id is too large.")
expect(pub).to be_http_status(400).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel id is too large.")
EventMachine.stop
end
end
......@@ -703,15 +703,15 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do
pub.should be_http_status(200).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
expect(pub).to be_http_status(200).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel deleted.")
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
stats.callback do
stats.should be_http_status(200).with_body
expect(stats).to be_http_status(200).with_body
response = JSON.parse(stats.response)
response["channels"].to_s.should_not be_empty
response["channels"].to_i.should eql(0)
expect(response["channels"].to_s).not_to be_empty
expect(response["channels"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -740,28 +740,28 @@ describe "Publisher Properties" do
if resp.strip.empty?
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats.callback do
stats.should be_http_status(200).with_body
expect(stats).to be_http_status(200).with_body
response = JSON.parse(stats.response)
response["subscribers"].to_i.should eql(1)
response["channels"].to_i.should eql(1)
expect(response["subscribers"].to_i).to eql(1)
expect(response["channels"].to_i).to eql(1)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do
pub.should be_http_status(200).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
expect(pub).to be_http_status(200).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel deleted.")
end
end
else
response = JSON.parse(resp)
response["channel"].should eql(channel)
response["id"].to_i.should eql(-2)
response["text"].should eql("Channel deleted")
expect(response["channel"]).to eql(channel)
expect(response["id"].to_i).to eql(-2)
expect(response["text"]).to eql("Channel deleted")
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats.callback do
stats.should be_http_status(200).with_body
expect(stats).to be_http_status(200).with_body
response = JSON.parse(stats.response)
response["subscribers"].to_i.should eql(0)
response["channels"].to_i.should eql(0)
expect(response["subscribers"].to_i).to eql(0)
expect(response["channels"].to_i).to eql(0)
end
EventMachine.stop
end
......@@ -791,31 +791,31 @@ describe "Publisher Properties" do
if resp.strip.empty?
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}, :timeout => 30
stats.callback do
stats.response_header.status.should eql(200)
stats.response_header.content_length.should_not eql(0)
expect(stats.response_header.status).to eql(200)
expect(stats.response_header.content_length).not_to eql(0)
response = JSON.parse(stats.response)
response["subscribers"].to_i.should eql(1)
response["channels"].to_i.should eql(1)
expect(response["subscribers"].to_i).to eql(1)
expect(response["channels"].to_i).to eql(1)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers, :body => "custom channel delete message", :timeout => 30
pub.callback do
pub.response_header.status.should eql(200)
pub.response_header.content_length.should eql(0)
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
expect(pub.response_header.status).to eql(200)
expect(pub.response_header.content_length).to eql(0)
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel deleted.")
end
end
else
response = JSON.parse(resp)
response["channel"].should eql(channel)
response["id"].to_i.should eql(-2)
response["text"].should eql("custom channel delete message")
expect(response["channel"]).to eql(channel)
expect(response["id"].to_i).to eql(-2)
expect(response["text"]).to eql("custom channel delete message")
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}, :timeout => 30
stats.callback do
stats.response_header.status.should eql(200)
stats.response_header.content_length.should_not eql(0)
expect(stats.response_header.status).to eql(200)
expect(stats.response_header.content_length).not_to eql(0)
response = JSON.parse(stats.response)
response["subscribers"].to_i.should eql(0)
response["channels"].to_i.should eql(0)
expect(response["subscribers"].to_i).to eql(0)
expect(response["channels"].to_i).to eql(0)
end
EventMachine.stop
end
......@@ -847,61 +847,61 @@ describe "Publisher Properties" do
if resp.strip.empty?
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats.callback do
stats.should be_http_status(200).with_body
expect(stats).to be_http_status(200).with_body
response = JSON.parse(stats.response)
response["subscribers"].to_i.should eql(1)
response["channels"].to_i.should eql(2)
expect(response["subscribers"].to_i).to eql(1)
expect(response["channels"].to_i).to eql(2)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_1.to_s).delete :head => headers
pub.callback do
pub.should be_http_status(200).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
expect(pub).to be_http_status(200).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel deleted.")
end
end
else
if !stage1_complete
stage1_complete = true
response = JSON.parse(resp.split("|")[0])
response["channel"].should eql(channel_1)
response["id"].to_i.should eql(-2)
response["text"].should eql("Channel deleted")
expect(response["channel"]).to eql(channel_1)
expect(response["id"].to_i).to eql(-2)
expect(response["text"]).to eql("Channel deleted")
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats.callback do
stats.should be_http_status(200).with_body
expect(stats).to be_http_status(200).with_body
response = JSON.parse(stats.response)
response["subscribers"].to_i.should eql(1)
response["channels"].to_i.should eql(1)
expect(response["subscribers"].to_i).to eql(1)
expect(response["channels"].to_i).to eql(1)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2.to_s).post :head => headers, :body=> body
pub.callback do
pub.should be_http_status(200).with_body
expect(pub).to be_http_status(200).with_body
end
end
elsif !stage2_complete
stage2_complete = true
response = JSON.parse(resp.split("|")[1])
response["channel"].should eql(channel_2)
response["id"].to_i.should eql(1)
response["text"].should eql(body)
expect(response["channel"]).to eql(channel_2)
expect(response["id"].to_i).to eql(1)
expect(response["text"]).to eql(body)
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2.to_s).delete :head => headers
pub.callback do
pub.should be_http_status(200).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
expect(pub).to be_http_status(200).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel deleted.")
end
else
response = JSON.parse(resp.split("|")[2])
response["channel"].should eql(channel_2)
response["id"].to_i.should eql(-2)
response["text"].should eql("Channel deleted")
expect(response["channel"]).to eql(channel_2)
expect(response["id"].to_i).to eql(-2)
expect(response["text"]).to eql("Channel deleted")
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats.callback do
stats.should be_http_status(200).with_body
expect(stats).to be_http_status(200).with_body
response = JSON.parse(stats.response)
response["subscribers"].to_i.should eql(0)
response["channels"].to_i.should eql(0)
expect(response["subscribers"].to_i).to eql(0)
expect(response["channels"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -931,7 +931,7 @@ describe "Publisher Properties" do
resp_1 += chunk
end
sub_1.callback do
resp_1.should eql("{\"id\":\"-2\", \"channel\":\"test_delete_channels_whith_subscribers_1\", \"text\":\"Channel deleted\"}FOOTER")
expect(resp_1).to eql("{\"id\":\"-2\", \"channel\":\"test_delete_channels_whith_subscribers_1\", \"text\":\"Channel deleted\"}FOOTER")
end
resp_2 = ""
......@@ -940,40 +940,40 @@ describe "Publisher Properties" do
resp_2 += chunk
end
sub_2.callback do
resp_2.should eql("{\"id\":\"-2\", \"channel\":\"test_delete_channels_whith_subscribers_2\", \"text\":\"Channel deleted\"}FOOTER")
expect(resp_2).to eql("{\"id\":\"-2\", \"channel\":\"test_delete_channels_whith_subscribers_2\", \"text\":\"Channel deleted\"}FOOTER")
end
EM.add_timer(0.5) do
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats.callback do
stats.should be_http_status(200).with_body
expect(stats).to be_http_status(200).with_body
response = JSON.parse(stats.response)
response["subscribers"].to_i.should eql(2)
response["channels"].to_i.should eql(2)
expect(response["subscribers"].to_i).to eql(2)
expect(response["channels"].to_i).to eql(2)
end
end
EM.add_timer(1.5) do
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_1.to_s).delete :head => headers
pub_1.callback do
pub_1.should be_http_status(200).without_body
pub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
expect(pub_1).to be_http_status(200).without_body
expect(pub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel deleted.")
end
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel_2.to_s).delete :head => headers
pub_2.callback do
pub_2.should be_http_status(200).without_body
pub_2.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
expect(pub_2).to be_http_status(200).without_body
expect(pub_2.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel deleted.")
end
end
EM.add_timer(5) do
stats_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => {'accept' => 'application/json'}
stats_2.callback do
stats_2.should be_http_status(200).with_body
expect(stats_2).to be_http_status(200).with_body
response = JSON.parse(stats_2.response)
response["subscribers"].to_i.should eql(0)
response["channels"].to_i.should eql(0)
expect(response["subscribers"].to_i).to eql(0)
expect(response["channels"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -1002,13 +1002,13 @@ describe "Publisher Properties" do
if resp == conf.header_template
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do
pub.should be_http_status(200).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
expect(pub).to be_http_status(200).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel deleted.")
end
end
end
sub_1.callback do
resp.should eql("#{conf.header_template}Channel deleted#{conf.footer_template}")
expect(resp).to eql("#{conf.header_template}Channel deleted#{conf.footer_template}")
EventMachine.stop
end
end
......@@ -1055,14 +1055,14 @@ describe "Publisher Properties" do
EM.add_timer(1) do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do
pub.should be_http_status(200).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
expect(pub).to be_http_status(200).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel deleted.")
end
end
EM.add_timer(2) do
resp.should eql("#{conf.header_template}Channel deleted#{conf.footer_template}")
resp2.should eql("<html><body>|Channel deleted|</body></html>")
expect(resp).to eql("#{conf.header_template}Channel deleted#{conf.footer_template}")
expect(resp2).to eql("<html><body>|Channel deleted|</body></html>")
EventMachine.stop
end
end
......@@ -1091,14 +1091,14 @@ describe "Publisher Properties" do
if resp.strip.empty?
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do
pub.should be_http_status(200).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
expect(pub).to be_http_status(200).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel deleted.")
end
else
response = JSON.parse(resp)
response["channel"].should eql(channel)
response["id"].to_i.should eql(-2)
response["text"].should eql(conf.channel_deleted_message_text)
expect(response["channel"]).to eql(channel)
expect(response["id"].to_i).to eql(-2)
expect(response["text"]).to eql(conf.channel_deleted_message_text)
EventMachine.stop
end
end
......@@ -1116,15 +1116,15 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch1/ch2').delete :head => headers
pub.callback do
pub.should be_http_status(200).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
expect(pub).to be_http_status(200).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel deleted.")
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get :head => headers
stats.callback do
stats.should be_http_status(200).with_body
expect(stats).to be_http_status(200).with_body
response = JSON.parse(stats.response)
response["channels"].to_s.should_not be_empty
response["channels"].to_i.should eql(0)
expect(response["channels"].to_s).not_to be_empty
expect(response["channels"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -1143,18 +1143,18 @@ describe "Publisher Properties" do
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=ch3/ch4/ch1').delete :head => headers
pub.callback do
pub.should be_http_status(200).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
expect(pub).to be_http_status(200).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel deleted.")
stats = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :head => headers
stats.callback do
stats.should be_http_status(200).with_body
expect(stats).to be_http_status(200).with_body
response = JSON.parse(stats.response)
response["channels"].to_s.should_not be_empty
response["channels"].to_i.should eql(1)
response["infos"][0]["channel"].should eql("ch2")
response["infos"][0]["published_messages"].should eql("1")
response["infos"][0]["stored_messages"].should eql("1")
expect(response["channels"].to_s).not_to be_empty
expect(response["channels"].to_i).to eql(1)
expect(response["infos"][0]["channel"]).to eql("ch2")
expect(response["infos"][0]["published_messages"]).to eql("1")
expect(response["infos"][0]["stored_messages"]).to eql("1")
EventMachine.stop
end
end
......
......@@ -18,7 +18,7 @@ describe "Publisher Publishing Messages" do
EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub.stream do |chunk|
chunk.should eql(body)
expect(chunk).to eql(body)
EventMachine.stop
end
......@@ -35,7 +35,7 @@ describe "Publisher Publishing Messages" do
EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub.stream do |chunk|
chunk.should eql(body)
expect(chunk).to eql(body)
EventMachine.stop
end
......@@ -69,7 +69,7 @@ describe "Publisher Publishing Messages" do
end
sub.callback do
response.bytes.to_a.should eql(body.bytes.to_a)
expect(response.bytes.to_a).to eql(body.bytes.to_a)
EventMachine.stop
end
......@@ -95,7 +95,7 @@ describe "Publisher Publishing Messages" do
response_sub += chunk
if response_sub.include?('A')
response_sub.should eql(large_message + 'A')
expect(response_sub).to eql(large_message + 'A')
response_sub = ''
# check if getting old messages works fine too
......@@ -104,7 +104,7 @@ describe "Publisher Publishing Messages" do
response_sub_1 += chunk_1
if response_sub_1.include?('A')
response_sub_1.should eql(large_message + 'A')
expect(response_sub_1).to eql(large_message + 'A')
response_sub_1 = ''
publish_message_inline(channel, headers, small_message + 'B')
......@@ -123,11 +123,11 @@ describe "Publisher Publishing Messages" do
EM.add_timer(3) do
if response_sub.include?('B') && response_sub_1.include?('B')
response_sub.should eql(small_message + 'B')
response_sub_1.should eql(small_message + 'B')
expect(response_sub).to eql(small_message + 'B')
expect(response_sub_1).to eql(small_message + 'B')
large_message.size.should eql(4194304) # 4mb
small_message.size.should eql(10204) # 10k
expect(large_message.size).to eql(4194304) # 4mb
expect(small_message.size).to eql(10204) # 10k
EventMachine.stop
end
end
......@@ -150,8 +150,8 @@ describe "Publisher Publishing Messages" do
response += chunk
end
pub.callback do
(Time.now - start).should be < 0.1 #should fast proccess message
response.strip.should eql('{"channel": "ch_test_publish_messages_with_template_patterns", "published_messages": "1", "stored_messages": "1", "subscribers": "0"}')
expect(Time.now - start).to be < 0.1 #should fast proccess message
expect(response.strip).to eql('{"channel": "ch_test_publish_messages_with_template_patterns", "published_messages": "1", "stored_messages": "1", "subscribers": "0"}')
EventMachine.stop
end
end
......@@ -172,7 +172,7 @@ describe "Publisher Publishing Messages" do
recieved_messages = response.split("|")
if recieved_messages.length == messagens_to_publish
recieved_messages.last.should eql(body_prefix + messagens_to_publish.to_s)
expect(recieved_messages.last).to eql(body_prefix + messagens_to_publish.to_s)
EventMachine.stop
end
end
......@@ -202,10 +202,10 @@ describe "Publisher Publishing Messages" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get
sub.stream do |chunk|
response = JSON.parse(chunk)
response["id"].to_i.should eql(1)
response["channel"].should eql(channel)
response["text"].should eql(body)
response["event_id"].should eql(event_id)
expect(response["id"].to_i).to eql(1)
expect(response["channel"]).to eql(channel)
expect(response["text"]).to eql(body)
expect(response["event_id"]).to eql(event_id)
EventMachine.stop
end
......@@ -225,10 +225,10 @@ describe "Publisher Publishing Messages" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get
sub.stream do |chunk|
response = JSON.parse(chunk)
response["id"].to_i.should eql(1)
response["channel"].should eql(channel)
response["text"].should eql(body)
response["event_type"].should eql(event_type)
expect(response["id"].to_i).to eql(1)
expect(response["channel"]).to eql(channel)
expect(response["text"]).to eql(body)
expect(response["event_type"]).to eql(event_type)
EventMachine.stop
end
......@@ -248,10 +248,10 @@ describe "Publisher Publishing Messages" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get
sub.stream do |chunk|
response = JSON.parse(chunk)
response["id"].to_i.should eql(1)
response["channel"].should eql(channel)
response["text"].should eql(body)
response["event_id"].should eql("")
expect(response["id"].to_i).to eql(1)
expect(response["channel"]).to eql(channel)
expect(response["text"]).to eql(body)
expect(response["event_id"]).to eql("")
EventMachine.stop
end
......@@ -262,10 +262,10 @@ describe "Publisher Publishing Messages" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get
sub.stream do |chunk|
response = JSON.parse(chunk)
response["id"].to_i.should eql(2)
response["channel"].should eql(channel)
response["text"].should eql(body)
response["event_id"].should eql("")
expect(response["id"].to_i).to eql(2)
expect(response["channel"]).to eql(channel)
expect(response["text"]).to eql(body)
expect(response["event_id"]).to eql("")
EventMachine.stop
end
......@@ -285,12 +285,12 @@ describe "Publisher Publishing Messages" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get
sub.stream do |chunk|
response = JSON.parse(chunk)
response["id"].to_i.should eql(1)
response["channel"].should eql(channel)
response["text"].should eql(body)
response["publish_time"].size.should eql(29)
expect(response["id"].to_i).to eql(1)
expect(response["channel"]).to eql(channel)
expect(response["text"]).to eql(body)
expect(response["publish_time"].size).to eql(29)
publish_time = Time.parse(response["publish_time"])
publish_time.to_i.should be_in_the_interval(now.to_i, now.to_i + 1)
expect(publish_time.to_i).to be_in_the_interval(now.to_i, now.to_i + 1)
EventMachine.stop
end
......@@ -315,10 +315,10 @@ describe "Publisher Publishing Messages" do
if lines.size > 1
lines.each_with_index do |line, i|
resp = JSON.parse(line)
resp["id"].to_i.should eql(i + 1)
resp["channel"].should eql(channel)
resp["text"].should eql(body)
resp["tag"].to_i.should eql(i)
expect(resp["id"].to_i).to eql(i + 1)
expect(resp["channel"]).to eql(channel)
expect(resp["text"]).to eql(body)
expect(resp["tag"].to_i).to eql(i)
end
end
......
......@@ -23,7 +23,7 @@ def publish_message_inline(channel, headers, body, delay=0.01, &block)
EM.add_timer(delay) do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).post :head => headers, :body => body
pub.callback do
pub.should be_http_status(200)
expect(pub).to be_http_status(200)
block.call(pub) unless block.nil?
end
end
......@@ -39,7 +39,7 @@ def publish_message(channel, headers, body)
content = Zlib::GzipReader.new(StringIO.new(content)).read
end
response = JSON.parse(content)
response["channel"].to_s.should eql(channel)
expect(response["channel"].to_s).to eql(channel)
end
def post_to(path, headers, body)
......
......@@ -18,7 +18,7 @@ describe "Comunication Properties" do
EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub.stream do |chunk|
chunk.should eql(conf.header_template)
expect(chunk).to eql(conf.header_template)
EventMachine.stop
end
end
......@@ -33,14 +33,14 @@ describe "Comunication Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.callback do |chunk|
sub_1.should be_http_status(403).without_body
sub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscriber could not create channels.")
expect(sub_1).to be_http_status(403).without_body
expect(sub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Subscriber could not create channels.")
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
pub.callback do
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_2.stream do |chunk2|
chunk2.should eql(conf.header_template)
expect(chunk2).to eql(conf.header_template)
EventMachine.stop
end
end
......@@ -84,9 +84,9 @@ describe "Comunication Properties" do
end
EM.add_timer(17) do
response_1.should eql("#{conf.header_template}#{body}")
response_2.should eql("#{conf.header_template}#{body}")
response_3.should eql("#{conf.header_template}")
expect(response_1).to eql("#{conf.header_template}#{body}")
expect(response_2).to eql("#{conf.header_template}#{body}")
expect(response_3).to eql("#{conf.header_template}")
EventMachine.stop
end
end
......@@ -109,9 +109,9 @@ describe "Comunication Properties" do
lines = response.split("|")
if lines.length >= 3
lines[0].should eql("#{conf.header_template}")
lines[1].should eql("{\"duplicated\":\"#{channel}\", \"channel\":\"#{channel}\", \"message\":\"#{body}\", \"message_id\":\"1\"}")
lines[2].should eql("{\"duplicated\":\"\", \"channel\":\"\", \"message\":\" \", \"message_id\":\"-1\"}")
expect(lines[0]).to eql("#{conf.header_template}")
expect(lines[1]).to eql("{\"duplicated\":\"#{channel}\", \"channel\":\"#{channel}\", \"message\":\"#{body}\", \"message_id\":\"1\"}")
expect(lines[2]).to eql("{\"duplicated\":\"\", \"channel\":\"\", \"message\":\" \", \"message_id\":\"-1\"}")
EventMachine.stop
end
end
......@@ -135,9 +135,9 @@ describe "Comunication Properties" do
lines = response.split("|")
if lines.length >= 3
lines[0].should eql("#{conf.header_template}")
lines[1].should eql("{\"channel\":\"ch_test_message_and_channel_with_same_pattern_of_the_template~channel~~channel~~channel~~text~~text~~text~\", \"message\":\"~channel~~channel~~channel~~text~~text~~text~\", \"message_id\":\"1\"}")
lines[2].should eql("{\"channel\":\"\", \"message\":\" \", \"message_id\":\"-1\"}")
expect(lines[0]).to eql("#{conf.header_template}")
expect(lines[1]).to eql("{\"channel\":\"ch_test_message_and_channel_with_same_pattern_of_the_template~channel~~channel~~channel~~text~~text~~text~\", \"message\":\"~channel~~channel~~channel~~text~~text~~text~\", \"message_id\":\"1\"}")
expect(lines[2]).to eql("{\"channel\":\"\", \"message\":\" \", \"message_id\":\"-1\"}")
EventMachine.stop
end
end
......
......@@ -22,13 +22,13 @@ describe "Subscriber Connection Cleanup" do
sub.stream do |chunk|
response += chunk
response.should include(conf.header_template)
expect(response).to include(conf.header_template)
end
sub.callback do
stop = Time.now
time_diff_sec(start, stop).should be_in_the_interval(17, 17.5)
response.should include(conf.footer_template)
expect(time_diff_sec(start, stop)).to be_in_the_interval(17, 17.5)
expect(response).to include(conf.footer_template)
EventMachine.stop
end
end
......@@ -51,8 +51,8 @@ describe "Subscriber Connection Cleanup" do
sub.callback do
stop = Time.now
time_diff_sec(start, stop).should be_in_the_interval(17, 17.5)
chunks_received.should be_eql(5)
expect(time_diff_sec(start, stop)).to be_in_the_interval(17, 17.5)
expect(chunks_received).to be_eql(5)
EventMachine.stop
end
end
......@@ -68,10 +68,10 @@ describe "Subscriber Connection Cleanup" do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.stream do |chunk|
response_1 += chunk
response_1.should include(conf.header_template)
expect(response_1).to include(conf.header_template)
end
sub_1.callback do
response_1.should include(conf.footer_template)
expect(response_1).to include(conf.footer_template)
end
sleep(2)
......@@ -80,19 +80,19 @@ describe "Subscriber Connection Cleanup" do
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_2.stream do |chunk|
response_2 += chunk
response_2.should include(conf.header_template)
expect(response_2).to include(conf.header_template)
end
sub_2.callback do
response_2.should include(conf.footer_template)
expect(response_2).to include(conf.footer_template)
response_4 = ''
sub_4 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_4.stream do |chunk|
response_4 += chunk
response_4.should include(conf.header_template)
expect(response_4).to include(conf.header_template)
end
sub_4.callback do
response_4.should include(conf.footer_template)
expect(response_4).to include(conf.footer_template)
EventMachine.stop
end
end
......@@ -103,10 +103,10 @@ describe "Subscriber Connection Cleanup" do
sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_3.stream do |chunk|
response_3 += chunk
response_3.should include(conf.header_template)
expect(response_3).to include(conf.header_template)
end
sub_3.callback do
response_3.should include(conf.footer_template)
expect(response_3).to include(conf.footer_template)
end
end
......
......@@ -23,7 +23,7 @@ describe "Subscriber Event Source" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get
sub.stream do |chunk|
sub.response_header["CONTENT_TYPE"].should eql("text/event-stream; charset=utf-8")
expect(sub.response_header["CONTENT_TYPE"]).to eql("text/event-stream; charset=utf-8")
source.start
end
end
......@@ -37,7 +37,7 @@ describe "Subscriber Event Source" do
EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get
sub.stream do |chunk|
chunk.should eql(": header line 1\n: header line 2\n: header line 3\n: header line 4\n")
expect(chunk).to eql(": header line 1\n: header line 2\n: header line 3\n: header line 4\n")
EventMachine.stop
end
end
......@@ -51,7 +51,7 @@ describe "Subscriber Event Source" do
EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get
sub.stream do |chunk|
chunk.should eql(": header line 1\\nheader line 2\n")
expect(chunk).to eql(": header line 1\\nheader line 2\n")
EventMachine.stop
end
end
......@@ -69,7 +69,7 @@ describe "Subscriber Event Source" do
response += chunk
end
sub.callback do
response.should eql(": \n: footer line 1\n: footer line 2\n: footer line 3\n: footer line 4\n")
expect(response).to eql(": \n: footer line 1\n: footer line 2\n: footer line 3\n: footer line 4\n")
EventMachine.stop
end
end
......@@ -87,7 +87,7 @@ describe "Subscriber Event Source" do
response += chunk
end
sub.callback do
response.should eql(": \n: footer line 1\\nfooter line 2\n")
expect(response).to eql(": \n: footer line 1\\nfooter line 2\n")
EventMachine.stop
end
end
......@@ -103,7 +103,7 @@ describe "Subscriber Event Source" do
EventMachine.run do
source = EventMachine::EventSource.new(nginx_address + '/sub/_' + channel.to_s)
source.message do |message|
message.should eql(body)
expect(message).to eql(body)
publish_message_inline(channel, headers, body)
end
source.start
......@@ -112,7 +112,7 @@ describe "Subscriber Event Source" do
sub.stream do |chunk|
response += chunk
if response.include?("data: ")
response.should eql(": \ndata: #{body}\n\n")
expect(response).to eql(": \ndata: #{body}\n\n")
EventMachine.stop
end
end
......@@ -131,7 +131,7 @@ describe "Subscriber Event Source" do
EventMachine.run do
source = EventMachine::EventSource.new(nginx_address + '/sub/_' + channel.to_s)
source.message do |message|
message.should eql(body)
expect(message).to eql(body)
publish_message_inline(channel, headers, body)
end
source.start
......@@ -140,7 +140,7 @@ describe "Subscriber Event Source" do
sub.stream do |chunk|
response += chunk
if response.include?("data: ")
response.should eql(": \ndata: #{body}\n\n")
expect(response).to eql(": \ndata: #{body}\n\n")
EventMachine.stop
end
end
......@@ -160,8 +160,8 @@ describe "Subscriber Event Source" do
EventMachine.run do
source = EventMachine::EventSource.new(nginx_address + '/sub/_' + channel.to_s)
source.message do |message|
message.should eql(body)
source.last_event_id.should eql(event_id)
expect(message).to eql(body)
expect(source.last_event_id).to eql(event_id)
publish_message_inline(channel, headers.merge('Event-Id' => event_id), body)
end
source.start
......@@ -170,7 +170,7 @@ describe "Subscriber Event Source" do
sub.stream do |chunk|
response += chunk
if response.include?("data: ")
response.should eql(": \nid: #{event_id}\ndata: #{body}\n\n")
expect(response).to eql(": \nid: #{event_id}\ndata: #{body}\n\n")
EventMachine.stop
end
end
......@@ -190,7 +190,7 @@ describe "Subscriber Event Source" do
EventMachine.run do
source = EventMachine::EventSource.new(nginx_address + '/sub/_' + channel.to_s)
source.on event_type do |message|
message.should eql(body)
expect(message).to eql(body)
publish_message_inline(channel, headers.merge('Event-type' => event_type), body)
end
source.start
......@@ -199,7 +199,7 @@ describe "Subscriber Event Source" do
sub.stream do |chunk|
response += chunk
if response.include?("data: ")
response.should eql(": \nevent: #{event_type}\ndata: #{body}\n\n")
expect(response).to eql(": \nevent: #{event_type}\ndata: #{body}\n\n")
EventMachine.stop
end
end
......@@ -218,7 +218,7 @@ describe "Subscriber Event Source" do
EventMachine.run do
source = EventMachine::EventSource.new(nginx_address + '/sub/_' + channel.to_s)
source.message do |message|
message.should eql(%({"id":"1", "message":"#{body}"}))
expect(message).to eql(%({"id":"1", "message":"#{body}"}))
publish_message_inline(channel, headers, body)
end
source.start
......@@ -227,7 +227,7 @@ describe "Subscriber Event Source" do
sub.stream do |chunk|
response += chunk
if response.include?("data: ")
response.should eql(%(: \ndata: {"id":"1", "message":"#{body}"}\n\n))
expect(response).to eql(%(: \ndata: {"id":"1", "message":"#{body}"}\n\n))
EventMachine.stop
end
end
......@@ -246,7 +246,7 @@ describe "Subscriber Event Source" do
EventMachine.run do
source = EventMachine::EventSource.new(nginx_address + '/sub/_' + channel.to_s)
source.message do |message|
message.should eql(%({"id":"1", "message":"#{body}"}))
expect(message).to eql(%({"id":"1", "message":"#{body}"}))
publish_message_inline(channel, headers, body)
end
source.start
......@@ -255,7 +255,7 @@ describe "Subscriber Event Source" do
sub.stream do |chunk|
response += chunk
if response.include?("data: ")
response.should eql(%(: \ndata: {"id":"1", "message":"#{body}"}\n\n))
expect(response).to eql(%(: \ndata: {"id":"1", "message":"#{body}"}\n\n))
EventMachine.stop
end
end
......@@ -275,8 +275,8 @@ describe "Subscriber Event Source" do
EventMachine.run do
source = EventMachine::EventSource.new(nginx_address + '/sub/_' + channel.to_s)
source.message do |message|
message.should eql(%({"id":"1", "message":"#{body}"}))
source.last_event_id.should eql(event_id)
expect(message).to eql(%({"id":"1", "message":"#{body}"}))
expect(source.last_event_id).to eql(event_id)
publish_message_inline(channel, headers.merge('Event-Id' => event_id), body)
end
source.start
......@@ -285,7 +285,7 @@ describe "Subscriber Event Source" do
sub.stream do |chunk|
response += chunk
if response.include?("data: ")
response.should eql(%(: \nid: #{event_id}\ndata: {"id":"1", "message":"#{body}"}\n\n))
expect(response).to eql(%(: \nid: #{event_id}\ndata: {"id":"1", "message":"#{body}"}\n\n))
EventMachine.stop
end
end
......@@ -305,7 +305,7 @@ describe "Subscriber Event Source" do
EventMachine.run do
source = EventMachine::EventSource.new(nginx_address + '/sub/_' + channel.to_s)
source.on event_type do |message|
message.should eql(%({"id":"1", "message":"#{body}"}))
expect(message).to eql(%({"id":"1", "message":"#{body}"}))
publish_message_inline(channel, headers.merge('Event-type' => event_type), body)
end
source.start
......@@ -314,7 +314,7 @@ describe "Subscriber Event Source" do
sub.stream do |chunk|
response += chunk
if response.include?("data: ")
response.should eql(%(: \nevent: #{event_type}\ndata: {"id":"1", "message":"#{body}"}\n\n))
expect(response).to eql(%(: \nevent: #{event_type}\ndata: {"id":"1", "message":"#{body}"}\n\n))
EventMachine.stop
end
end
......@@ -332,7 +332,7 @@ describe "Subscriber Event Source" do
EventMachine.run do
source = EventMachine::EventSource.new(nginx_address + '/sub/_' + channel.to_s)
source.message do |message|
message.should eql("line 1\nline 2\nline 3\nline 4")
expect(message).to eql("line 1\nline 2\nline 3\nline 4")
publish_message_inline(channel, headers, body)
end
source.start
......@@ -340,7 +340,7 @@ describe "Subscriber Event Source" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get
sub.stream do |chunk|
if chunk.include?("line 4")
chunk.should eql("data: line 1\ndata: line 2\ndata: line 3\ndata: line 4\n\n")
expect(chunk).to eql("data: line 1\ndata: line 2\ndata: line 3\ndata: line 4\n\n")
EventMachine.stop
end
end
......@@ -358,7 +358,7 @@ describe "Subscriber Event Source" do
EventMachine.run do
source = EventMachine::EventSource.new(nginx_address + '/sub/_' + channel.to_s)
source.message do |message|
message.should eql(body)
expect(message).to eql(body)
publish_message_inline(channel, headers, body)
end
source.start
......@@ -366,7 +366,7 @@ describe "Subscriber Event Source" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get
sub.stream do |chunk|
if chunk.include?("line 2")
chunk.should eql("data: line 1\\nline 2\n\n")
expect(chunk).to eql("data: line 1\\nline 2\n\n")
EventMachine.stop
end
end
......@@ -384,7 +384,7 @@ describe "Subscriber Event Source" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get
sub.stream do |chunk|
if chunk.include?("-1")
chunk.should eql(": -1\n")
expect(chunk).to eql(": -1\n")
EventMachine.stop
end
end
......@@ -412,14 +412,14 @@ describe "Subscriber Event Source" do
sub.stream do |chunk|
response += chunk
if response.include?("footer")
response.should eql(": header\ndata: msg #{body}\n\n: footer\n")
expect(response).to eql(": header\ndata: msg #{body}\n\n: footer\n")
response = ''
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/ev/' + channel.to_s + '?tests=on').get
sub_1.stream do |chunk_1|
response += chunk_1
if response.include?("footer")
response.should eql(": header\ndata: msg #{body}\n\n: footer\n")
expect(response).to eql(": header\ndata: msg #{body}\n\n: footer\n")
EventMachine.stop
end
end
......
......@@ -16,7 +16,7 @@ describe "Subscriber Properties" do
response += chunk
end
sub_1.callback do |chunk|
response.should eql("#{body}")
expect(response).to eql("#{body}")
sent_headers = headers.merge({'If-Modified-Since' => sub_1.response_header['LAST_MODIFIED'], 'If-None-Match' => sub_1.response_header['ETAG']})
response = ""
......@@ -25,7 +25,7 @@ describe "Subscriber Properties" do
response += chunk2
end
sub_2.callback do
response.should eql("#{body} 1")
expect(response).to eql("#{body} 1")
EventMachine.stop
end
......@@ -53,7 +53,7 @@ describe "Subscriber Properties" do
response += chunk
end
sub.callback do |chunk|
response.should eql("msg 3msg 4")
expect(response).to eql("msg 3msg 4")
EventMachine.stop
end
end
......@@ -69,10 +69,10 @@ describe "Subscriber Properties" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s, :inactivity_timeout => 15).get :head => headers
sub.callback do
stop = Time.now
time_diff_sec(start, stop).should be_in_the_interval(10, 10.5)
sub.should be_http_status(304).without_body
Time.parse(sub.response_header['LAST_MODIFIED'].to_s).utc.to_i.should be_in_the_interval(Time.now.utc.to_i-1, Time.now.utc.to_i)
sub.response_header['ETAG'].to_s.should eql("0")
expect(time_diff_sec(start, stop)).to be_in_the_interval(10, 10.5)
expect(sub).to be_http_status(304).without_body
expect(Time.parse(sub.response_header['LAST_MODIFIED'].to_s).utc.to_i).to be_in_the_interval(Time.now.utc.to_i-1, Time.now.utc.to_i)
expect(sub.response_header['ETAG'].to_s).to eql("0")
EventMachine.stop
end
end
......@@ -88,10 +88,10 @@ describe "Subscriber Properties" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub.callback do
stop = Time.now
time_diff_sec(start, stop).should be_in_the_interval(5, 5.5)
sub.should be_http_status(304).without_body
Time.parse(sub.response_header['LAST_MODIFIED'].to_s).utc.to_i.should be_in_the_interval(Time.now.utc.to_i-1, Time.now.utc.to_i)
sub.response_header['ETAG'].to_s.should eql("0")
expect(time_diff_sec(start, stop)).to be_in_the_interval(5, 5.5)
expect(sub).to be_http_status(304).without_body
expect(Time.parse(sub.response_header['LAST_MODIFIED'].to_s).utc.to_i).to be_in_the_interval(Time.now.utc.to_i-1, Time.now.utc.to_i)
expect(sub.response_header['ETAG'].to_s).to eql("0")
EventMachine.stop
end
end
......@@ -107,10 +107,10 @@ describe "Subscriber Properties" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub.callback do
stop = Time.now
time_diff_sec(start, stop).should be_in_the_interval(3, 3.5)
sub.should be_http_status(304).without_body
Time.parse(sub.response_header['LAST_MODIFIED'].to_s).utc.to_i.should be_in_the_interval(Time.now.utc.to_i-1, Time.now.utc.to_i)
sub.response_header['ETAG'].to_s.should eql("0")
expect(time_diff_sec(start, stop)).to be_in_the_interval(3, 3.5)
expect(sub).to be_http_status(304).without_body
expect(Time.parse(sub.response_header['LAST_MODIFIED'].to_s).utc.to_i).to be_in_the_interval(Time.now.utc.to_i-1, Time.now.utc.to_i)
expect(sub.response_header['ETAG'].to_s).to eql("0")
EventMachine.stop
end
end
......@@ -126,8 +126,8 @@ describe "Subscriber Properties" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub.callback do
stop = Time.now
time_diff_sec(start, stop).should be_in_the_interval(5, 5.5)
sub.should be_http_status(304).without_body
expect(time_diff_sec(start, stop)).to be_in_the_interval(5, 5.5)
expect(sub).to be_http_status(304).without_body
EventMachine.stop
end
end
......@@ -144,20 +144,20 @@ describe "Subscriber Properties" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub.callback do
stop = Time.now
time_diff_sec(start, stop).should be_in_the_interval(1, 1.5)
sub.should be_http_status(200)
expect(time_diff_sec(start, stop)).to be_in_the_interval(1, 1.5)
expect(sub).to be_http_status(200)
response = JSON.parse(sub.response)
response["id"].should eql("-3")
response["message"].should eql("Timed out")
response["channel"].should eql("")
response["tag"].should eql("0")
response["time"].should eql("Thu, 01 Jan 1970 00:00:00 GMT")
Time.parse(sub.response_header['LAST_MODIFIED'].to_s).utc.to_i.should be_in_the_interval(Time.now.utc.to_i-1, Time.now.utc.to_i)
sub.response_header['ETAG'].to_s.should eql("0")
expect(response["id"]).to eql("-3")
expect(response["message"]).to eql("Timed out")
expect(response["channel"]).to eql("")
expect(response["tag"]).to eql("0")
expect(response["time"]).to eql("Thu, 01 Jan 1970 00:00:00 GMT")
expect(Time.parse(sub.response_header['LAST_MODIFIED'].to_s).utc.to_i).to be_in_the_interval(Time.now.utc.to_i-1, Time.now.utc.to_i)
expect(sub.response_header['ETAG'].to_s).to eql("0")
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?callback=' + callback_function_name).get :head => headers
sub_1.callback do
sub_1.response.should eql(%(callback_function([{"id":"-3", "message":"Timed out", "channel":"", "tag":"0", "time":"Thu, 01 Jan 1970 00:00:00 GMT"}]);))
expect(sub_1.response).to eql(%(callback_function([{"id":"-3", "message":"Timed out", "channel":"", "tag":"0", "time":"Thu, 01 Jan 1970 00:00:00 GMT"}]);))
EventMachine.stop
end
end
......@@ -174,16 +174,16 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s).get :head => headers.merge({'If-Modified-Since' => 'Thu, 1 Jan 1970 00:00:00 GMT', 'If-None-Match' => 0})
sub_1.callback do
sub_1.should be_http_status(200)
expect(sub_1).to be_http_status(200)
response = JSON.parse(sub_1.response)
response["channel"].should eql(channel_1)
expect(response["channel"]).to eql(channel_1)
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s).get :head => headers.merge({'If-Modified-Since' => sub_1.response_header['LAST_MODIFIED'], 'If-None-Match' => sub_1.response_header['ETAG']})
sub_2.callback do
sub_2.should be_http_status(200)
expect(sub_2).to be_http_status(200)
response = JSON.parse(sub_2.response)
response["channel"].should eql(channel_2)
sub_2.response_header['ETAG'].to_i.should eql(sub_1.response_header['ETAG'].to_i + 1)
expect(response["channel"]).to eql(channel_2)
expect(sub_2.response_header['ETAG'].to_i).to eql(sub_1.response_header['ETAG'].to_i + 1)
EventMachine.stop
end
......@@ -206,23 +206,23 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.callback do
sub_1.should be_http_status(200)
expect(sub_1).to be_http_status(200)
response = JSON.parse(sub_1.response)
response["channel"].should eql(channel)
response["id"].to_i.should eql(-2)
expect(response["channel"]).to eql(channel)
expect(response["id"].to_i).to eql(-2)
end
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?callback=' + callback_function_name).get :head => headers
sub_2.callback do
sub_2.response.should eql(%(#{callback_function_name}([{"id":"-2", "message":"Channel deleted", "channel":"ch_test_delete_channel_with_long_polling_subscriber"}]);))
expect(sub_2.response).to eql(%(#{callback_function_name}([{"id":"-2", "message":"Channel deleted", "channel":"ch_test_delete_channel_with_long_polling_subscriber"}]);))
EventMachine.stop
end
EM.add_timer(0.5) do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s).delete :head => headers
pub.callback do
pub.should be_http_status(200).without_body
pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel deleted.")
expect(pub).to be_http_status(200).without_body
expect(pub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel deleted.")
end
end
end
......@@ -239,7 +239,7 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?callback=' + callback_function_name).get :head => headers
sub_1.callback do
sub_1.response.should eql("#{callback_function_name}([#{body}]);")
expect(sub_1.response).to eql("#{callback_function_name}([#{body}]);")
EventMachine.stop
end
......@@ -261,15 +261,15 @@ describe "Subscriber Properties" do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b2' + '?callback=' + callback_function_name).get :head => headers
sub_1.callback do
sub_1.response.should eql("#{callback_function_name}([#{body},#{body + "1"}]);")
expect(sub_1.response).to eql("#{callback_function_name}([#{body},#{body + "1"}]);")
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?callback=' + callback_function_name).get :head => headers.merge({'Last-Event-Id' => 'event_id'})
sub_2.callback do
sub_2.response.should eql("#{callback_function_name}([#{body + "1"}]);")
expect(sub_2.response).to eql("#{callback_function_name}([#{body + "1"}]);")
sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?callback=' + callback_function_name).get :head => headers.merge({'If-Modified-Since' => Time.at(0).utc.strftime("%a, %d %b %Y %T %Z")})
sub_3.callback do
sub_3.response.should eql("#{callback_function_name}([#{body},#{body + "1"}]);")
expect(sub_3.response).to eql("#{callback_function_name}([#{body},#{body + "1"}]);")
EventMachine.stop
end
......@@ -290,7 +290,7 @@ describe "Subscriber Properties" do
sent_headers = headers.merge({'accept' => 'otherknown/value'})
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?callback=' + callback_function_name).get :head => sent_headers
sub_1.callback do
sub_1.response_header['CONTENT_TYPE'].should eql('application/javascript')
expect(sub_1.response_header['CONTENT_TYPE']).to eql('application/javascript')
EventMachine.stop
end
publish_message_inline(channel, {}, body)
......@@ -305,8 +305,8 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.callback do
sub_1.response_header["EXPIRES"].should eql("Thu, 01 Jan 1970 00:00:01 GMT")
sub_1.response_header["CACHE_CONTROL"].should eql("no-cache, no-store, must-revalidate")
expect(sub_1.response_header["EXPIRES"]).to eql("Thu, 01 Jan 1970 00:00:01 GMT")
expect(sub_1.response_header["CACHE_CONTROL"]).to eql("no-cache, no-store, must-revalidate")
EventMachine.stop
end
end
......@@ -326,12 +326,12 @@ describe "Subscriber Properties" do
actual_response << chunk
end
sub_1.callback do
sub_1.should be_http_status(200)
expect(sub_1).to be_http_status(200)
sub_1.response_header["CONTENT_ENCODING"].should eql("gzip")
expect(sub_1.response_header["CONTENT_ENCODING"]).to eql("gzip")
actual_response = Zlib::GzipReader.new(StringIO.new(actual_response)).read
actual_response.should eql("#{body}")
expect(actual_response).to eql("#{body}")
EventMachine.stop
end
publish_message_inline(channel, {}, body)
......
......@@ -22,19 +22,19 @@ describe "Subscriber Padding by user agent" do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do
sub_1.should be_http_status(200)
sub_1.response.size.should eql(1100 + expected_size)
sub_1.response.should match padding_pattern
expect(sub_1).to be_http_status(200)
expect(sub_1.response.size).to eql(1100 + expected_size)
expect(sub_1.response).to match padding_pattern
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 2")
sub_2.callback do
sub_2.should be_http_status(200)
sub_2.response.size.should eql(4097 + expected_size)
expect(sub_2).to be_http_status(200)
expect(sub_2.response.size).to eql(4097 + expected_size)
sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 3")
sub_3.callback do
sub_3.should be_http_status(200)
sub_3.response.size.should eql(expected_size)
expect(sub_3).to be_http_status(200)
expect(sub_3.response.size).to eql(expected_size)
EventMachine.stop
end
......@@ -55,19 +55,19 @@ describe "Subscriber Padding by user agent" do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback {
sub_1.should be_http_status(200)
sub_1.response.size.should eql(500 + expected_size)
sub_1.response.should match padding_pattern
expect(sub_1).to be_http_status(200)
expect(sub_1.response.size).to eql(500 + expected_size)
expect(sub_1.response).to match padding_pattern
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 2")
sub_2.callback {
sub_2.should be_http_status(200)
sub_2.response.size.should eql(expected_size)
expect(sub_2).to be_http_status(200)
expect(sub_2.response.size).to eql(expected_size)
sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 3")
sub_3.callback {
sub_3.should be_http_status(200)
sub_3.response.size.should eql(expected_size)
expect(sub_3).to be_http_status(200)
expect(sub_3.response.size).to eql(expected_size)
EventMachine.stop
}
......@@ -91,56 +91,56 @@ describe "Subscriber Padding by user agent" do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do
sub_1.should be_http_status(200)
sub_1.response.size.should eql(expected_padding + i + expected_size)
sub_1.response.should match padding_pattern
expect(sub_1).to be_http_status(200)
expect(sub_1.response.size).to eql(expected_padding + i + expected_size)
expect(sub_1.response).to match padding_pattern
i = 105
expected_padding = 600 - ((i/100).to_i * 100)
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do
sub_1.should be_http_status(200)
sub_1.response.size.should eql(expected_padding + i + expected_size)
expect(sub_1).to be_http_status(200)
expect(sub_1.response.size).to eql(expected_padding + i + expected_size)
i = 221
expected_padding = 600 - ((i/100).to_i * 100)
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do
sub_1.should be_http_status(200)
sub_1.response.size.should eql(expected_padding + i + expected_size)
expect(sub_1).to be_http_status(200)
expect(sub_1.response.size).to eql(expected_padding + i + expected_size)
i = 331
expected_padding = 600 - ((i/100).to_i * 100)
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do
sub_1.should be_http_status(200)
sub_1.response.size.should eql(expected_padding + i + expected_size)
expect(sub_1).to be_http_status(200)
expect(sub_1.response.size).to eql(expected_padding + i + expected_size)
i = 435
expected_padding = 600 - ((i/100).to_i * 100)
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do
sub_1.should be_http_status(200)
sub_1.response.size.should eql(expected_padding + i + expected_size)
expect(sub_1).to be_http_status(200)
expect(sub_1.response.size).to eql(expected_padding + i + expected_size)
i = 502
expected_padding = 600 - ((i/100).to_i * 100)
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do
sub_1.should be_http_status(200)
sub_1.response.size.should eql(expected_padding + i + expected_size)
expect(sub_1).to be_http_status(200)
expect(sub_1.response.size).to eql(expected_padding + i + expected_size)
i = 550
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge("User-Agent" => "Test 1")
sub_1.callback do
sub_1.should be_http_status(200)
sub_1.response.size.should eql(i + expected_size)
expect(sub_1).to be_http_status(200)
expect(sub_1.response.size).to eql(i + expected_size)
EventMachine.stop
end
......@@ -170,14 +170,14 @@ describe "Subscriber Padding by user agent" do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?ua=test 1').get :head => headers
sub_1.callback do
sub_1.should be_http_status(200)
sub_1.response.size.should eql(1024 + expected_size)
sub_1.response.should match padding_pattern
expect(sub_1).to be_http_status(200)
expect(sub_1.response.size).to eql(1024 + expected_size)
expect(sub_1.response).to match padding_pattern
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?ua=test 2').get :head => headers
sub_2.callback do
sub_2.should be_http_status(200)
sub_2.response.size.should eql(expected_size)
expect(sub_2).to be_http_status(200)
expect(sub_2.response.size).to eql(expected_size)
EventMachine.stop
end
......
......@@ -13,9 +13,9 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.callback do
sub_1.should be_http_status(304).without_body
sub_1.response_header['LAST_MODIFIED'].to_s.should eql("")
sub_1.response_header['ETAG'].to_s.should eql("")
expect(sub_1).to be_http_status(304).without_body
expect(sub_1.response_header['LAST_MODIFIED'].to_s).to eql("")
expect(sub_1.response_header['ETAG'].to_s).to eql("")
EventMachine.stop
end
end
......@@ -30,9 +30,9 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => sent_headers
sub_1.callback do
sub_1.should be_http_status(304).without_body
Time.parse(sub_1.response_header['LAST_MODIFIED'].to_s).should eql(Time.parse(sent_headers['If-Modified-Since']))
sub_1.response_header['ETAG'].to_s.should eql(sent_headers['If-None-Match'])
expect(sub_1).to be_http_status(304).without_body
expect(Time.parse(sub_1.response_header['LAST_MODIFIED'].to_s)).to eql(Time.parse(sent_headers['If-Modified-Since']))
expect(sub_1.response_header['ETAG'].to_s).to eql(sent_headers['If-None-Match'])
EventMachine.stop
end
end
......@@ -53,10 +53,10 @@ describe "Subscriber Properties" do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers.merge({'If-Modified-Since' => Time.at(0).utc.strftime("%a, %d %b %Y %T %Z")})
sub_1.callback do
sub_1.should be_http_status(200)
sub_1.response_header['LAST_MODIFIED'].to_s.should_not eql("")
sub_1.response_header['ETAG'].to_s.should eql("1")
sub_1.response.should eql("#{body}")
expect(sub_1).to be_http_status(200)
expect(sub_1.response_header['LAST_MODIFIED'].to_s).not_to eql("")
expect(sub_1.response_header['ETAG'].to_s).to eql("1")
expect(sub_1.response).to eql("#{body}")
EventMachine.stop
end
end
......@@ -74,7 +74,7 @@ describe "Subscriber Properties" do
publish_message(channel, {}, body)
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?callback=' + callback_function_name).get :head => headers.merge({'If-Modified-Since' => Time.at(0).utc.strftime("%a, %d %b %Y %T %Z")})
sub_1.callback do
sub_1.response.should eql("#{callback_function_name}([#{body}]);")
expect(sub_1.response).to eql("#{callback_function_name}([#{body}]);")
EventMachine.stop
end
end
......@@ -94,15 +94,15 @@ describe "Subscriber Properties" do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b2' + '?callback=' + callback_function_name).get :head => headers
sub_1.callback do
sub_1.response.should eql("#{callback_function_name}([#{body},#{body + "1"}]);")
expect(sub_1.response).to eql("#{callback_function_name}([#{body},#{body + "1"}]);")
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?callback=' + callback_function_name).get :head => headers.merge({'Last-Event-Id' => 'event_id'})
sub_2.callback do
sub_2.response.should eql("#{callback_function_name}([#{body + "1"}]);")
expect(sub_2.response).to eql("#{callback_function_name}([#{body + "1"}]);")
sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?callback=' + callback_function_name).get :head => headers.merge({'If-Modified-Since' => Time.at(0).utc.strftime("%a, %d %b %Y %T %Z")})
sub_3.callback do
sub_3.response.should eql("#{callback_function_name}([#{body},#{body + "1"}]);")
expect(sub_3.response).to eql("#{callback_function_name}([#{body},#{body + "1"}]);")
EventMachine.stop
end
......@@ -124,7 +124,7 @@ describe "Subscriber Properties" do
sent_headers = headers.merge({'accept' => 'otherknown/value'})
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?callback=' + callback_function_name).get :head => sent_headers
sub_1.callback do
sub_1.response_header['CONTENT_TYPE'].should eql('application/javascript')
expect(sub_1.response_header['CONTENT_TYPE']).to eql('application/javascript')
EventMachine.stop
end
end
......@@ -146,12 +146,12 @@ describe "Subscriber Properties" do
actual_response << chunk
end
sub_1.callback do
sub_1.should be_http_status(200)
expect(sub_1).to be_http_status(200)
sub_1.response_header["CONTENT_ENCODING"].should eql("gzip")
expect(sub_1.response_header["CONTENT_ENCODING"]).to eql("gzip")
actual_response = Zlib::GzipReader.new(StringIO.new(actual_response)).read
actual_response.should eql("#{body}")
expect(actual_response).to eql("#{body}")
EventMachine.stop
end
end
......@@ -166,8 +166,8 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.callback do
sub_1.response_header["EXPIRES"].should eql("Thu, 01 Jan 1970 00:00:01 GMT")
sub_1.response_header["CACHE_CONTROL"].should eql("no-cache, no-store, must-revalidate")
expect(sub_1.response_header["EXPIRES"]).to eql("Thu, 01 Jan 1970 00:00:01 GMT")
expect(sub_1.response_header["CACHE_CONTROL"]).to eql("no-cache, no-store, must-revalidate")
EventMachine.stop
end
end
......
......@@ -16,8 +16,8 @@ describe "Subscriber Properties" do
EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/').get :head => headers
sub.callback do
sub.should be_http_status(400).without_body
sub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("No channel id provided.")
expect(sub).to be_http_status(400).without_body
expect(sub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("No channel id provided.")
EventMachine.stop
end
end
......@@ -30,8 +30,8 @@ describe "Subscriber Properties" do
socket = open_socket(nginx_host, nginx_port)
socket.print("OPTIONS /sub/ch_test_accepted_methods_0 HTTP/1.0\r\n\r\n")
headers, body = read_response_on_socket(socket)
headers.should match_the_pattern(/HTTP\/1\.1 200 OK/)
headers.should match_the_pattern(/Content-Length: 0/)
expect(headers).to match_the_pattern(/HTTP\/1\.1 200 OK/)
expect(headers).to match_the_pattern(/Content-Length: 0/)
socket.close
EventMachine.run do
......@@ -44,26 +44,26 @@ describe "Subscriber Properties" do
multi.add(:e, EventMachine::HttpRequest.new(nginx_address + '/sub/ch_test_accepted_methods_5').get)
multi.callback do
multi.responses[:callback].length.should eql(5)
expect(multi.responses[:callback].length).to eql(5)
multi.responses[:callback][:a].should be_http_status(405)
multi.responses[:callback][:a].req.method.should eql("HEAD")
multi.responses[:callback][:a].response_header['ALLOW'].should eql("GET")
expect(multi.responses[:callback][:a]).to be_http_status(405)
expect(multi.responses[:callback][:a].req.method).to eql("HEAD")
expect(multi.responses[:callback][:a].response_header['ALLOW']).to eql("GET")
multi.responses[:callback][:b].should be_http_status(405)
multi.responses[:callback][:b].req.method.should eql("PUT")
multi.responses[:callback][:b].response_header['ALLOW'].should eql("GET")
expect(multi.responses[:callback][:b]).to be_http_status(405)
expect(multi.responses[:callback][:b].req.method).to eql("PUT")
expect(multi.responses[:callback][:b].response_header['ALLOW']).to eql("GET")
multi.responses[:callback][:c].should be_http_status(405)
multi.responses[:callback][:c].req.method.should eql("POST")
multi.responses[:callback][:c].response_header['ALLOW'].should eql("GET")
expect(multi.responses[:callback][:c]).to be_http_status(405)
expect(multi.responses[:callback][:c].req.method).to eql("POST")
expect(multi.responses[:callback][:c].response_header['ALLOW']).to eql("GET")
multi.responses[:callback][:d].should be_http_status(405)
multi.responses[:callback][:d].req.method.should eql("DELETE")
multi.responses[:callback][:d].response_header['ALLOW'].should eql("GET")
expect(multi.responses[:callback][:d]).to be_http_status(405)
expect(multi.responses[:callback][:d].req.method).to eql("DELETE")
expect(multi.responses[:callback][:d].response_header['ALLOW']).to eql("GET")
multi.responses[:callback][:e].should_not be_http_status(405)
multi.responses[:callback][:e].req.method.should eql("GET")
expect(multi.responses[:callback][:e]).not_to be_http_status(405)
expect(multi.responses[:callback][:e].req.method).to eql("GET")
EventMachine.stop
end
......@@ -78,8 +78,8 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.callback do
sub_1.should be_http_status(403).without_body
sub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel id not authorized for this method.")
expect(sub_1).to be_http_status(403).without_body
expect(sub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel id not authorized for this method.")
EventMachine.stop
end
end
......@@ -99,10 +99,10 @@ describe "Subscriber Properties" do
multi.add(:b, EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_2).get(:head => headers))
multi.add(:c, EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel_3).get(:head => headers))
multi.callback do
multi.responses[:callback].length.should eql(3)
expect(multi.responses[:callback].length).to eql(3)
multi.responses[:callback].each do |name, response|
response.should be_http_status(403).without_body
response.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel id not authorized for this method.")
expect(response).to be_http_status(403).without_body
expect(response.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel id not authorized for this method.")
end
EventMachine.stop
......@@ -125,9 +125,9 @@ describe "Subscriber Properties" do
multi.add(:g, EventMachine::HttpRequest.new(nginx_address + '/sub/ch_multi_channels_4.b').get)
multi.callback do
multi.responses[:callback].length.should eql(7)
expect(multi.responses[:callback].length).to eql(7)
multi.responses[:callback].each do |name, response|
response.should be_http_status(200)
expect(response).to be_http_status(200)
end
EventMachine.stop
......@@ -143,8 +143,8 @@ describe "Subscriber Properties" do
EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s ).get :head => headers
sub.callback do
sub.should be_http_status(400).without_body
sub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Channel id is too large.")
expect(sub).to be_http_status(400).without_body
expect(sub.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Channel id is too large.")
EventMachine.stop
end
end
......@@ -162,21 +162,21 @@ describe "Subscriber Properties" do
multi.add(:d, EventMachine::HttpRequest.new(nginx_address + '/sub/bd').get)
multi.callback do
multi.responses[:callback].length.should eql(4)
expect(multi.responses[:callback].length).to eql(4)
multi.responses[:callback][:a].should be_http_status(403).without_body
multi.responses[:callback][:a].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscribed too much wildcard channels.")
multi.responses[:callback][:a].req.uri.to_s.should eql(nginx_address + '/sub/bd_test_wildcard_channels_without_common_channel')
expect(multi.responses[:callback][:a]).to be_http_status(403).without_body
expect(multi.responses[:callback][:a].response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Subscribed too much wildcard channels.")
expect(multi.responses[:callback][:a].req.uri.to_s).to eql(nginx_address + '/sub/bd_test_wildcard_channels_without_common_channel')
multi.responses[:callback][:b].should be_http_status(403).without_body
multi.responses[:callback][:b].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscribed too much wildcard channels.")
multi.responses[:callback][:b].req.uri.to_s.should eql(nginx_address + '/sub/bd_')
expect(multi.responses[:callback][:b]).to be_http_status(403).without_body
expect(multi.responses[:callback][:b].response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Subscribed too much wildcard channels.")
expect(multi.responses[:callback][:b].req.uri.to_s).to eql(nginx_address + '/sub/bd_')
multi.responses[:callback][:c].should be_http_status(200)
multi.responses[:callback][:c].req.uri.to_s.should eql(nginx_address + '/sub/bd1')
expect(multi.responses[:callback][:c]).to be_http_status(200)
expect(multi.responses[:callback][:c].req.uri.to_s).to eql(nginx_address + '/sub/bd1')
multi.responses[:callback][:d].should be_http_status(200)
multi.responses[:callback][:d].req.uri.to_s.should eql(nginx_address + '/sub/bd')
expect(multi.responses[:callback][:d]).to be_http_status(200)
expect(multi.responses[:callback][:d].req.uri.to_s).to eql(nginx_address + '/sub/bd')
EventMachine.stop
end
......@@ -195,20 +195,20 @@ describe "Subscriber Properties" do
multi.add(:d, EventMachine::HttpRequest.new(nginx_address + '/sub/bd1/bd2').get)
multi.callback do
multi.responses[:callback].length.should eql(4)
expect(multi.responses[:callback].length).to eql(4)
multi.responses[:callback][:a].should be_http_status(403).without_body
multi.responses[:callback][:a].response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscribed too much wildcard channels.")
multi.responses[:callback][:a].req.uri.to_s.should eql(nginx_address + '/sub/bd1/bd2/bd3/bd4/bd_1/bd_2/bd_3')
expect(multi.responses[:callback][:a]).to be_http_status(403).without_body
expect(multi.responses[:callback][:a].response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Subscribed too much wildcard channels.")
expect(multi.responses[:callback][:a].req.uri.to_s).to eql(nginx_address + '/sub/bd1/bd2/bd3/bd4/bd_1/bd_2/bd_3')
multi.responses[:callback][:b].should be_http_status(200)
multi.responses[:callback][:b].req.uri.to_s.should eql(nginx_address + '/sub/bd1/bd2/bd_1/bd_2')
expect(multi.responses[:callback][:b]).to be_http_status(200)
expect(multi.responses[:callback][:b].req.uri.to_s).to eql(nginx_address + '/sub/bd1/bd2/bd_1/bd_2')
multi.responses[:callback][:c].should be_http_status(200)
multi.responses[:callback][:c].req.uri.to_s.should eql(nginx_address + '/sub/bd1/bd_1')
expect(multi.responses[:callback][:c]).to be_http_status(200)
expect(multi.responses[:callback][:c].req.uri.to_s).to eql(nginx_address + '/sub/bd1/bd_1')
multi.responses[:callback][:d].should be_http_status(200)
multi.responses[:callback][:d].req.uri.to_s.should eql(nginx_address + '/sub/bd1/bd2')
expect(multi.responses[:callback][:d]).to be_http_status(200)
expect(multi.responses[:callback][:d].req.uri.to_s).to eql(nginx_address + '/sub/bd1/bd2')
EventMachine.stop
end
......@@ -223,8 +223,8 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.callback do
sub_1.should be_http_status(403).without_body
sub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscriber could not create channels.")
expect(sub_1).to be_http_status(403).without_body
expect(sub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Subscriber could not create channels.")
EventMachine.stop
end
end
......@@ -242,7 +242,7 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.callback do
sub_1.should be_http_status(200)
expect(sub_1).to be_http_status(200)
EventMachine.stop
end
end
......@@ -262,7 +262,7 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + wildcard_channel.to_s).get :head => headers
sub_1.callback do
sub_1.should be_http_status(200)
expect(sub_1).to be_http_status(200)
EventMachine.stop
end
end
......@@ -282,8 +282,8 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.callback do
sub_1.should be_http_status(403).without_body
sub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscriber could not create channels.")
expect(sub_1).to be_http_status(403).without_body
expect(sub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Subscriber could not create channels.")
EventMachine.stop
end
end
......@@ -304,8 +304,8 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '/' + wildcard_channel.to_s).get :head => headers
sub_1.callback do
sub_1.should be_http_status(403).without_body
sub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscriber could not create channels.")
expect(sub_1).to be_http_status(403).without_body
expect(sub_1.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Subscriber could not create channels.")
EventMachine.stop
end
end
......@@ -332,34 +332,34 @@ describe "Subscriber Properties" do
if lines.length >= 6
line = JSON.parse(lines[0])
line['channel'].should eql(channel_1.to_s)
line['message'].should eql('body' + channel_1.to_s)
line['id'].to_i.should eql(1)
expect(line['channel']).to eql(channel_1.to_s)
expect(line['message']).to eql('body' + channel_1.to_s)
expect(line['id'].to_i).to eql(1)
line = JSON.parse(lines[1])
line['channel'].should eql(channel_2.to_s)
line['message'].should eql('body' + channel_2.to_s)
line['id'].to_i.should eql(1)
expect(line['channel']).to eql(channel_2.to_s)
expect(line['message']).to eql('body' + channel_2.to_s)
expect(line['id'].to_i).to eql(1)
line = JSON.parse(lines[2])
line['channel'].should eql(channel_3.to_s)
line['message'].should eql('body' + channel_3.to_s)
line['id'].to_i.should eql(1)
expect(line['channel']).to eql(channel_3.to_s)
expect(line['message']).to eql('body' + channel_3.to_s)
expect(line['id'].to_i).to eql(1)
line = JSON.parse(lines[3])
line['channel'].should eql(channel_4.to_s)
line['message'].should eql('body' + channel_4.to_s)
line['id'].to_i.should eql(1)
expect(line['channel']).to eql(channel_4.to_s)
expect(line['message']).to eql('body' + channel_4.to_s)
expect(line['id'].to_i).to eql(1)
line = JSON.parse(lines[4])
line['channel'].should eql(channel_5.to_s)
line['message'].should eql('body' + channel_5.to_s)
line['id'].to_i.should eql(1)
expect(line['channel']).to eql(channel_5.to_s)
expect(line['message']).to eql('body' + channel_5.to_s)
expect(line['id'].to_i).to eql(1)
line = JSON.parse(lines[5])
line['channel'].should eql(channel_6.to_s)
line['message'].should eql('body' + channel_6.to_s)
line['id'].to_i.should eql(1)
expect(line['channel']).to eql(channel_6.to_s)
expect(line['message']).to eql('body' + channel_6.to_s)
expect(line['id'].to_i).to eql(1)
EventMachine.stop
end
......@@ -384,12 +384,12 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + 1.to_s).get :head => headers
sub_1.stream do
sub_1.should be_http_status(200)
expect(sub_1).to be_http_status(200)
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + 2.to_s).get :head => headers
sub_2.callback do
sub_2.should be_http_status(403).without_body
sub_2.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Number of channels were exceeded.")
expect(sub_2).to be_http_status(403).without_body
expect(sub_2.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Number of channels were exceeded.")
EventMachine.stop
end
end
......@@ -404,12 +404,12 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/ch1/' + channel.to_s + 1.to_s).get :head => headers
sub_1.stream do
sub_1.should be_http_status(200)
expect(sub_1).to be_http_status(200)
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub/ch1/' + channel.to_s + 2.to_s).get :head => headers
sub_2.callback do
sub_2.should be_http_status(403).without_body
sub_2.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Number of channels were exceeded.")
expect(sub_2).to be_http_status(403).without_body
expect(sub_2.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Number of channels were exceeded.")
EventMachine.stop
end
end
......@@ -443,16 +443,16 @@ describe "Subscriber Properties" do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.stream do |chunk|
response = JSON.parse(chunk)
response['msg'].should be_nil
response['text'].should eql(body)
expect(response['msg']).to be_nil
expect(response['text']).to eql(body)
EventMachine.stop
end
sub_2 = EventMachine::HttpRequest.new(nginx_address + '/sub2/' + channel.to_s + '.b1').get :head => headers
sub_2.stream do |chunk|
response = JSON.parse(chunk)
response['text'].should be_nil
response['msg'].should eql(body)
expect(response['text']).to be_nil
expect(response['msg']).to eql(body)
EventMachine.stop
end
......@@ -464,8 +464,8 @@ describe "Subscriber Properties" do
sub_3 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '.b1').get :head => headers
sub_3.stream do |chunk|
response = JSON.parse(chunk)
response['msg'].should be_nil
response['text'].should eql(body)
expect(response['msg']).to be_nil
expect(response['text']).to eql(body)
EventMachine.stop
end
end
......@@ -474,8 +474,8 @@ describe "Subscriber Properties" do
sub_4 = EventMachine::HttpRequest.new(nginx_address + '/sub2/' + channel.to_s + '.b1').get :head => headers
sub_4.stream do |chunk|
response = JSON.parse(chunk)
response['text'].should be_nil
response['msg'].should eql(body)
expect(response['text']).to be_nil
expect(response['msg']).to eql(body)
EventMachine.stop
end
end
......@@ -490,7 +490,7 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.stream do |chunk|
chunk.should eql("#{body}")
expect(chunk).to eql("#{body}")
EventMachine.stop
end
......@@ -508,7 +508,7 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.stream do |chunk|
chunk.should eql(" ")
expect(chunk).to eql(" ")
EventMachine.stop
end
end
......@@ -523,7 +523,7 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.stream do |chunk|
chunk.should eql(conf.ping_message_text)
expect(chunk).to eql(conf.ping_message_text)
EventMachine.stop
end
end
......@@ -538,7 +538,7 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.stream do |chunk|
chunk.should eql("-1: ")
expect(chunk).to eql("-1: ")
EventMachine.stop
end
end
......@@ -553,7 +553,7 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.stream do |chunk|
chunk.should eql("-1:#{conf.ping_message_text}")
expect(chunk).to eql("-1:#{conf.ping_message_text}")
EventMachine.stop
end
end
......@@ -567,7 +567,7 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.stream do |chunk|
sub_1.response_header['TRANSFER_ENCODING'].should eql("chunked")
expect(sub_1.response_header['TRANSFER_ENCODING']).to eql("chunked")
EventMachine.stop
end
end
......@@ -585,12 +585,12 @@ describe "Subscriber Properties" do
EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get(:head => headers).stream do
sub_4 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_4.callback do
sub_4.should be_http_status(403).without_body
sub_4.response_header['X_NGINX_PUSHSTREAM_EXPLAIN'].should eql("Subscribers limit per channel has been exceeded.")
expect(sub_4).to be_http_status(403).without_body
expect(sub_4.response_header['X_NGINX_PUSHSTREAM_EXPLAIN']).to eql("Subscribers limit per channel has been exceeded.")
sub_5 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + other_channel.to_s).get :head => headers
sub_5.callback do
sub_5.should be_http_status(200)
expect(sub_5).to be_http_status(200)
EventMachine.stop
end
end
......@@ -617,7 +617,7 @@ describe "Subscriber Properties" do
response += chunk
end
sub.callback do
response.should eql("msg 2msg 3msg 4")
expect(response).to eql("msg 2msg 3msg 4")
response = ''
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get
......@@ -625,7 +625,7 @@ describe "Subscriber Properties" do
response += chunk
end
sub_1.callback do
response.should eql("msg 5")
expect(response).to eql("msg 5")
EventMachine.stop
end
......@@ -643,9 +643,9 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.stream do |chunk|
sub_1.response_header['ACCESS_CONTROL_ALLOW_ORIGIN'].should be_nil
sub_1.response_header['ACCESS_CONTROL_ALLOW_METHODS'].should be_nil
sub_1.response_header['ACCESS_CONTROL_ALLOW_HEADERS'].should be_nil
expect(sub_1.response_header['ACCESS_CONTROL_ALLOW_ORIGIN']).to be_nil
expect(sub_1.response_header['ACCESS_CONTROL_ALLOW_METHODS']).to be_nil
expect(sub_1.response_header['ACCESS_CONTROL_ALLOW_HEADERS']).to be_nil
EventMachine.stop
end
......@@ -661,9 +661,9 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.stream do |chunk|
sub_1.response_header['ACCESS_CONTROL_ALLOW_ORIGIN'].should eql("custom.domain.com")
sub_1.response_header['ACCESS_CONTROL_ALLOW_METHODS'].should eql("GET")
sub_1.response_header['ACCESS_CONTROL_ALLOW_HEADERS'].should eql("If-Modified-Since,If-None-Match,Etag,Event-Id,Event-Type,Last-Event-Id")
expect(sub_1.response_header['ACCESS_CONTROL_ALLOW_ORIGIN']).to eql("custom.domain.com")
expect(sub_1.response_header['ACCESS_CONTROL_ALLOW_METHODS']).to eql("GET")
expect(sub_1.response_header['ACCESS_CONTROL_ALLOW_HEADERS']).to eql("If-Modified-Since,If-None-Match,Etag,Event-Id,Event-Type,Last-Event-Id")
EventMachine.stop
end
......@@ -678,9 +678,9 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s + '?domain=test.com').get :head => headers
sub_1.stream do |chunk|
sub_1.response_header['ACCESS_CONTROL_ALLOW_ORIGIN'].should eql("test.com")
sub_1.response_header['ACCESS_CONTROL_ALLOW_METHODS'].should eql("GET")
sub_1.response_header['ACCESS_CONTROL_ALLOW_HEADERS'].should eql("If-Modified-Since,If-None-Match,Etag,Event-Id,Event-Type,Last-Event-Id")
expect(sub_1.response_header['ACCESS_CONTROL_ALLOW_ORIGIN']).to eql("test.com")
expect(sub_1.response_header['ACCESS_CONTROL_ALLOW_METHODS']).to eql("GET")
expect(sub_1.response_header['ACCESS_CONTROL_ALLOW_HEADERS']).to eql("If-Modified-Since,If-None-Match,Etag,Event-Id,Event-Type,Last-Event-Id")
EventMachine.stop
end
......@@ -696,7 +696,7 @@ describe "Subscriber Properties" do
EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub.stream do |chunk|
chunk.should eql("#{conf.header_template}")
expect(chunk).to eql("#{conf.header_template}")
EventMachine.stop
end
end
......@@ -718,7 +718,7 @@ describe "Subscriber Properties" do
EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + path).get :head => headers
sub.stream do |chunk|
chunk.should eql(expected_response)
expect(chunk).to eql(expected_response)
EventMachine.stop
end
end
......@@ -748,7 +748,7 @@ describe "Subscriber Properties" do
}
})
nginx_test_configuration(merged_config).should include(%{"push_stream_header_template_file" directive is duplicate or template set by 'push_stream_header_template'})
expect(nginx_test_configuration(merged_config)).to include(%{"push_stream_header_template_file" directive is duplicate or template set by 'push_stream_header_template'})
end
it "should not accept header_template_file and header_template on same level" do
......@@ -764,7 +764,7 @@ describe "Subscriber Properties" do
}
})
nginx_test_configuration(merged_config).should include(%{"push_stream_header_template" directive is duplicate})
expect(nginx_test_configuration(merged_config)).to include(%{"push_stream_header_template" directive is duplicate})
end
it "should accept header_template_file and header_template on different levels" do
......@@ -812,7 +812,7 @@ describe "Subscriber Properties" do
:header_template_file => "/unexistent/path"
})
nginx_test_configuration(merged_config).should include(%{push stream module: unable to open file "/unexistent/path" for header template})
expect(nginx_test_configuration(merged_config)).to include(%{push stream module: unable to open file "/unexistent/path" for header template})
end
end
......@@ -823,7 +823,7 @@ describe "Subscriber Properties" do
EventMachine.run do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub.stream do |chunk|
sub.response_header['CONTENT_TYPE'].should eql(conf.content_type)
expect(sub.response_header['CONTENT_TYPE']).to eql(conf.content_type)
EventMachine.stop
end
end
......@@ -848,8 +848,8 @@ describe "Subscriber Properties" do
EventMachine.stop if chunks_received == 4
end
sub.callback do
chunks_received.should eql(4)
time_diff_sec(step2, step1).round.should eql(time_diff_sec(step4, step3).round)
expect(chunks_received).to eql(4)
expect(time_diff_sec(step2, step1).round).to eql(time_diff_sec(step4, step3).round)
end
end
end
......@@ -862,8 +862,8 @@ describe "Subscriber Properties" do
EventMachine.run do
sub_1 = EventMachine::HttpRequest.new(nginx_address + '/sub/' + channel.to_s).get :head => headers
sub_1.callback do
sub_1.response_header["EXPIRES"].should eql("Thu, 01 Jan 1970 00:00:01 GMT")
sub_1.response_header["CACHE_CONTROL"].should eql("no-cache, no-store, must-revalidate")
expect(sub_1.response_header["EXPIRES"]).to eql("Thu, 01 Jan 1970 00:00:01 GMT")
expect(sub_1.response_header["CACHE_CONTROL"]).to eql("no-cache, no-store, must-revalidate")
EventMachine.stop
end
end
......@@ -904,8 +904,8 @@ describe "Subscriber Properties" do
resp_2 += chunk
end
sub_2.callback do
resp_1.should eql("<script>p(1,'channels_path_inside_if_block','published message');</script>")
resp_2.should eql("<script>p(1,'test_channels_path_inside_if_block','published message');</script>")
expect(resp_1).to eql("<script>p(1,'channels_path_inside_if_block','published message');</script>")
expect(resp_2).to eql("<script>p(1,'test_channels_path_inside_if_block','published message');</script>")
EventMachine.stop
end
......@@ -928,12 +928,12 @@ describe "Subscriber Properties" do
actual_response << chunk
end
sub_1.callback do
sub_1.should be_http_status(200)
expect(sub_1).to be_http_status(200)
sub_1.response_header["CONTENT_ENCODING"].should eql("gzip")
expect(sub_1.response_header["CONTENT_ENCODING"]).to eql("gzip")
actual_response = Zlib::GzipReader.new(StringIO.new(actual_response)).read
actual_response.should eql("HEADER\r\nTEMPLATE\r\n1234\r\n<script>p(1,'ch_test_get_content_gzipped','body');</script></body></html>")
expect(actual_response).to eql("HEADER\r\nTEMPLATE\r\n1234\r\n<script>p(1,'ch_test_get_content_gzipped','body');</script></body></html>")
EventMachine.stop
end
publish_message_inline(channel, {}, body)
......@@ -968,13 +968,13 @@ describe "Subscriber Properties" do
actual_response += chunk
end
sub_1.callback do
sub_1.should be_http_status(200)
expect(sub_1).to be_http_status(200)
actual_response.should eql("HEADER\r\nTEMPLATE\r\n1234\r\n<script>p(1,'ch_test_extra_http','body');</script></body></html>")
expect(actual_response).to eql("HEADER\r\nTEMPLATE\r\n1234\r\n<script>p(1,'ch_test_extra_http','body');</script></body></html>")
req = EventMachine::HttpRequest.new("http://#{nginx_host}:#{nginx_port.to_i + 1}/").get
req.callback do
req.response.should eql("extra server configuration")
expect(req.response).to eql("extra server configuration")
EventMachine.stop
end
end
......@@ -1023,11 +1023,11 @@ describe "Subscriber Properties" do
actual_response_2 += chunk
end
EM.add_timer(1.5) do
sub_1.should be_http_status(200)
sub_2.should be_http_status(200)
expect(sub_1).to be_http_status(200)
expect(sub_2).to be_http_status(200)
actual_response_1.should eql("HEADER\r\nTEMPLATE\r\n1234\r\n<script>p(1,'ch_test_extra_http','body_1');</script></body></html>")
actual_response_2.should eql("body_2")
expect(actual_response_1).to eql("HEADER\r\nTEMPLATE\r\n1234\r\n<script>p(1,'ch_test_extra_http','body_1');</script></body></html>")
expect(actual_response_2).to eql("body_2")
EventMachine.stop
end
......
......@@ -32,36 +32,36 @@ describe "Receive old messages" do
get_content(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s + '.b5' + '/' + channel_3.to_s + '.b2', 6, headers) do |response, response_headers|
if ["long-polling", "polling"].include?(conf.subscriber_mode)
response_headers['LAST_MODIFIED'].to_s.should_not eql("")
response_headers['ETAG'].to_s.should_not eql("")
expect(response_headers['LAST_MODIFIED'].to_s).not_to eql("")
expect(response_headers['ETAG'].to_s).not_to eql("")
end
lines = response.split(eol)
lines[0].should eql('HEADER')
expect(lines[0]).to eql('HEADER')
line = JSON.parse(lines[1])
line['channel'].should eql(channel_2.to_s)
line['message'].should eql('body1')
line['id'].to_i.should eql(1)
expect(line['channel']).to eql(channel_2.to_s)
expect(line['message']).to eql('body1')
expect(line['id'].to_i).to eql(1)
line = JSON.parse(lines[2])
line['channel'].should eql(channel_2.to_s)
line['message'].should eql('body2')
line['id'].to_i.should eql(2)
expect(line['channel']).to eql(channel_2.to_s)
expect(line['message']).to eql('body2')
expect(line['id'].to_i).to eql(2)
line = JSON.parse(lines[3])
line['channel'].should eql(channel_2.to_s)
line['message'].should eql('body3')
line['id'].to_i.should eql(3)
expect(line['channel']).to eql(channel_2.to_s)
expect(line['message']).to eql('body3')
expect(line['id'].to_i).to eql(3)
line = JSON.parse(lines[4])
line['channel'].should eql(channel_3.to_s)
line['message'].should eql('body2')
line['id'].to_i.should eql(2)
expect(line['channel']).to eql(channel_3.to_s)
expect(line['message']).to eql('body2')
expect(line['id'].to_i).to eql(2)
line = JSON.parse(lines[5])
line['channel'].should eql(channel_3.to_s)
line['message'].should eql('body3')
line['id'].to_i.should eql(3)
expect(line['channel']).to eql(channel_3.to_s)
expect(line['message']).to eql('body3')
expect(line['id'].to_i).to eql(3)
end
end
end
......@@ -91,32 +91,32 @@ describe "Receive old messages" do
get_content(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s + '/' + channel_3.to_s, 5, sent_headers) do |response, response_headers|
if ["long-polling", "polling"].include?(conf.subscriber_mode)
response_headers['LAST_MODIFIED'].to_s.should_not eql("")
response_headers['ETAG'].to_s.should_not eql("")
expect(response_headers['LAST_MODIFIED'].to_s).not_to eql("")
expect(response_headers['ETAG'].to_s).not_to eql("")
end
lines = response.split(eol)
lines[0].should eql('HEADER')
expect(lines[0]).to eql('HEADER')
line = JSON.parse(lines[1])
line['channel'].should eql(channel_1.to_s)
line['message'].should eql('body3')
line['id'].to_i.should eql(3)
expect(line['channel']).to eql(channel_1.to_s)
expect(line['message']).to eql('body3')
expect(line['id'].to_i).to eql(3)
line = JSON.parse(lines[2])
line['channel'].should eql(channel_2.to_s)
line['message'].should eql('body3')
line['id'].to_i.should eql(3)
expect(line['channel']).to eql(channel_2.to_s)
expect(line['message']).to eql('body3')
expect(line['id'].to_i).to eql(3)
line = JSON.parse(lines[3])
line['channel'].should eql(channel_3.to_s)
line['message'].should eql('body2')
line['id'].to_i.should eql(2)
expect(line['channel']).to eql(channel_3.to_s)
expect(line['message']).to eql('body2')
expect(line['id'].to_i).to eql(2)
line = JSON.parse(lines[4])
line['channel'].should eql(channel_3.to_s)
line['message'].should eql('body3')
line['id'].to_i.should eql(3)
expect(line['channel']).to eql(channel_3.to_s)
expect(line['message']).to eql('body3')
expect(line['id'].to_i).to eql(3)
end
end
end
......@@ -146,42 +146,42 @@ describe "Receive old messages" do
get_content(nginx_address + '/sub/' + channel_1.to_s + '/' + channel_2.to_s + '.b5' + '/' + channel_3.to_s, 7, sent_headers) do |response, response_headers|
if ["long-polling", "polling"].include?(conf.subscriber_mode)
response_headers['LAST_MODIFIED'].to_s.should_not eql("")
response_headers['ETAG'].to_s.should_not eql("")
expect(response_headers['LAST_MODIFIED'].to_s).not_to eql("")
expect(response_headers['ETAG'].to_s).not_to eql("")
end
lines = response.split(eol)
lines[0].should eql('HEADER')
expect(lines[0]).to eql('HEADER')
line = JSON.parse(lines[1])
line['channel'].should eql(channel_1.to_s)
line['message'].should eql('body3')
line['id'].to_i.should eql(3)
expect(line['channel']).to eql(channel_1.to_s)
expect(line['message']).to eql('body3')
expect(line['id'].to_i).to eql(3)
line = JSON.parse(lines[2])
line['channel'].should eql(channel_2.to_s)
line['message'].should eql('body1')
line['id'].to_i.should eql(1)
expect(line['channel']).to eql(channel_2.to_s)
expect(line['message']).to eql('body1')
expect(line['id'].to_i).to eql(1)
line = JSON.parse(lines[3])
line['channel'].should eql(channel_2.to_s)
line['message'].should eql('body2')
line['id'].to_i.should eql(2)
expect(line['channel']).to eql(channel_2.to_s)
expect(line['message']).to eql('body2')
expect(line['id'].to_i).to eql(2)
line = JSON.parse(lines[4])
line['channel'].should eql(channel_2.to_s)
line['message'].should eql('body3')
line['id'].to_i.should eql(3)
expect(line['channel']).to eql(channel_2.to_s)
expect(line['message']).to eql('body3')
expect(line['id'].to_i).to eql(3)
line = JSON.parse(lines[5])
line['channel'].should eql(channel_3.to_s)
line['message'].should eql('body2')
line['id'].to_i.should eql(2)
expect(line['channel']).to eql(channel_3.to_s)
expect(line['message']).to eql('body2')
expect(line['id'].to_i).to eql(2)
line = JSON.parse(lines[6])
line['channel'].should eql(channel_3.to_s)
line['message'].should eql('body3')
line['id'].to_i.should eql(3)
expect(line['channel']).to eql(channel_3.to_s)
expect(line['message']).to eql('body3')
expect(line['id'].to_i).to eql(3)
end
end
end
......@@ -198,11 +198,11 @@ describe "Receive old messages" do
sent_headers = headers.merge({'Last-Event-Id' => 'event 2'})
get_content(nginx_address + '/sub/' + channel.to_s, 2, sent_headers) do |response, response_headers|
if ["long-polling", "polling"].include?(conf.subscriber_mode)
response_headers['LAST_MODIFIED'].to_s.should_not eql("")
response_headers['ETAG'].to_s.should_not eql("")
expect(response_headers['LAST_MODIFIED'].to_s).not_to eql("")
expect(response_headers['ETAG'].to_s).not_to eql("")
end
response.should eql("msg 3\r\nmsg 4\r\n")
expect(response).to eql("msg 3\r\nmsg 4\r\n")
end
end
end
......@@ -222,11 +222,11 @@ describe "Receive old messages" do
sent_headers = headers.merge({'If-Modified-Since' => now.utc.strftime("%a, %d %b %Y %T %Z"), 'If-None-Match' => '6'})
get_content(nginx_address + '/sub/' + channel.to_s, 4, sent_headers) do |response, response_headers|
if ["long-polling", "polling"].include?(conf.subscriber_mode)
response_headers['LAST_MODIFIED'].to_s.should_not eql("")
response_headers['ETAG'].to_s.should eql("10")
expect(response_headers['LAST_MODIFIED'].to_s).not_to eql("")
expect(response_headers['ETAG'].to_s).to eql("10")
end
response.should eql("msg 6\r\nmsg 7\r\nmsg 8\r\nmsg 9\r\n")
expect(response).to eql("msg 6\r\nmsg 7\r\nmsg 8\r\nmsg 9\r\n")
end
end
end
......@@ -242,11 +242,11 @@ describe "Receive old messages" do
sent_headers = headers.merge({'If-Modified-Since' => now.utc.strftime("%a, %d %b %Y %T %Z"), 'If-None-Match' => '0'})
get_content(nginx_address + '/sub/' + channel.to_s, 1, sent_headers) do |response, response_headers|
if ["long-polling", "polling"].include?(conf.subscriber_mode)
response_headers['LAST_MODIFIED'].to_s.should_not eql("")
response_headers['ETAG'].to_s.should eql("1")
expect(response_headers['LAST_MODIFIED'].to_s).not_to eql("")
expect(response_headers['ETAG'].to_s).to eql("1")
end
response.should eql("msg 1#{eol}")
expect(response).to eql("msg 1#{eol}")
end
end
end
......@@ -266,11 +266,11 @@ describe "Receive old messages" do
params = "time=#{URI.encode(now.utc.strftime("%a, %d %b %Y %T %Z"))}&tag=6"
get_content(nginx_address + '/sub/' + channel.to_s + '?' + params, 4, headers) do |response, response_headers|
if ["long-polling", "polling"].include?(conf.subscriber_mode)
response_headers['LAST_MODIFIED'].to_s.should_not eql("")
response_headers['ETAG'].to_s.should eql("10")
expect(response_headers['LAST_MODIFIED'].to_s).not_to eql("")
expect(response_headers['ETAG'].to_s).to eql("10")
end
response.should eql("msg 6\r\nmsg 7\r\nmsg 8\r\nmsg 9\r\n")
expect(response).to eql("msg 6\r\nmsg 7\r\nmsg 8\r\nmsg 9\r\n")
end
end
end
......@@ -290,11 +290,11 @@ describe "Receive old messages" do
params = "event_id=#{URI.escape("event 2")}"
get_content(nginx_address + '/sub/' + channel.to_s + '?' + params, 2, headers) do |response, response_headers|
if ["long-polling", "polling"].include?(conf.subscriber_mode)
response_headers['LAST_MODIFIED'].to_s.should_not eql("")
response_headers['ETAG'].to_s.should_not eql("")
expect(response_headers['LAST_MODIFIED'].to_s).not_to eql("")
expect(response_headers['ETAG'].to_s).not_to eql("")
end
response.should eql("msg 3\r\nmsg 4\r\n")
expect(response).to eql("msg 3\r\nmsg 4\r\n")
end
end
end
......@@ -363,7 +363,7 @@ describe "Receive old messages" do
lines = body.gsub(/[^\w{:,}" ]/, "\n").gsub("f{", "{").split("\n").delete_if{|line| line.empty?}.compact
lines.length.should be >= number_expected_lines
expect(lines.length).to be >= number_expected_lines
if lines.length >= number_expected_lines
block.call("#{lines.join("\r\n")}\r\n", resp_headers) unless block.nil?
......
......@@ -32,26 +32,26 @@ describe "Subscriber WebSocket" do
multi.callback do
multi.responses[:callback].length.should eql(5)
expect(multi.responses[:callback].length).to eql(5)
multi.responses[:callback][:a].should be_http_status(405)
multi.responses[:callback][:a].req.method.should eql("HEAD")
multi.responses[:callback][:a].response_header['ALLOW'].should eql("GET")
expect(multi.responses[:callback][:a]).to be_http_status(405)
expect(multi.responses[:callback][:a].req.method).to eql("HEAD")
expect(multi.responses[:callback][:a].response_header['ALLOW']).to eql("GET")
multi.responses[:callback][:b].should be_http_status(405)
multi.responses[:callback][:b].req.method.should eql("PUT")
multi.responses[:callback][:b].response_header['ALLOW'].should eql("GET")
expect(multi.responses[:callback][:b]).to be_http_status(405)
expect(multi.responses[:callback][:b].req.method).to eql("PUT")
expect(multi.responses[:callback][:b].response_header['ALLOW']).to eql("GET")
multi.responses[:callback][:c].should be_http_status(405)
multi.responses[:callback][:c].req.method.should eql("POST")
multi.responses[:callback][:c].response_header['ALLOW'].should eql("GET")
expect(multi.responses[:callback][:c]).to be_http_status(405)
expect(multi.responses[:callback][:c].req.method).to eql("POST")
expect(multi.responses[:callback][:c].response_header['ALLOW']).to eql("GET")
multi.responses[:callback][:d].should be_http_status(405)
multi.responses[:callback][:d].req.method.should eql("DELETE")
multi.responses[:callback][:d].response_header['ALLOW'].should eql("GET")
expect(multi.responses[:callback][:d]).to be_http_status(405)
expect(multi.responses[:callback][:d].req.method).to eql("DELETE")
expect(multi.responses[:callback][:d].response_header['ALLOW']).to eql("GET")
multi.responses[:callback][:e].should_not be_http_status(405)
multi.responses[:callback][:e].req.method.should eql("GET")
expect(multi.responses[:callback][:e]).not_to be_http_status(405)
expect(multi.responses[:callback][:e].req.method).to eql("GET")
EventMachine.stop
end
......@@ -67,8 +67,8 @@ describe "Subscriber WebSocket" do
socket = open_socket(nginx_host, nginx_port)
socket.print("#{request}\r\n")
headers, body = read_response_on_socket(socket)
body.should eql("")
headers.should match_the_pattern(/Don't have at least one of the mandatory headers: Connection, Upgrade, Sec-WebSocket-Key and Sec-WebSocket-Version/)
expect(body).to eql("")
expect(headers).to match_the_pattern(/Don't have at least one of the mandatory headers: Connection, Upgrade, Sec-WebSocket-Key and Sec-WebSocket-Version/)
socket.close
request << "Connection: Upgrade\r\n"
......@@ -76,8 +76,8 @@ describe "Subscriber WebSocket" do
socket = open_socket(nginx_host, nginx_port)
socket.print("#{request}\r\n")
headers, body = read_response_on_socket(socket)
body.should eql("")
headers.should match_the_pattern(/Don't have at least one of the mandatory headers: Connection, Upgrade, Sec-WebSocket-Key and Sec-WebSocket-Version/)
expect(body).to eql("")
expect(headers).to match_the_pattern(/Don't have at least one of the mandatory headers: Connection, Upgrade, Sec-WebSocket-Key and Sec-WebSocket-Version/)
socket.close
request << "Sec-WebSocket-Key: /mQoZf6pRiv8+6o72GncLQ==\r\n"
......@@ -85,8 +85,8 @@ describe "Subscriber WebSocket" do
socket = open_socket(nginx_host, nginx_port)
socket.print("#{request}\r\n")
headers, body = read_response_on_socket(socket)
body.should eql("")
headers.should match_the_pattern(/Don't have at least one of the mandatory headers: Connection, Upgrade, Sec-WebSocket-Key and Sec-WebSocket-Version/)
expect(body).to eql("")
expect(headers).to match_the_pattern(/Don't have at least one of the mandatory headers: Connection, Upgrade, Sec-WebSocket-Key and Sec-WebSocket-Version/)
socket.close
request << "Upgrade: websocket\r\n"
......@@ -94,8 +94,8 @@ describe "Subscriber WebSocket" do
socket = open_socket(nginx_host, nginx_port)
socket.print("#{request}\r\n")
headers, body = read_response_on_socket(socket)
body.should eql("")
headers.should match_the_pattern(/Don't have at least one of the mandatory headers: Connection, Upgrade, Sec-WebSocket-Key and Sec-WebSocket-Version/)
expect(body).to eql("")
expect(headers).to match_the_pattern(/Don't have at least one of the mandatory headers: Connection, Upgrade, Sec-WebSocket-Key and Sec-WebSocket-Version/)
socket.close
request << "Sec-WebSocket-Version: 8\r\n"
......@@ -103,9 +103,9 @@ describe "Subscriber WebSocket" do
socket = open_socket(nginx_host, nginx_port)
socket.print("#{request}\r\n")
headers, body = read_response_on_socket(socket)
body.should eql("")
headers.should_not match_the_pattern(/Don't have at least one of the mandatory headers: Connection, Upgrade, Sec-WebSocket-Key and Sec-WebSocket-Version/)
headers.should match_the_pattern(/HTTP\/1\.1 101 Switching Protocols/)
expect(body).to eql("")
expect(headers).not_to match_the_pattern(/Don't have at least one of the mandatory headers: Connection, Upgrade, Sec-WebSocket-Key and Sec-WebSocket-Version/)
expect(headers).to match_the_pattern(/HTTP\/1\.1 101 Switching Protocols/)
socket.close
end
end
......@@ -118,25 +118,25 @@ describe "Subscriber WebSocket" do
socket = open_socket(nginx_host, nginx_port)
socket.print("#{request}Sec-WebSocket-Version: 7\r\n\r\n")
headers, body = read_response_on_socket(socket)
body.should eql("")
headers.should match_the_pattern(/Sec-WebSocket-Version: 8, 13/)
headers.should match_the_pattern(/X-Nginx-PushStream-Explain: Version not supported. Supported versions: 8, 13/)
expect(body).to eql("")
expect(headers).to match_the_pattern(/Sec-WebSocket-Version: 8, 13/)
expect(headers).to match_the_pattern(/X-Nginx-PushStream-Explain: Version not supported. Supported versions: 8, 13/)
socket.close
socket = open_socket(nginx_host, nginx_port)
socket.print("#{request}Sec-WebSocket-Version: 8\r\n\r\n")
headers, body = read_response_on_socket(socket)
body.should eql("")
headers.should_not match_the_pattern(/Sec-WebSocket-Version: 8, 13/)
headers.should_not match_the_pattern(/X-Nginx-PushStream-Explain: Version not supported. Supported versions: 8, 13/)
expect(body).to eql("")
expect(headers).not_to match_the_pattern(/Sec-WebSocket-Version: 8, 13/)
expect(headers).not_to match_the_pattern(/X-Nginx-PushStream-Explain: Version not supported. Supported versions: 8, 13/)
socket.close
socket = open_socket(nginx_host, nginx_port)
socket.print("#{request}Sec-WebSocket-Version: 13\r\n\r\n")
headers, body = read_response_on_socket(socket)
body.should eql("")
headers.should_not match_the_pattern(/Sec-WebSocket-Version: 8, 13/)
headers.should_not match_the_pattern(/X-Nginx-PushStream-Explain: Version not supported. Supported versions: 8, 13/)
expect(body).to eql("")
expect(headers).not_to match_the_pattern(/Sec-WebSocket-Version: 8, 13/)
expect(headers).not_to match_the_pattern(/X-Nginx-PushStream-Explain: Version not supported. Supported versions: 8, 13/)
socket.close
end
end
......@@ -150,11 +150,11 @@ describe "Subscriber WebSocket" do
socket.print("#{request}\r\n")
headers, body = read_response_on_socket(socket)
socket.close
body.should eql("")
headers.should match_the_pattern(/HTTP\/1\.1 101 Switching Protocols/)
headers.should match_the_pattern(/Sec-WebSocket-Accept: RaIOIcQ6CBoc74B9EKdH0avYZnw=/)
headers.should match_the_pattern(/Upgrade: WebSocket/)
headers.should match_the_pattern(/Connection: Upgrade/)
expect(body).to eql("")
expect(headers).to match_the_pattern(/HTTP\/1\.1 101 Switching Protocols/)
expect(headers).to match_the_pattern(/Sec-WebSocket-Accept: RaIOIcQ6CBoc74B9EKdH0avYZnw=/)
expect(headers).to match_the_pattern(/Upgrade: WebSocket/)
expect(headers).to match_the_pattern(/Connection: Upgrade/)
end
end
......@@ -166,7 +166,7 @@ describe "Subscriber WebSocket" do
socket = open_socket(nginx_host, nginx_port)
socket.print("#{request}\r\n")
headers, body = read_response_on_socket(socket, 'TEMPLATE')
body.should eql("\201\017HEADER_TEMPLATE")
expect(body).to eql("\201\017HEADER_TEMPLATE")
socket.close
end
end
......@@ -180,7 +180,7 @@ describe "Subscriber WebSocket" do
socket.print("#{request}\r\n")
headers, body = read_response_on_socket(socket)
body, dummy = read_response_on_socket(socket, "\211\000")
body.should eql("\211\000")
expect(body).to eql("\211\000")
socket.close
end
end
......@@ -194,7 +194,7 @@ describe "Subscriber WebSocket" do
socket.print("#{request}\r\n")
headers, body = read_response_on_socket(socket)
body, dummy = read_response_on_socket(socket, "\210\000")
body.should eql("\210\000")
expect(body).to eql("\210\000")
socket.close
end
end
......@@ -207,7 +207,7 @@ describe "Subscriber WebSocket" do
socket = open_socket(nginx_host, nginx_port)
socket.print("#{request}\r\n")
headers, body = read_response_on_socket(socket, "\"}")
body.should eql("\x88I\x03\xF0{\"http_status\": 403, \"explain\":\"Subscriber could not create channels.\"}")
expect(body).to eql("\x88I\x03\xF0{\"http_status\": 403, \"explain\":\"Subscriber could not create channels.\"}")
socket.close
end
end
......@@ -221,7 +221,7 @@ describe "Subscriber WebSocket" do
socket.print("#{request}\r\n")
headers, body = read_response_on_socket(socket)
body, dummy = read_response_on_socket(socket, "\210\000")
body.should eql("\201\017FOOTER_TEMPLATE\210\000")
expect(body).to eql("\201\017FOOTER_TEMPLATE\210\000")
socket.close
end
end
......@@ -238,7 +238,7 @@ describe "Subscriber WebSocket" do
publish_message(channel, {}, "Hello")
body, dummy = read_response_on_socket(socket, "Hello")
body.should eql("\201\005Hello")
expect(body).to eql("\201\005Hello")
socket.close
end
end
......@@ -256,7 +256,7 @@ describe "Subscriber WebSocket" do
socket = open_socket(nginx_host, nginx_port)
socket.print("#{request}\r\n")
headers, body = read_response_on_socket(socket, "aaa")
body.should match_the_pattern(/^\201\176\377\377aaa/)
expect(body).to match_the_pattern(/^\201\176\377\377aaa/)
socket.close
end
end
......@@ -274,7 +274,7 @@ describe "Subscriber WebSocket" do
socket = open_socket(nginx_host, nginx_port)
socket.print("#{request}\r\n")
headers, body = read_response_on_socket(socket, "aaa")
body.should match_the_pattern(/^\201\177\000\000\000\000\000\001\000\000aaa/)
expect(body).to match_the_pattern(/^\201\177\000\000\000\000\000\001\000\000aaa/)
socket.close
end
end
......@@ -292,12 +292,12 @@ describe "Subscriber WebSocket" do
socket_1 = open_socket(nginx_host, nginx_port)
socket_1.print("#{request_1}\r\n")
headers_1, body_1 = read_response_on_socket(socket_1, '}')
body_1.should eql("\201\017{\"text\":\"#{body}\"}")
expect(body_1).to eql("\201\017{\"text\":\"#{body}\"}")
socket_2 = open_socket(nginx_host, nginx_port)
socket_2.print("#{request_2}\r\n")
headers_2, body_2 = read_response_on_socket(socket_2, '}')
body_2.should eql("{\"text\":\"#{body}\"}")
expect(body_2).to eql("{\"text\":\"#{body}\"}")
socket_1.close
socket_2.close
end
......@@ -333,22 +333,22 @@ describe "Subscriber WebSocket" do
socket.print(frame)
body, dummy = read_response_on_socket(socket, "ch1")
body.should eql("\211\000\x81.{\"channel\":\"ch2\", \"id\":\"1\", \"message\":\"hello\"}\x81.{\"channel\":\"ch1\", \"id\":\"1\", \"message\":\"hello\"}")
expect(body).to eql("\211\000\x81.{\"channel\":\"ch2\", \"id\":\"1\", \"message\":\"hello\"}\x81.{\"channel\":\"ch1\", \"id\":\"1\", \"message\":\"hello\"}")
socket.close
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=ALL').get :timeout => 30
pub.callback do
pub.should be_http_status(200).with_body
expect(pub).to be_http_status(200).with_body
response = JSON.parse(pub.response)
response["channels"].to_s.should_not be_empty
response["channels"].to_i.should eql(2)
response["infos"][0]["channel"].should eql("ch2")
response["infos"][0]["published_messages"].should eql("1")
response["infos"][0]["stored_messages"].should eql("1")
response["infos"][1]["channel"].should eql("ch1")
response["infos"][1]["published_messages"].should eql("1")
response["infos"][1]["stored_messages"].should eql("1")
expect(response["channels"].to_s).not_to be_empty
expect(response["channels"].to_i).to eql(2)
expect(response["infos"][0]["channel"]).to eql("ch2")
expect(response["infos"][0]["published_messages"]).to eql("1")
expect(response["infos"][0]["stored_messages"]).to eql("1")
expect(response["infos"][1]["channel"]).to eql("ch1")
expect(response["infos"][1]["published_messages"]).to eql("1")
expect(response["infos"][1]["stored_messages"]).to eql("1")
EventMachine.stop
end
end
......@@ -357,9 +357,9 @@ describe "Subscriber WebSocket" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/ch1.b1').get :timeout => 30
sub.stream do |chunk|
line = JSON.parse(chunk.split("\r\n")[0])
line['channel'].should eql("ch1")
line['message'].should eql('hello')
line['id'].to_i.should eql(1)
expect(line['channel']).to eql("ch1")
expect(line['message']).to eql('hello')
expect(line['id'].to_i).to eql(1)
EventMachine.stop
end
end
......@@ -368,9 +368,9 @@ describe "Subscriber WebSocket" do
sub = EventMachine::HttpRequest.new(nginx_address + '/sub/ch2.b1').get :timeout => 30
sub.stream do |chunk|
line = JSON.parse(chunk.split("\r\n")[0])
line['channel'].should eql("ch2")
line['message'].should eql('hello')
line['id'].to_i.should eql(1)
expect(line['channel']).to eql("ch2")
expect(line['message']).to eql('hello')
expect(line['id'].to_i).to eql(1)
EventMachine.stop
end
end
......@@ -409,14 +409,14 @@ describe "Subscriber WebSocket" do
ws.onmessage do |text, type|
received_messages += 1
msg = JSON.parse(text)
msg['channel'].should eql(channel)
expect(msg['channel']).to eql(channel)
if received_messages == 1
msg['message'].should eql(large_message)
msg['message'].size.should eql(4194304) # 4mb
expect(msg['message']).to eql(large_message)
expect(msg['message'].size).to eql(4194304) # 4mb
ws.send small_message
elsif received_messages == 2
msg['message'].should eql(small_message)
msg['message'].size.should eql(10204) # 10kb
expect(msg['message']).to eql(small_message)
expect(msg['message'].size).to eql(10204) # 10kb
EventMachine.stop
end
end
......@@ -444,12 +444,12 @@ describe "Subscriber WebSocket" do
pub = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :timeout => 30
pub.callback do
socket.close
pub.should be_http_status(200).with_body
expect(pub).to be_http_status(200).with_body
response = JSON.parse(pub.response)
response["channel"].to_s.should eql(channel)
response["published_messages"].to_i.should eql(0)
response["stored_messages"].to_i.should eql(0)
response["subscribers"].to_i.should eql(1)
expect(response["channel"].to_s).to eql(channel)
expect(response["published_messages"].to_i).to eql(0)
expect(response["stored_messages"].to_i).to eql(0)
expect(response["subscribers"].to_i).to eql(1)
EventMachine.stop
end
end
......@@ -468,18 +468,18 @@ describe "Subscriber WebSocket" do
headers, body = read_response_on_socket(socket)
socket.print(frame)
body, dummy = read_response_on_socket(socket, "\210\000")
body.should eql("\210\000")
expect(body).to eql("\210\000")
EventMachine.run do
pub = EventMachine::HttpRequest.new(nginx_address + '/channels-stats?id=' + channel.to_s).get :timeout => 30
pub.callback do
socket.close
pub.should be_http_status(200).with_body
expect(pub).to be_http_status(200).with_body
response = JSON.parse(pub.response)
response["channel"].to_s.should eql(channel)
response["published_messages"].to_i.should eql(0)
response["stored_messages"].to_i.should eql(0)
response["subscribers"].to_i.should eql(0)
expect(response["channel"].to_s).to eql(channel)
expect(response["published_messages"].to_i).to eql(0)
expect(response["stored_messages"].to_i).to eql(0)
expect(response["subscribers"].to_i).to eql(0)
EventMachine.stop
end
end
......@@ -511,7 +511,7 @@ describe "Subscriber WebSocket" do
pub = EventMachine::HttpRequest.new(nginx_address + '/pub?id=' + channel.to_s ).post :head => headers, :body => body
pub.callback do
headers, resp = read_response_on_socket(socket, '|')
resp.bytes.to_a.should eql("\x81\x7F\x00\x00\x00\x00\x00\x02\x00\x01#{body}|".bytes.to_a)
expect(resp.bytes.to_a).to eql("\x81\x7F\x00\x00\x00\x00\x00\x02\x00\x01#{body}|".bytes.to_a)
EventMachine.stop
socket.close
end
......@@ -531,8 +531,8 @@ describe "Subscriber WebSocket" do
headers, body = read_response_on_socket(socket)
socket.close
headers.should include("Expires: Thu, 01 Jan 1970 00:00:01 GMT\r\n")
headers.should include("Cache-Control: no-cache, no-store, must-revalidate\r\n")
expect(headers).to include("Expires: Thu, 01 Jan 1970 00:00:01 GMT\r\n")
expect(headers).to include("Cache-Control: no-cache, no-store, must-revalidate\r\n")
end
end
......@@ -553,12 +553,12 @@ describe "Subscriber WebSocket" do
# wait for close frame
body, dummy = read_response_on_socket(socket, "\210\000")
body.should eql("\210\000")
expect(body).to eql("\210\000")
socket.print("WRITE SOMETHING UNKNOWN\r\n")
error_log = File.read(conf.error_log)
error_log.should_not include("client sent invalid")
expect(error_log).not_to include("client sent invalid")
socket.close
end
end
......@@ -583,11 +583,11 @@ describe "Subscriber WebSocket" do
# check statistics
pub_1 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get
pub_1.callback do
pub_1.should be_http_status(200).with_body
expect(pub_1).to be_http_status(200).with_body
resp_1 = JSON.parse(pub_1.response)
resp_1.has_key?("channels").should be_true
resp_1["channels"].to_i.should eql(1)
resp_1["subscribers"].to_i.should eql(1)
expect(resp_1.has_key?("channels")).to be_truthy
expect(resp_1["channels"].to_i).to eql(1)
expect(resp_1["subscribers"].to_i).to eql(1)
# send reload signal
`#{ nginx_executable } -c #{ conf.configuration_filename } -s reload > /dev/null 2>&1`
......@@ -597,14 +597,14 @@ describe "Subscriber WebSocket" do
pub_2 = EventMachine::HttpRequest.new(nginx_address + '/channels-stats').get
pub_2.callback do
socket.close
pub_2.should be_http_status(200).with_body
expect(pub_2).to be_http_status(200).with_body
resp_2 = JSON.parse(pub_2.response)
resp_2.has_key?("channels").should be_true
resp_2["channels"].to_i.should eql(1)
resp_2["subscribers"].to_i.should eql(0)
expect(resp_2.has_key?("channels")).to be_truthy
expect(resp_2["channels"].to_i).to eql(1)
expect(resp_2["subscribers"].to_i).to eql(0)
error_log_pos = File.readlines(conf.error_log)
(error_log_pos - error_log_pre).join.should_not include("client sent invalid")
expect((error_log_pos - error_log_pre).join).not_to include("client sent invalid")
EventMachine.stop
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment