spec/acceptance/rest/channel_spec.rb in ably-1.0.3 vs spec/acceptance/rest/channel_spec.rb in ably-1.0.4
- old
+ new
@@ -254,10 +254,29 @@
end
end
end
end
end
+
+ context 'with a non ASCII channel name' do
+ let(:channel_name) { 'foo:¡€≤`☃' }
+ let(:channel_name_encoded) { 'foo%3A%C2%A1%E2%82%AC%E2%89%A4%60%E2%98%83' }
+ let(:endpoint) { client.endpoint }
+ let(:channel) { client.channels.get(channel_name) }
+
+ context 'stubbed', :webmock do
+ let!(:get_stub) {
+ stub_request(:post, "#{endpoint}/channels/#{channel_name_encoded}/publish").
+ to_return(:body => '{}', :headers => { 'Content-Type' => 'application/json' })
+ }
+
+ it 'correctly encodes the channel name' do
+ channel.publish('foo')
+ expect(get_stub).to have_been_requested
+ end
+ end
+ end
end
describe '#history' do
let(:channel) { client.channel("persisted:#{random_str(4)}") }
let(:expected_history) do
@@ -372,10 +391,10 @@
[:start, :end].each do |option|
describe ":#{option}", :webmock do
let!(:history_stub) {
query_params = default_history_options
.merge(option => milliseconds).map { |k, v| "#{k}=#{v}" }.join('&')
- stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/messages?#{query_params}").
+ stub_request(:get, "#{endpoint}/channels/#{URI.encode_www_form_component(channel_name)}/messages?#{query_params}").
to_return(:body => '{}', :headers => { 'Content-Type' => 'application/json' })
}
before do
channel.history(options)