File: crack_spec.rb

package info (click to toggle)
ruby-fogbugz 0.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 132 kB
  • sloc: ruby: 199; makefile: 3
file content (26 lines) | stat: -rw-r--r-- 767 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
RSpec.describe 'Cracker' do
  context 'valid response xml' do
    let(:xml) { %q(<?xml version="1.0" encoding="UTF-8"?>
                   <response>
                     <version>2</version>
                   </response>) }

    it 'parses the response' do
      expect(parse_xml(xml)).to eq({ 'version' => '2' })
    end
  end

  context 'invalid response xml' do
    let(:xml) { %q(<html><head><title>Object moved</title></head><body>
                   <h2>Object moved to <a href="http://example.fogbugz.com:84/internalError.asp?aspxerrorpath=/api.asp">here</a>.</h2>
                   </body></html>) }

    it 'returns nil' do
      expect(parse_xml(xml)).to be_nil
    end
  end

  def parse_xml(xml)
    Fogbugz::Adapter::XML::Cracker.parse(xml)
  end
end