spec/acceptance/rest/presence_spec.rb in ably-0.7.6 vs spec/acceptance/rest/presence_spec.rb in ably-0.8.0
- old
+ new
@@ -122,15 +122,22 @@
end
end
let(:client) do
Ably::Rest::Client.new(key: "#{user}:#{secret}")
end
+ let(:default_options) do
+ {
+ direction: :backwards,
+ limit: 100
+ }
+ end
[:start, :end].each do |option|
describe ":#{option}", :webmock do
let!(:history_stub) {
- stub_request(:get, "#{endpoint}/channels/#{CGI.escape(channel_name)}/presence/history?#{option}=#{milliseconds}").
+ query_params = default_options.merge(option => milliseconds).map { |k, v| "#{k}=#{v}" }.join('&')
+ stub_request(:get, "#{endpoint}/channels/#{CGI.escape(channel_name)}/presence/history?#{query_params}").
to_return(:body => '{}', :headers => { 'Content-Type' => 'application/json' })
}
before do
presence.history(options)
@@ -223,11 +230,11 @@
end
end
context '#get' do
let!(:get_stub) {
- stub_request(:get, "#{endpoint}/channels/#{CGI.escape(channel_name)}/presence").
+ stub_request(:get, "#{endpoint}/channels/#{CGI.escape(channel_name)}/presence?limit=100").
to_return(:body => serialized_encoded_message, :headers => { 'Content-Type' => content_type })
}
after do
expect(get_stub).to have_been_requested
@@ -240,11 +247,11 @@
end
end
context '#history' do
let!(:history_stub) {
- stub_request(:get, "#{endpoint}/channels/#{CGI.escape(channel_name)}/presence/history").
+ stub_request(:get, "#{endpoint}/channels/#{CGI.escape(channel_name)}/presence/history?direction=backwards&limit=100").
to_return(:body => serialized_encoded_message, :headers => { 'Content-Type' => content_type })
}
after do
expect(history_stub).to have_been_requested
@@ -270,11 +277,11 @@
end
context '#get' do
let(:client_options) { default_options.merge(log_level: :fatal) }
let!(:get_stub) {
- stub_request(:get, "#{endpoint}/channels/#{CGI.escape(channel_name)}/presence").
+ stub_request(:get, "#{endpoint}/channels/#{CGI.escape(channel_name)}/presence?limit=100").
to_return(:body => serialized_encoded_message_with_invalid_encoding, :headers => { 'Content-Type' => content_type })
}
let(:presence_message) { presence.get.items.first }
after do
@@ -294,10 +301,10 @@
end
context '#history' do
let(:client_options) { default_options.merge(log_level: :fatal) }
let!(:history_stub) {
- stub_request(:get, "#{endpoint}/channels/#{CGI.escape(channel_name)}/presence/history").
+ stub_request(:get, "#{endpoint}/channels/#{CGI.escape(channel_name)}/presence/history?direction=backwards&limit=100").
to_return(:body => serialized_encoded_message_with_invalid_encoding, :headers => { 'Content-Type' => content_type })
}
let(:presence_message) { presence.history.items.first }
after do