spec/uptimerobot_spec.rb in uptimerobot-0.1.3 vs spec/uptimerobot_spec.rb in uptimerobot-0.1.4

- old
+ new

@@ -111,9 +111,53 @@ end end expect(client.getMonitors(params)).to eq response end + + context 'when include escaped string' do + let(:escaped_string) do + 'http monitor (basic auth)' + end + + let(:unescaped_string) do + 'http monitor (basic auth)' + end + + let(:response_with_escaped_string) do + res = response.dup + res['monitors']['monitor'][0]['friendlyname'] = escaped_string + res + end + + let(:response_with_unescaped_string) do + res = response.dup + res['monitors']['monitor'][0]['friendlyname'] = unescaped_string + res + end + + it do + client = uptime_robot do |stub| + stub.get('getMonitors') do |env| + expect(env.params).to eq DEFAULT_PARAMS.merge(stringify_hash(params)) + [200, {'Content-Type' => 'json'}, JSON.dump(response_with_escaped_string)] + end + end + + expect(client.getMonitors(params)).to eq response_with_unescaped_string + end + + it do + client = uptime_robot(:skip_unescape_monitor => true) do |stub| + stub.get('getMonitors') do |env| + expect(env.params).to eq DEFAULT_PARAMS.merge(stringify_hash(params)) + [200, {'Content-Type' => 'json'}, JSON.dump(response_with_escaped_string)] + end + end + + expect(client.getMonitors(params)).to eq response_with_escaped_string + end + end end describe '#newMonitor' do let(:params) do {