Sha256: 50fc5c5db3e3ec56900a4496f425c7b7d0ab197e991df640a81078617c9f2da4

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

describe 'a successfully parsed response', :shared => true do
  it 'should allow access to the root' do
    root = @response.root
    root.should_not be_nil
    root.name.should eql('RESTResponse')
  end

  it 'should be checkable by the name of its root' do
    @response.is?(:RESTResponse).should be_true
  end

  it 'should allow access to an element by its name' do
    @response.element(:RequestId).should_not be_nil
  end

  it 'should allow access to an element\'s elements by its name' do
    tokens = @response.elements(:Tokens)
    tokens.should respond_to(:each)
    tokens.should_not be_empty
  end

  it 'should allow access to an element\'s value by its name' do
    token = Relax::Response.new(@response.elements(:Tokens).first)
    token.element(:TokenId).inner_text.should eql('JPMQARDVJK')
    token.element(:Status).inner_text.should eql('Active')
  end

  it 'should have a means of checking for the existence of a node' do
    @response.has?(:Status).should_not be_nil
    @response.has?(:Errors).should be_nil
  end

  it 'should set known parameters' do
    @response.status.should eql('Success')
    @response.request_id.should eql(44287)
    @response.valid_request.should eql("true")
  end

  it 'should automatically pull parameters from the XML' do
    @response.tokens.length.should eql(2)
    @response.tokens.first.status.should eql('Active')
    @response.error.code.should eql(1)
    @response.error.message.should eql('Failed')
  end

  it 'should raise MissingParameter if required parameters are missing' do
    proc { @response.class.new('') }.should raise_error(Relax::MissingParameter)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dbalatero-relax-0.0.7.1 spec/parser_helper.rb