-
-
Save leehambley/2817bee77fd4eec1f28b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(rdb:1) @response.class | |
XMLParser | |
(rdb:1) @response.body | |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<error>\n | |
<error_message>Authentication Missing</error_message>\n | |
<error_code>57</error_code>\n</error>\n" | |
(rdb:1) @response.body.class | |
String | |
(rdb:1) @response.xml | |
{"error_message"=>["Authentication Missing"], "error_code"=>["57"]} | |
(rdb:1) @response.xml.class | |
Hash | |
(rdb:1) @response.body.should have_xpath('/error_message') | |
Spec::Expectations::ExpectationNotMetError Exception: expected | |
following text to match xpath /error_message: | |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" | |
"http://www.w3.org/TR/REC-html40/loose.dtd"> | |
<?xml version="1.0" | |
encoding="UTF-8"?><html><body><error><error_message>Authentication | |
Missing</error_message><error_code>57</error_code></error></body></html> | |
(rdb:1) @response.xml.should have_xpath('/error_message') | |
Spec::Expectations::ExpectationNotMetError Exception: expected | |
following text to match xpath /error_message: | |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" | |
"http://www.w3.org/TR/REC-html40/loose.dtd"> | |
<?xml version="1.0" | |
encoding="UTF-8"?><html><body><error><error_message>Authentication | |
Missing</error_message><error_code>57</error_code></error></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Constants | |
# | |
GATEWAY_ADDRESS = 'http://localhost:4567/' | |
# Debugging | |
require 'ruby-debug' | |
Debugger.settings[:autoeval] = true | |
# Others | |
require 'webrat' | |
require 'mechanize' | |
require 'webrat' | |
require 'xmlsimple' | |
require 'builder' | |
# Makes the rsync syntax prettier... | |
# doing { ... }.should raise_error | |
alias :doing :lambda | |
# Configure webrat for Mechanize | |
Webrat.configure do |config| | |
config.mode = :mechanize | |
end | |
# Configure our Mech world | |
class MechanizeWorld < Webrat::MechanizeSession | |
require 'spec' | |
include Webrat::Matchers | |
include Spec::Matchers | |
include Webrat::HaveTagMatcher | |
def initialize | |
@agent ||= WWW::Mechanize.new | |
@agent.pluggable_parser.default = XMLParser | |
@agent.pluggable_parser.html = XMLParser | |
end | |
end | |
World do | |
MechanizeWorld.new | |
end | |
class XMLParser < WWW::Mechanize::File | |
attr_reader :xml | |
def initialize(uri=nil, response=nil, body=nil, code=nil) | |
super(uri, response, body, code) | |
# @xml = XmlSimple.xml_in(body) | |
@xml = body | |
end | |
end | |
## | |
## Everything below this line taken from | |
## http://blog.wolfman.com/articles/2008/1/2/xpath-matchers-for-rspec | |
## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Where in the chain does this: | |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<error>\n | |
<error_message>Authentication Missing</error_message>\n | |
<error_code>57</error_code>\n</error>\n" | |
become this?: | |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" | |
"http://www.w3.org/TR/REC-html40/loose.dtd"> | |
<?xml version="1.0" | |
encoding="UTF-8"?><html><body><error><error_message>Authentication | |
Missing</error_message><error_code>57</error_code></error></body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment