Class: Rspec::Xsd::Matcher
- Inherits:
-
Object
- Object
- Rspec::Xsd::Matcher
- Defined in:
- lib/rspec/xsd/matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(schema_path) ⇒ Matcher
constructor
A new instance of Matcher.
- #matches?(xml) ⇒ Boolean
Constructor Details
#initialize(schema_path) ⇒ Matcher
Returns a new instance of Matcher.
7 8 9 10 11 |
# File 'lib/rspec/xsd/matcher.rb', line 7 def initialize(schema_path) @schema_path = schema_path @schema = File.basename(schema_path) @errors = [] end |
Instance Method Details
#description ⇒ Object
32 33 34 |
# File 'lib/rspec/xsd/matcher.rb', line 32 def description "validate against #{@schema}" end |
#failure_message ⇒ Object
24 25 26 |
# File 'lib/rspec/xsd/matcher.rb', line 24 def "expected that XML would validate against #{@schema}\r\n\r\n#{@errors.join("\r\n")}" end |
#failure_message_when_negated ⇒ Object
28 29 30 |
# File 'lib/rspec/xsd/matcher.rb', line 28 def "expected that XML would not validate against #{@schema}" end |
#matches?(xml) ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rspec/xsd/matcher.rb', line 13 def matches?(xml) File.open(@schema_path) do |f| xsd = Nokogiri::XML::Schema(f) @errors = xsd.validate(Nokogiri::XML(xml)) end @errors.map! { |e| e } @errors.empty? end |