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 characters
| <root> | |
| <schools> | |
| <school> | |
| <id>1</id> | |
| <name>First school</name> | |
| </school> | |
| <school> | |
| <id>2</id> | |
| <name>Second school</name> | |
| </school> |
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 characters
| let(:doc) { Nokogiri::XML(xml) } | |
| it do | |
| id = doc.xpath('//school[name/text()="Second school"]/id').text | |
| expect(id).to eq('2') | |
| end |
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 characters
| let(:doc) { Nokogiri::XML(xml) } | |
| it do | |
| school_id = doc.xpath('//school[name/text()="Second school"]/id').text | |
| student_names = doc.xpath("//student[schoolId/text()=#{school_id}]/name").map(&:text) | |
| expect(student_names).to match(%w(Alex Olivia)) | |
| end |
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 characters
| class School | |
| include HappyMapper | |
| tag 'school' | |
| has_one :id, String | |
| has_one :name, String | |
| end | |
| let(:schools) { School.parse(xml) } | |
| it do |
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 characters
| class Student | |
| include HappyMapper | |
| tag 'student' | |
| has_one :name, String | |
| has_one :school_id, String, tag: 'schoolId' | |
| end | |
| class School | |
| include HappyMapper | |
| tag 'school' |
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 characters
| require 'spec_helper' | |
| require 'nokogiri' | |
| describe 'Nokogiri' do | |
| let(:xml) do | |
| %( | |
| <root> | |
| <schools> | |
| <school> | |
| <id>1</id> |
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 characters
| <?xml version="1.0"?> | |
| <root> | |
| <authorities> | |
| <authority> | |
| <originID>100</originID> | |
| <timestamp>2016-06-08T15:56:32</timestamp> | |
| <authorityName>authorityNameNew</authorityName> | |
| <INN>1234567890</INN> | |
| </authority> | |
| </authorities> |
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 characters
| grep -Eo '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' access.log | uniq -c | sort --reverse | head -n10 |
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 characters
| require 'sinatra' | |
| get '/pizza' do | |
| if rand(0..1).zero? | |
| 'OK' | |
| else | |
| 'Something is wrong' | |
| end | |
| end |
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 characters
| require 'net/http' | |
| url = URI.parse('http://localhost:4567/pizza') | |
| req = Net::HTTP::Get.new(url.to_s) | |
| res = Net::HTTP.start(url.host, url.port) { |http| http.request(req) } | |
| body = res.body | |
| abort body if body != 'OK' |
OlderNewer