Last active
August 4, 2016 13:49
-
-
Save qd3v/437859585c909da9cd8e to your computer and use it in GitHub Desktop.
Revisions
-
Ivan Byurganovskiy revised this gist
Aug 4, 2016 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,19 @@ def xml_document(&block) end end # OR # module SpecHelpers # # Should be used with be_equivalent_to provided by 'equivalent-xml' gem # # @see http://www.rubydoc.info/github/sparklemotion/nokogiri/Nokogiri/XML/Builder # # @see https://github.com/mbklein/equivalent-xml # def xml_document(&block) # Nokogiri::XML::Builder.new(&block).doc # end # end # RSpec.configuration.include(SpecHelpers) # spec describe "XML", :api do -
Ivan Byurganovskiy revised this gist
Jul 31, 2015 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,12 +13,12 @@ def xml_document(&block) # spec describe "XML", :api do let(:response_xml) do <<-XML <?xml version="1.0" encoding="utf-8"?> <Response> <Num>100</Num> <Body from="100" to="200">Test</Body> </Response> XML @@ -28,11 +28,12 @@ def xml_document(&block) xml_document do Response { Body('Test', from: '100', to: '200') Num(100) } end end it "strings" do expect(response_xml).to be_equivalent_to(pattern) end end -
Ivan Byurganovskiy revised this gist
Jul 31, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,7 @@ RSpec.configure do |config| # Should be used with be_equivalent_to provided by 'equivalent-xml' gem # @see http://www.rubydoc.info/github/sparklemotion/nokogiri/Nokogiri/XML/Builder # @see https://github.com/mbklein/equivalent-xml def xml_document(&block) Nokogiri::XML::Builder.new(&block).doc end @@ -13,6 +14,7 @@ def xml_document(&block) # spec describe "XML" do # <?xml?> can be skipped safely, it will still match let(:response_xml) do <<-XML <?xml version="1.0" encoding="utf-8"?> -
Ivan Byurganovskiy created this gist
Jul 31, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ # spec_helper.rb require 'nokogiri' require 'equivalent-xml/rspec_matchers' RSpec.configure do |config| # Should be used with be_equivalent_to provided by 'equivalent-xml' gem # @see http://www.rubydoc.info/github/sparklemotion/nokogiri/Nokogiri/XML/Builder def xml_document(&block) Nokogiri::XML::Builder.new(&block).doc end end # spec describe "XML" do let(:response_xml) do <<-XML <?xml version="1.0" encoding="utf-8"?> <Response> <Body from="100" to="200">Test</Body> </Response> XML end let(:pattern) do xml_document do Response { Body('Test', from: '100', to: '200') } end end it "strings" do expect(response_xml).to be_equivalent_to(pattern) end end