daodao 0.0.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/Gemfile +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +35 -6
- data/Rakefile +1 -1
- data/daodao.gemspec +6 -4
- data/lib/daodao.rb +21 -3
- data/lib/daodao/hotel.rb +49 -0
- data/lib/daodao/hotel_list.rb +33 -0
- data/lib/daodao/rank.rb +92 -0
- data/lib/daodao/version.rb +1 -1
- data/spec/hotel_list_spec.rb +14 -0
- data/spec/hotel_spec.rb +64 -0
- data/spec/rank_fast_spec.rb +7 -0
- data/spec/rank_spec.rb +45 -0
- data/spec/spec_helper.rb +91 -0
- metadata +36 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94e13e69f1a94e9ef2457e87b79d059580e4e62b
|
4
|
+
data.tar.gz: b6ff9806987c8b4b28ac3fdbb8802c4728676165
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76c7b442362b441f4a038bccf9bb74a4eadcc802692c37049200f2e870f187caffafed1afea874bf05b4228976cc9da6923f1e277da39b8e10f1c495fd498a28
|
7
|
+
data.tar.gz: 1e302326ab4b61b556dad26e114055f29e3d3f067bfc7dba09a8adb6e6cdb9eb11e4e81149058587a2f795dec4d44451323fbd03266ef12ab1d44cba50e65dc4
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
source 'https://ruby.taobao.org'
|
2
|
+
gem 'nokogiri','=1.6.6.2'
|
3
|
+
gem 'capybara', '=2.4.4'
|
4
|
+
gem 'capybara-webkit','=1.3.1'
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
### Daodao
|
2
2
|
|
3
|
-
|
3
|
+
Daodao is a Ruby gem that crawls the ota's ranking and the rooms details in [www.daodao.com](http://www.daodao.com)
|
4
4
|
|
5
|
-
|
5
|
+
### Installation
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
@@ -17,12 +17,41 @@ And then execute:
|
|
17
17
|
Or install it yourself as:
|
18
18
|
|
19
19
|
$ gem install daodao
|
20
|
+
|
21
|
+
#### Getting started
|
20
22
|
|
21
|
-
|
23
|
+
```sh
|
24
|
+
$ touch test.rb
|
25
|
+
$ vi test.rb
|
26
|
+
```
|
27
|
+
Add some codes like the following
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'daodao'
|
31
|
+
uri = "/Hotel_Review-g298555-d2682464-Reviews-Four_Seasons_Hotel_Guangzhou-Guangzhou_Guangdong.html"
|
32
|
+
sample = Daodao::Rank.new(uri)
|
33
|
+
puts 'The rooms details are as follow :'
|
34
|
+
puts sample.rooms_details
|
35
|
+
```
|
36
|
+
This will crawl the rooms details of the target hotel for you.
|
37
|
+
|
38
|
+
`Note:` You can pass other uri to `initialize` representing the hotel page.
|
39
|
+
|
40
|
+
#### Get ota's ranking
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
require 'daodao'
|
44
|
+
|
45
|
+
ranking = sample.rank
|
46
|
+
puts "The ota's ranking are as follow :"
|
47
|
+
puts ranking
|
48
|
+
```
|
49
|
+
|
50
|
+
#### Bug
|
51
|
+
1. The speed is still a problem
|
22
52
|
|
23
|
-
TODO: Write usage instructions here
|
24
53
|
|
25
|
-
|
54
|
+
### Contributing
|
26
55
|
|
27
56
|
1. Fork it ( https://github.com/[my-github-username]/daodao/fork )
|
28
57
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
data/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
|
2
|
+
|
data/daodao.gemspec
CHANGED
@@ -6,10 +6,10 @@ require 'daodao/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "daodao"
|
8
8
|
spec.version = Daodao::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
11
|
-
spec.summary = %q{
|
12
|
-
spec.description = %q{daodao hotel list}
|
9
|
+
spec.authors = ["timlen"]
|
10
|
+
spec.email = ["tinglenxan@gmail.com"]
|
11
|
+
spec.summary = %q{}
|
12
|
+
spec.description = %q{daodao hotel list.}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -20,4 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.1.0"
|
24
|
+
|
23
25
|
end
|
data/lib/daodao.rb
CHANGED
@@ -1,5 +1,23 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'capybara'
|
3
|
+
require 'capybara-webkit'
|
4
|
+
require 'open-uri'
|
5
|
+
require 'daodao/version'
|
6
|
+
require 'daodao/rank'
|
7
|
+
require 'daodao/hotel'
|
8
|
+
require 'daodao/hotel_list'
|
3
9
|
module Daodao
|
4
|
-
|
10
|
+
def self.rank(url)
|
11
|
+
page = Nokogiri::HTML(open(url))
|
12
|
+
row = {}
|
13
|
+
row[:hotel_id] = url.split('-')[2]
|
14
|
+
row[:hotel_name] = page.xpath('//span[@itemprop="name"]').text
|
15
|
+
rank=1
|
16
|
+
page.css("div.provider_meta_overview").each { |item|
|
17
|
+
key = 'rank'+rank.to_s
|
18
|
+
row[key.to_sym] = item.css("span.providerLogo_96x41").xpath('./img/@alt').first.value
|
19
|
+
rank+=1
|
20
|
+
}
|
21
|
+
row
|
22
|
+
end
|
5
23
|
end
|
data/lib/daodao/hotel.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module Daodao
|
2
|
+
class Hotel
|
3
|
+
|
4
|
+
# Crawl page from the desired hotel page
|
5
|
+
# @parmas: hotel_id, string
|
6
|
+
def initialize(hotel_id)
|
7
|
+
raise "The argument of class HotelInfo should be string" if !hotel_id.instance_of?(String)
|
8
|
+
@id = hotel_id
|
9
|
+
@url = URI("http://daodao.com/Hotel_Review-#{hotel_id}")
|
10
|
+
@pages = Nokogiri::HTML(open(@url))
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
@pages.xpath('//span[@itemprop="name"]').text
|
15
|
+
end
|
16
|
+
|
17
|
+
def id
|
18
|
+
@id
|
19
|
+
end
|
20
|
+
|
21
|
+
def stars
|
22
|
+
str = @pages.xpath('//div[@class="stars"]/span/img/@alt').first.value
|
23
|
+
str[/\d+/].to_i
|
24
|
+
end
|
25
|
+
|
26
|
+
def locality
|
27
|
+
@pages.at_css('span.locality').text
|
28
|
+
end
|
29
|
+
|
30
|
+
def country
|
31
|
+
@pages.at_css('span.country-name').text
|
32
|
+
end
|
33
|
+
|
34
|
+
def address
|
35
|
+
#TODO
|
36
|
+
#@pages.css('span.street-address')
|
37
|
+
end
|
38
|
+
|
39
|
+
def rank
|
40
|
+
text = @pages.xpath('//div[@class="slim_ranking"]/b[@class="rank_text"]').text
|
41
|
+
text[/\d+/].to_i
|
42
|
+
end
|
43
|
+
|
44
|
+
def desc
|
45
|
+
@pages.xpath('//span[@class="desc"]/text()')[0].text
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Daodao
|
2
|
+
class HotelList
|
3
|
+
START_URL = "http://www.daodao.com/dpages/sitemap/hotels.html"
|
4
|
+
def initialize
|
5
|
+
@page = Nokogiri::HTML(open(URI(START_URL)))
|
6
|
+
@page_amount = @page.xpath("//div[@id='page_list']/p/a").size
|
7
|
+
end
|
8
|
+
|
9
|
+
# Fetch the hotels in each page
|
10
|
+
def hotels_in_page(page_id)
|
11
|
+
hotel_list = []
|
12
|
+
if page_id > 1
|
13
|
+
url = "http://www.daodao.com/dpages/sitemap/hotels-#{page_id}.html"
|
14
|
+
else
|
15
|
+
url = "http://www.daodao.com/dpages/sitemap/hotels.html"
|
16
|
+
end
|
17
|
+
page = Nokogiri::HTML(open(URI(url)))
|
18
|
+
page.xpath("//dl/a").each { |hotel|
|
19
|
+
item = {}
|
20
|
+
item[:name] = hotel.text
|
21
|
+
item[:url] = hotel['href']
|
22
|
+
hotel_list.push(item)
|
23
|
+
}
|
24
|
+
return hotel_list
|
25
|
+
end
|
26
|
+
|
27
|
+
# Get the page's number
|
28
|
+
def page_amount
|
29
|
+
@page_amount
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
data/lib/daodao/rank.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
module Daodao
|
2
|
+
class Rank
|
3
|
+
include Capybara::DSL
|
4
|
+
|
5
|
+
def initialize(uri)
|
6
|
+
Capybara.current_driver = :webkit
|
7
|
+
|
8
|
+
Capybara.default_selector = :xpath
|
9
|
+
|
10
|
+
Capybara.app_host ="http://daodao.com"
|
11
|
+
page.driver.header "User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.77.4 (KHTML, like Gecko) Version/7.0.5 Safari/537.77.4"
|
12
|
+
puts " \e[34mBuilding Session...\e[0m"
|
13
|
+
@uri = uri
|
14
|
+
page.visit(URI(uri))
|
15
|
+
# Click the div to navigate hidden info
|
16
|
+
page.all("//div[@class='tab ']").each do |node|
|
17
|
+
node.trigger('click')
|
18
|
+
end
|
19
|
+
# Expand all divs tagged with '展开报价'
|
20
|
+
page.all("div[@class='provider_meta_overview mskQC_Meta_RoomTab msk']//*[text()='展开报价']").each do |layout|
|
21
|
+
puts '展开报价...'
|
22
|
+
layout.trigger('click')
|
23
|
+
end
|
24
|
+
@page = Nokogiri::HTML(page.html)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Get all the rooms details
|
28
|
+
# @Return: an array, a list of rooms details
|
29
|
+
def rooms_details
|
30
|
+
otas = []
|
31
|
+
@page.css("div.provider_meta_overview").each { |item|
|
32
|
+
row = {}
|
33
|
+
row[:ota_name] = item.css("span.providerLogo_96x41").xpath('./img/@alt').first.value
|
34
|
+
|
35
|
+
state = item.css("span.unavailable")
|
36
|
+
if state.empty?
|
37
|
+
row[:ota_state] = "有房"
|
38
|
+
row[:lowest_price] = item.css("span.price").text.sub(/¥/,'').strip.to_i
|
39
|
+
else
|
40
|
+
row[:ota_state] = "也许有房"
|
41
|
+
row[:lowest_price] = nil
|
42
|
+
end
|
43
|
+
|
44
|
+
rooms = []
|
45
|
+
dropdown_room_list = @page.css("div.provider_rooms_details")[otas.size]
|
46
|
+
dropdown_room_list.xpath("./a").each do |room_details|
|
47
|
+
room = {}
|
48
|
+
room[:room_type] = room_details.at_css("span.room_type").text
|
49
|
+
|
50
|
+
price_tax_fees = room_details.at_css("span.price_tax_fees_wrap")
|
51
|
+
room[:room_price] = price_tax_fees['price'].to_i
|
52
|
+
room[:room_tax] = price_tax_fees['taxfee'].to_i
|
53
|
+
|
54
|
+
return_amount_node = room_details.css("span.rebate_amount")
|
55
|
+
room[:return_amount] = return_amount_node.empty? ? 0 : return_amount_node.text.sub(/¥/,'').to_i
|
56
|
+
|
57
|
+
room[:room_state] = room_details.at_css("span.available").text
|
58
|
+
rooms << room
|
59
|
+
end
|
60
|
+
row[:rooms_details] = rooms
|
61
|
+
otas << row
|
62
|
+
}
|
63
|
+
return otas
|
64
|
+
end
|
65
|
+
|
66
|
+
def name
|
67
|
+
@page.xpath('//span[@itemprop="name"]').text
|
68
|
+
end
|
69
|
+
|
70
|
+
def id
|
71
|
+
@uri.split('-')[2]
|
72
|
+
end
|
73
|
+
|
74
|
+
def rank
|
75
|
+
row = {}
|
76
|
+
row[:hotel_id] = self.id
|
77
|
+
row[:hotel_name] = self.name
|
78
|
+
rank=1
|
79
|
+
@page.css("div.provider_meta_overview").each { |item|
|
80
|
+
key = 'rank'+rank.to_s
|
81
|
+
row[key.to_sym] = item.css("span.providerLogo_96x41").xpath('./img/@alt').first.value
|
82
|
+
rank+=1
|
83
|
+
}
|
84
|
+
return row
|
85
|
+
end
|
86
|
+
|
87
|
+
def screen_shot
|
88
|
+
page.save_screenshot("#{Time.now}.png")
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
data/lib/daodao/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Daodao::HotelList do
|
4
|
+
object = Daodao::HotelList.new
|
5
|
+
|
6
|
+
it "The page amount is '307' " do
|
7
|
+
expect(object.page_amount).to eq 307
|
8
|
+
end
|
9
|
+
|
10
|
+
it " The first hotel's name is '168大酒店' " do
|
11
|
+
expect(object.hotels_in_page(1)[0][:name]).to eq "168大酒店"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
data/spec/hotel_spec.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Daodao::Hotel do
|
4
|
+
# hotel in guangzhou
|
5
|
+
gz_sample = Daodao::Hotel.new("d2682464")
|
6
|
+
|
7
|
+
it "has name '四季酒店'" do
|
8
|
+
expect(gz_sample.name).to eq '四季酒店'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "has id 'd2682464'" do
|
12
|
+
expect(gz_sample.id).to eq 'd2682464'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "has stars 5.0星级" do
|
16
|
+
expect(gz_sample.stars).to eq 5
|
17
|
+
end
|
18
|
+
|
19
|
+
it "has locality '广州市'" do
|
20
|
+
expect(gz_sample.locality).to eq "广州市"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "has country name '广东省' " do
|
24
|
+
expect(gz_sample.country).to eq "广东省"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "has rank '3'" do
|
28
|
+
expect(gz_sample.rank).to eq 3
|
29
|
+
end
|
30
|
+
|
31
|
+
it "has desc '\n' " do
|
32
|
+
expect(gz_sample.desc).to eq "\n"
|
33
|
+
end
|
34
|
+
|
35
|
+
#=====================================================================================================
|
36
|
+
# hotel in beijing
|
37
|
+
bj_sample = Daodao::Hotel.new("d3256870")
|
38
|
+
|
39
|
+
it "has name '北京怡亨酒店'" do
|
40
|
+
expect(bj_sample.name).to eq '北京怡亨酒店'
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has stars 5.0星级" do
|
44
|
+
expect(bj_sample.stars).to eq 5
|
45
|
+
end
|
46
|
+
|
47
|
+
it "has locality '北京市'" do
|
48
|
+
expect(bj_sample.locality).to eq "北京市"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "has country name '中国' " do
|
52
|
+
expect(bj_sample.country).to eq "中国"
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
it "has rank '1'" do
|
57
|
+
expect(bj_sample.rank).to eq 1
|
58
|
+
end
|
59
|
+
|
60
|
+
it "has desc '北京怡亨酒店位处世界最繁忙的首都之一,共设100间房间,酒店细节专为商务旅客而设计。26间客房和套房,均于浴室内设置旋流浴,其中20间奢华套房更特设私人户外游泳池。房间内提供我们著名的“怡亨生活精品”,为高级住宿体验带来新定义。怡亨酒店不仅让您细味现代奢华的艺术,亦让您品味现代艺术的奢华。' " do
|
61
|
+
expect(bj_sample.desc).to eq "北京怡亨酒店位处世界最繁忙的首都之一,共设100间房间,酒店细节专为商务旅客而设计。26间客房和套房,均于浴室内设置旋流浴,其中20间奢华套房更特设私人户外游泳池。房间内提供我们著名的“怡亨生活精品”,为高级住宿体验带来新定义。怡亨酒店不仅让您细味现代奢华的艺术,亦让您品味现代艺术的奢华。"
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Daodao do
|
3
|
+
ranks = Daodao.rank('http://www.daodao.com/Hotel_Review-g298555-d2682464-Reviews-Four_Seasons_Hotel_Guangzhou-Guangzhou_Guangdong.html')
|
4
|
+
it "The first Ota name 'Booking.com' " do
|
5
|
+
expect(ranks[:rank1]).to eq 'Booking.com'
|
6
|
+
end
|
7
|
+
end
|
data/spec/rank_spec.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Daodao::Rank do
|
3
|
+
gz_sample = Daodao::Rank.new('/Hotel_Review-g298555-d2682464-Reviews-Four_Seasons_Hotel_Guangzhou-Guangzhou_Guangdong.html')
|
4
|
+
details = gz_sample.rooms_details
|
5
|
+
p gz_sample.rank
|
6
|
+
# screen shot
|
7
|
+
gz_sample.screen_shot
|
8
|
+
|
9
|
+
it "has otas amount '5'" do
|
10
|
+
expect(details.size).to eq 5
|
11
|
+
end
|
12
|
+
|
13
|
+
it "has lowest price '1903' " do
|
14
|
+
expect(details[2][:rooms_details][0][:room_price]).to eq 1903
|
15
|
+
end
|
16
|
+
|
17
|
+
it "The first Ota name 'Booking.com' " do
|
18
|
+
expect(details[0][:ota_name]).to eq 'Booking.com'
|
19
|
+
end
|
20
|
+
|
21
|
+
it "The rank 3 ota'name '艺龙旅行网' " do
|
22
|
+
expect(details[2][:ota_name]).to eq '艺龙旅行网'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "The rooms amount provided by elong '10'" do
|
26
|
+
expect(details[2][:rooms_details].size).to eq 10
|
27
|
+
end
|
28
|
+
|
29
|
+
it "The highest price of the rooms '4230'" do
|
30
|
+
expect(details[0][:rooms_details][3][:room_price]).to eq 4230
|
31
|
+
end
|
32
|
+
|
33
|
+
it "The room-type with the lowest price '高级城景房'" do
|
34
|
+
expect(details[2][:rooms_details][0][:room_type]).to eq '高级城景房'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "The first room's price of the last ota '2330'"do
|
38
|
+
expect(details[4][:rooms_details][0][:room_price]).to eq 2330
|
39
|
+
end
|
40
|
+
|
41
|
+
it "has The hotel name '四季酒店'"do
|
42
|
+
expect(gz_sample.name).to eq "四季酒店"
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
+
#
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
10
|
+
# a separate helper file that requires the additional dependencies and performs
|
11
|
+
# the additional setup, and require it from the spec files that actually need it.
|
12
|
+
#
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
+
# users commonly want.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
RSpec.configure do |config|
|
18
|
+
# rspec-expectations config goes here. You can use an alternate
|
19
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
20
|
+
# assertions if you prefer.
|
21
|
+
config.expect_with :rspec do |expectations|
|
22
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
23
|
+
# and `failure_message` of custom matchers include text for helper methods
|
24
|
+
# defined using `chain`, e.g.:
|
25
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
26
|
+
# # => "be bigger than 2 and smaller than 4"
|
27
|
+
# ...rather than:
|
28
|
+
# # => "be bigger than 2"
|
29
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
30
|
+
end
|
31
|
+
|
32
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
33
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
34
|
+
config.mock_with :rspec do |mocks|
|
35
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
36
|
+
# a real object. This is generally recommended, and will default to
|
37
|
+
# `true` in RSpec 4.
|
38
|
+
mocks.verify_partial_doubles = true
|
39
|
+
end
|
40
|
+
|
41
|
+
# The settings below are suggested to provide a good initial experience
|
42
|
+
# with RSpec, but feel free to customize to your heart's content.
|
43
|
+
=begin
|
44
|
+
# These two settings work together to allow you to limit a spec run
|
45
|
+
# to individual examples or groups you care about by tagging them with
|
46
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
47
|
+
# get run.
|
48
|
+
config.filter_run :focus
|
49
|
+
config.run_all_when_everything_filtered = true
|
50
|
+
|
51
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
52
|
+
# For more details, see:
|
53
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
54
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
55
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
56
|
+
config.disable_monkey_patching!
|
57
|
+
|
58
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
59
|
+
# be too noisy due to issues in dependencies.
|
60
|
+
config.warnings = true
|
61
|
+
|
62
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
63
|
+
# file, and it's useful to allow more verbose output when running an
|
64
|
+
# individual spec file.
|
65
|
+
if config.files_to_run.one?
|
66
|
+
# Use the documentation formatter for detailed output,
|
67
|
+
# unless a formatter has already been configured
|
68
|
+
# (e.g. via a command-line flag).
|
69
|
+
config.default_formatter = 'doc'
|
70
|
+
end
|
71
|
+
|
72
|
+
# Print the 10 slowest examples and example groups at the
|
73
|
+
# end of the spec run, to help surface which specs are running
|
74
|
+
# particularly slow.
|
75
|
+
config.profile_examples = 10
|
76
|
+
|
77
|
+
# Run specs in random order to surface order dependencies. If you find an
|
78
|
+
# order dependency and want to debug it, you can fix the order by providing
|
79
|
+
# the seed, which is printed after each run.
|
80
|
+
# --seed 1234
|
81
|
+
config.order = :random
|
82
|
+
|
83
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
84
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
85
|
+
# test failures related to randomization by passing the same `--seed` value
|
86
|
+
# as the one that triggered the failure.
|
87
|
+
Kernel.srand config.seed
|
88
|
+
=end
|
89
|
+
end
|
90
|
+
|
91
|
+
require 'daodao'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daodao
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- timlen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,21 +38,44 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.1.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.1.0
|
55
|
+
description: daodao hotel list.
|
42
56
|
email:
|
43
|
-
-
|
57
|
+
- tinglenxan@gmail.com
|
44
58
|
executables: []
|
45
59
|
extensions: []
|
46
60
|
extra_rdoc_files: []
|
47
61
|
files:
|
48
62
|
- ".gitignore"
|
63
|
+
- ".rspec"
|
49
64
|
- Gemfile
|
50
65
|
- LICENSE.txt
|
51
66
|
- README.md
|
52
67
|
- Rakefile
|
53
68
|
- daodao.gemspec
|
54
69
|
- lib/daodao.rb
|
70
|
+
- lib/daodao/hotel.rb
|
71
|
+
- lib/daodao/hotel_list.rb
|
72
|
+
- lib/daodao/rank.rb
|
55
73
|
- lib/daodao/version.rb
|
74
|
+
- spec/hotel_list_spec.rb
|
75
|
+
- spec/hotel_spec.rb
|
76
|
+
- spec/rank_fast_spec.rb
|
77
|
+
- spec/rank_spec.rb
|
78
|
+
- spec/spec_helper.rb
|
56
79
|
homepage: ''
|
57
80
|
licenses:
|
58
81
|
- MIT
|
@@ -73,8 +96,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
96
|
version: '0'
|
74
97
|
requirements: []
|
75
98
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.2.2
|
77
100
|
signing_key:
|
78
101
|
specification_version: 4
|
79
|
-
summary:
|
80
|
-
test_files:
|
102
|
+
summary: ''
|
103
|
+
test_files:
|
104
|
+
- spec/hotel_list_spec.rb
|
105
|
+
- spec/hotel_spec.rb
|
106
|
+
- spec/rank_fast_spec.rb
|
107
|
+
- spec/rank_spec.rb
|
108
|
+
- spec/spec_helper.rb
|