taobaorb 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/taobao/base.rb +3 -3
- data/lib/taobao/category.rb +2 -2
- data/lib/taobao/product.rb +15 -15
- data/lib/taobao/product_list.rb +4 -6
- data/lib/taobao/property.rb +13 -1
- data/lib/taobao/user.rb +3 -12
- data/lib/taobao/util.rb +1 -3
- data/lib/taobao/version.rb +1 -1
- data/lib/taobao/xml_parser.rb +25 -0
- data/lib/taobaorb.rb +1 -0
- metadata +59 -40
- data/spec/fixtures/absent_user.json +0 -1
- data/spec/fixtures/category.json +0 -1
- data/spec/fixtures/category_properties.json +0 -1
- data/spec/fixtures/category_without_subcategories.json +0 -1
- data/spec/fixtures/error.json +0 -1
- data/spec/fixtures/incorrect_category.json +0 -1
- data/spec/fixtures/items.json +0 -1
- data/spec/fixtures/items_page15.json +0 -1
- data/spec/fixtures/no_items.json +0 -1
- data/spec/fixtures/product.json +0 -1
- data/spec/fixtures/product_wo_property_alias.json +0 -1
- data/spec/fixtures/property.json +0 -20
- data/spec/fixtures/search.json +0 -1
- data/spec/fixtures/subcategories.json +0 -1
- data/spec/fixtures/top_category_properties.json +0 -1
- data/spec/fixtures/user.json +0 -1
- data/spec/fixtures/user_unknown_sex.json +0 -1
- data/spec/rspec/category_spec.rb +0 -64
- data/spec/rspec/product_list_spec.rb +0 -75
- data/spec/rspec/product_spec.rb +0 -51
- data/spec/rspec/property_list_spec.rb +0 -37
- data/spec/rspec/property_spec.rb +0 -32
- data/spec/rspec/search_spec.rb +0 -25
- data/spec/rspec/taobao_spec.rb +0 -32
- data/spec/rspec/user_spec.rb +0 -75
- data/spec/rspec/util_spec.rb +0 -18
- data/spec/spec_helper.rb +0 -26
data/spec/fixtures/search.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"items_get_response":{"items":{"item":[{"cid":1512,"delist_time":"2012-05-29 09:25:22","nick":"最低最诚信","num_iid":10203414733,"pic_url":"http:\/\/img04.taobaocdn.com\/bao\/uploaded\/i4\/T1QcfcXdxmXXaamH3._111446.jpg","post_fee":"15.00","price":"4650.00","score":12,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4S 未激活 黑白 三网4s 有实体 杜绝假配件","type":"fixed","volume":2210},{"cid":1512,"delist_time":"2012-05-27 21:00:13","nick":"华优数码","num_iid":15130756477,"pic_url":"http:\/\/img03.taobaocdn.com\/bao\/uploaded\/i3\/T1RhmLXgVlXXacA6gW_024151.jpg","post_fee":"0.00","price":"4200.00","score":13,"title":"五一疯抢「未激活」未拆封Apple\/苹果 <span class=H>iPhone<\/span> 4S 预装500美金软件","type":"fixed","volume":1592},{"cid":1512,"delist_time":"2012-06-02 12:55:24","nick":"新太数码通讯","num_iid":13199871937,"pic_url":"http:\/\/img02.taobaocdn.com\/bao\/uploaded\/i2\/T1FEeUXohqXXb8w0rb_093444.jpg","post_fee":"0.00","price":"4937.73","score":12,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4S 未拆封未激活 完美越狱 预装正版软件","type":"fixed","volume":1599},{"cid":1512,"delist_time":"2012-05-31 11:36:12","nick":"能良数码专营店","num_iid":10380105929,"pic_url":"http:\/\/img01.taobaocdn.com\/bao\/uploaded\/i1\/T1u2m7Xg8oXXcfpKEY_025913.jpg","post_fee":"0.00","price":"3688.00","score":13,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4 (8G) <span class=H>iPhone<\/span>4 正品手机 全国联保 送电保包","type":"fixed","volume":1433},{"cid":1512,"delist_time":"2012-06-02 09:46:16","nick":"能良数码专营店","num_iid":15179732651,"pic_url":"http:\/\/img.taobaocdn.com\/bao\/uploaded\/T1UuG7Xm8pXXbLgPgY_030104.jpg","post_fee":"0.00","price":"4598.00","score":13,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4S \/<span class=H>iphone<\/span>4s 16G 手机 大陆行货 送剪卡器","type":"fixed","volume":1296},{"cid":1512,"delist_time":"2012-06-01 12:17:50","nick":"梓诺数码","num_iid":13222815181,"pic_url":"http:\/\/img04.taobaocdn.com\/bao\/uploaded\/i4\/T1aweWXhVmXXaMhqQ4_051737.jpg","post_fee":"0.00","price":"4368.00","score":9,"title":"包邮 原封未激活Apple\/苹果 <span class=H>iPhone<\/span> 4S 16G 64G 另有电信版本","type":"fixed","volume":1130},{"cid":1512,"delist_time":"2012-05-30 18:46:39","nick":"马兴澄","num_iid":15144887356,"pic_url":"http:\/\/img02.taobaocdn.com\/bao\/uploaded\/i2\/T1CCveXftkXXau0IkT_011155.jpg","post_fee":"20.00","price":"3499.00","score":9,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4S(有锁) 16G 原装正品 三网通用 完美越狱","type":"fixed","volume":887},{"cid":1512,"delist_time":"2012-06-02 12:13:43","nick":"笨笨牛仔","num_iid":9341245712,"pic_url":"http:\/\/img01.taobaocdn.com\/bao\/uploaded\/i1\/T11pOQXntgXXc7PZrc_125953.jpg","post_fee":"15.00","price":"4070.00","score":12,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4 8G 16G 32G <span class=H>iphone<\/span>4 无锁 4代 苹果4 手机S","type":"fixed","volume":1022},{"cid":1512,"delist_time":"2012-06-02 12:08:26","nick":"泡泡卡520","num_iid":13922237072,"pic_url":"http:\/\/img01.taobaocdn.com\/bao\/uploaded\/i1\/T1iAWtXkBeXXXxQokY_031037.jpg","post_fee":"20.00","price":"3380.00","score":11,"title":"皇冠Apple\/苹果 <span class=H>iPhone<\/span> 4S(有锁) 正品美版全新 电信三网 手机","type":"fixed","volume":716},{"cid":1512,"delist_time":"2012-05-30 22:07:02","nick":"思创永辉数码专营店","num_iid":16327752569,"pic_url":"http:\/\/img02.taobaocdn.com\/bao\/uploaded\/i2\/T17s1QXilcXXbYd7Q1_042109.jpg","post_fee":"0.00","price":"4628.00","score":10,"title":"包顺丰 Apple\/苹果 <span class=H>iPhone<\/span> 4S 手机 4代 裸机现货 原封 无锁行货","type":"fixed","volume":632},{"cid":1512,"delist_time":"2012-05-31 13:45:02","nick":"数码通讯2008_2008","num_iid":12962369261,"pic_url":"http:\/\/img04.taobaocdn.com\/bao\/uploaded\/i4\/T1esHfXoJeXXaUc_E8_101724.jpg","post_fee":"15.00","price":"4410.00","score":13,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4S 全新未拆 预装正版软件","type":"fixed","volume":662},{"cid":1512,"delist_time":"2012-05-31 10:01:58","nick":"xiangliken321681","num_iid":14912908255,"pic_url":"http:\/\/img03.taobaocdn.com\/bao\/uploaded\/i3\/T1peCIXiBXXXbmqTc__080540.jpg","post_fee":"22.00","price":"1068.00","score":12,"title":"五一回馈 Apple\/苹果 <span class=H>iPhone<\/span> 3GS(16G)8G 32G 现货 疯狂热销中","type":"fixed","volume":583},{"cid":1512,"delist_time":"2012-06-02 12:34:43","nick":"国越电讯","num_iid":12950938369,"pic_url":"http:\/\/img02.taobaocdn.com\/bao\/uploaded\/i2\/T1gsCCXkRYXXXaPOk4_053311.jpg","post_fee":"0.00","price":"4350.00","score":10,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4S V版无锁 电信cdma 三网插卡 原封包邮减百","type":"fixed","volume":377},{"cid":1512,"delist_time":"2012-05-31 16:34:00","nick":"中原通讯98","num_iid":7827685023,"pic_url":"http:\/\/img03.taobaocdn.com\/bao\/uploaded\/i3\/T1xsrcXc0mXXXkRT79_104723.jpg","post_fee":"0.00","price":"4450.00","score":12,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4代8G未开封 抢购国行未激活 51特价全场8折","type":"fixed","volume":653},{"cid":1512,"delist_time":"2012-05-30 22:25:18","nick":"gddigital","num_iid":13708928375,"pic_url":"http:\/\/img01.taobaocdn.com\/bao\/uploaded\/i1\/T1QJveXi8lXXXjkGAW_022444.jpg","post_fee":"0.00","price":"4380.00","score":11,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4S 原封未激活 绝对原装配件 可免费越狱","type":"fixed","volume":552},{"cid":1512,"delist_time":"2012-05-28 17:56:29","nick":"逸倩飘秀","num_iid":3919390731,"pic_url":"http:\/\/img04.taobaocdn.com\/bao\/uploaded\/i4\/T1zzSFXkBwXXbBVcI._111542.jpg","post_fee":"20.00","price":"4370.00","score":12,"title":"「原封未激活」全新未拆 Apple\/苹果 <span class=H>iPhone<\/span> 4S实体店可刷卡 现货","type":"fixed","volume":483},{"cid":1512,"delist_time":"2012-06-02 11:18:00","nick":"泽和欣通通讯","num_iid":13632597732,"pic_url":"http:\/\/img02.taobaocdn.com\/bao\/uploaded\/i2\/T1suepXjtZXXcGYpPX_084119.jpg","post_fee":"15.00","price":"4700.00","score":9,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4S4s 正品行货 纯正原封未激活可越狱实体店","type":"fixed","volume":457},{"cid":1512,"delist_time":"2012-06-01 20:30:04","nick":"ourswei","num_iid":15252451347,"pic_url":"http:\/\/img08.taobaocdn.com\/bao\/uploaded\/i8\/T1B6G_XeXlXXbtxZE8_100025.jpg","post_fee":"0.00","price":"2500.00","score":10,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4代 美版 (有锁) 8G 16G 32G 港版无锁版 包邮","type":"fixed","volume":442},{"cid":1512,"delist_time":"2012-05-28 11:18:43","nick":"龙星通讯","num_iid":12934292127,"pic_url":"http:\/\/img04.taobaocdn.com\/bao\/uploaded\/i4\/T1jE5XXXVDXXbi.dU._112010.jpg","post_fee":"0.00","price":"2500.00","score":10,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4 16G 有锁无锁港版行货全面到货全国包邮顺丰","type":"fixed","volume":512},{"cid":1512,"delist_time":"2012-05-29 19:32:50","nick":"xialingzhi79","num_iid":12550667631,"pic_url":"http:\/\/img03.taobaocdn.com\/bao\/uploaded\/i3\/T1yJi6XdXmXXXWwe_a_121027.jpg","post_fee":"12.00","price":"1299.00","score":8,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 3GS(16G)3代\/苹果三代\/包邮顺丰\/上海实体店","type":"fixed","volume":401},{"cid":1512,"delist_time":"2012-06-02 12:12:02","nick":"红樂手机卖场","num_iid":16739412689,"pic_url":"http:\/\/img04.taobaocdn.com\/bao\/uploaded\/i4\/T1BNbcXdNmXXX2FA6a_122100.jpg","post_fee":"0.10","price":"2749.00","score":9,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4代(CDMA)电信版 代烧号 送充电宝 不包写号","type":"fixed","volume":336},{"cid":1512,"delist_time":"2012-05-30 16:17:00","nick":"亮点数码2009","num_iid":8376603070,"pic_url":"http:\/\/img01.taobaocdn.com\/bao\/uploaded\/i1\/T1SKCJXhlpXXc9w.74_054448.jpg","post_fee":"0.00","price":"4020.00","score":9,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4代8G 国行未激活 五一全场8折起特价3200元S","type":"fixed","volume":265},{"cid":1512,"delist_time":"2012-05-29 15:04:34","nick":"bw贝贝","num_iid":13238884556,"pic_url":"http:\/\/img06.taobaocdn.com\/bao\/uploaded\/i6\/T1jxvcXgNmXXb7l0sU_013937.jpg","post_fee":"0.00","price":"2500.00","score":12,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4 8G 抢国行未激活 全国包邮","type":"fixed","volume":406},{"cid":1512,"delist_time":"2012-05-31 01:13:09","nick":"4gshuma","num_iid":12496402839,"pic_url":"http:\/\/img02.taobaocdn.com\/bao\/uploaded\/i2\/T1DSjdXi8pXXaRnZ75_055255.jpg","post_fee":"22.00","price":"500.00","score":9,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 1代(4G)8G16G正品苹果一代手机支持后台录像","type":"fixed","volume":423},{"cid":1512,"delist_time":"2012-06-02 12:59:13","nick":"睿网客","num_iid":14662067500,"pic_url":"http:\/\/img02.taobaocdn.com\/bao\/uploaded\/i2\/T1RI55XlluXXcF4VrX_114057.jpg","post_fee":"0.00","price":"2500.00","score":11,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4代 美版 (有锁) 港版无锁版 包邮返80","type":"fixed","volume":315},{"cid":1512,"delist_time":"2012-06-02 12:06:50","nick":"新新陋室铭","num_iid":14132121621,"pic_url":"http:\/\/img01.taobaocdn.com\/bao\/uploaded\/i1\/T1CFW8XfXoXXagxJo9_103047.jpg","post_fee":"22.00","price":"3349.00","score":7,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4S(有锁)全新原装正品,完美越狱,当天发货","type":"fixed","volume":485},{"cid":1512,"delist_time":"2012-05-29 19:31:33","nick":"涛涛数码2000","num_iid":16375532140,"pic_url":"http:\/\/img02.taobaocdn.com\/bao\/uploaded\/i2\/T1xxvdXbBdXXaF4HU3_045939.jpg","post_fee":"0.00","price":"2500.00","score":12,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4代(CDMA) 16G无锁版 包邮电信智能手机","type":"fixed","volume":508},{"cid":1512,"delist_time":"2012-05-31 12:48:59","nick":"gongning924","num_iid":14031198667,"pic_url":"http:\/\/img01.taobaocdn.com\/bao\/uploaded\/i1\/T1atmzXXFLXXbF9ezX_115025.jpg","post_fee":"30.00","price":"3398.00","score":12,"title":"皇冠 日版 Apple\/苹果 <span class=H>iPhone<\/span> 4S(有锁) 5.01送礼包 三网通用!","type":"fixed","volume":180},{"cid":1512,"delist_time":"2012-05-27 11:56:53","nick":"鸿润通讯","num_iid":7597937771,"pic_url":"http:\/\/img04.taobaocdn.com\/bao\/uploaded\/i4\/T1c0S9Xi8vXXbWGxZU_014819.jpg","post_fee":"0.00","price":"3750.00","score":12,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4代8G抢原封未激活3160元返30元5.11完美越狱S","type":"fixed","volume":418},{"cid":1512,"delist_time":"2012-06-01 14:52:50","nick":"大平数码深圳店","num_iid":9991015958,"pic_url":"http:\/\/img03.taobaocdn.com\/bao\/uploaded\/i3\/T1JmqeXiRnXXbGtFcY_024917.jpg","post_fee":"0.00","price":"1080.00","score":9,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 3GS(16G)3代\/苹果三代\/二手手机\/包邮顺丰","type":"fixed","volume":268},{"cid":1512,"delist_time":"2012-05-27 11:40:05","nick":"a13723457681","num_iid":13646473139,"pic_url":"http:\/\/img01.taobaocdn.com\/bao\/uploaded\/i1\/T1Fl1AXj81XXcPJAZ._112905.jpg","post_fee":"13.00","price":"550.00","score":9,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 1代(4G)8G 16G 苹果一代 原装正品二手手机","type":"fixed","volume":320},{"cid":1512,"delist_time":"2012-05-28 16:29:22","nick":"廖南宾","num_iid":8687531634,"pic_url":"http:\/\/img04.taobaocdn.com\/bao\/uploaded\/i4\/T1UPK9XfVcXXbt29QS_010155.jpg","post_fee":"0.00","price":"2600.00","score":12,"title":"促销特价 Apple\/苹果 <span class=H>iPhone<\/span> 4代 8g 全国包顺丰快递","type":"fixed","volume":378},{"cid":1512,"delist_time":"2012-05-29 16:29:10","nick":"sz13751133142","num_iid":13398694847,"pic_url":"http:\/\/img02.taobaocdn.com\/bao\/uploaded\/i2\/T1Tt_fXbRfXXa0xqHX_114226.jpg","post_fee":"0.00","price":"4340.00","score":11,"title":"现货Apple\/苹果 <span class=H>iPhone<\/span> 4S 全新未拆封 未激活16G\/32G 杜绝假配件","type":"fixed","volume":207},{"cid":1512,"delist_time":"2012-05-30 09:54:19","nick":"seven_susu","num_iid":12962993288,"pic_url":"http:\/\/img03.taobaocdn.com\/bao\/uploaded\/i3\/T1zYzfXgpfXXc3FKfa_120619.jpg","post_fee":"20.00","price":"4200.00","score":14,"title":"完美越狱!Apple\/苹果 <span class=H>iPhone<\/span> 4S 大陆行货 送软件 送七件礼品","type":"fixed","volume":309},{"cid":1512,"delist_time":"2012-05-27 23:31:40","nick":"没有为什么007","num_iid":8972051685,"pic_url":"http:\/\/img01.taobaocdn.com\/bao\/uploaded\/i1\/T129mGXb8BXXbirR.._113338.jpg","post_fee":"16.00","price":"3599.00","score":10,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4(8G)苹果手机 黑白现货,当日发货!","type":"fixed","volume":190},{"cid":1512,"delist_time":"2012-05-30 16:59:46","nick":"子月数码","num_iid":15786732285,"pic_url":"http:\/\/img01.taobaocdn.com\/bao\/uploaded\/i1\/T1IXPfXjhiXXb2n7EW_024329.jpg","post_fee":"0.00","price":"4400.00","score":10,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4代8G 无锁2863 抢原封未激活3196元S 返50元","type":"fixed","volume":249},{"cid":1512,"delist_time":"2012-05-26 18:30:12","nick":"便宜爽歪歪","num_iid":14222533827,"pic_url":"http:\/\/img03.taobaocdn.com\/bao\/uploaded\/i3\/T1IXu4Xn0fXXakzx.7_064801.jpg","post_fee":"0.00","price":"3600.00","score":9,"title":"清仓特价 包邮 送贴膜 Apple\/苹果 <span class=H>iPhone<\/span> 4 8G无锁 <span class=H>iphone<\/span>4手机S","type":"fixed","volume":334},{"cid":1512,"delist_time":"2012-06-02 11:04:33","nick":"响当当手机","num_iid":14312891950,"pic_url":"http:\/\/img07.taobaocdn.com\/bao\/uploaded\/i7\/T11wm1XehkXXbSSJ3Z_032055.jpg","post_fee":"0.00","price":"4460.00","score":11,"title":"Apple\/苹果 <span class=H>iPhone<\/span> 4S 香港官网订购全新未拆封(附电子票)","type":"fixed","volume":179},{"cid":1512,"delist_time":"2012-06-01 22:41:44","nick":"奇迹shouji","num_iid":2997802325,"pic_url":"http:\/\/img03.taobaocdn.com\/bao\/uploaded\/i3\/T1YsfeXbxkXXXpZak._110941.jpg","post_fee":"0.00","price":"4300.00","score":15,"title":"可完美越狱 Apple\/苹果 <span class=H>iPhone<\/span> 4S 正品 装软件 未拆封 未激活","type":"fixed","volume":266},{"cid":1512,"delist_time":"2012-05-28 13:02:25","nick":"小傻仔_","num_iid":12707674672,"pic_url":"http:\/\/img02.taobaocdn.com\/bao\/uploaded\/i2\/T1VAyrXcVnXXanEQs0_035824.jpg","post_fee":"0.00","price":"4310.00","score":12,"title":"【正品\/假一赔三】Apple\/苹果 <span class=H>iPhone<\/span> 4S 16G\/32G\/64G 无锁版","type":"fixed","volume":196}]},"total_results":3140949}}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"itemcats_get_response":{"item_cats":{"item_cat":[{"cid":2908,"is_parent":false,"name":"ZIPPO\/芝宝","parent_cid":28},{"cid":50000467,"is_parent":true,"name":"品牌打火机\/其它打火机","parent_cid":28},{"cid":290601,"is_parent":false,"name":"瑞士军刀","parent_cid":28},{"cid":50011894,"is_parent":false,"name":"眼镜架","parent_cid":28},{"cid":50011895,"is_parent":false,"name":"眼镜片","parent_cid":28},{"cid":50011892,"is_parent":false,"name":"框架眼镜","parent_cid":28},{"cid":50010368,"is_parent":false,"name":"太阳眼镜","parent_cid":28},{"cid":50011893,"is_parent":true,"name":"功能眼镜","parent_cid":28},{"cid":50011888,"is_parent":true,"name":"眼镜配件、护理剂","parent_cid":28},{"cid":50011896,"is_parent":false,"name":"滴眼液、护眼用品","parent_cid":28},{"cid":2909,"is_parent":true,"name":"烟具","parent_cid":28},{"cid":50012709,"is_parent":false,"name":"酒具","parent_cid":28}]}}}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"itemprops_get_response":{}}
|
data/spec/fixtures/user.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"user_get_response":{"user":{"buyer_credit":{"good_num":1292,"level":8,"score":1292,"total_num":1292},"created":"2005-12-10 19:03:18","last_visit":"2012-06-29 23:28:25","location":{"city":"金华","state":"浙江"},"nick":"喜客多2008","seller_credit":{"good_num":2587208,"level":18,"score":2576453,"total_num":2624203},"sex":"f","type":"C","uid":"6cd6014f007c04426e2437fef870329a","user_id":18139021}}}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"user_get_response":{"user":{"buyer_credit":{"good_num":0,"level":0,"score":0,"total_num":0},"created":"2009-01-16 11:26:54","last_visit":"2012-06-29 23:23:57","location":{"city":"广州","state":"广东"},"nick":"t400旗舰店","seller_credit":{"good_num":329528,"level":15,"score":329528,"total_num":329528},"type":"B","uid":"f640763e5f08956d425e445e704b1fc4","user_id":174145821}}}
|
data/spec/rspec/category_spec.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Taobao::Category do
|
5
|
-
describe '#id' do
|
6
|
-
it 'should returns ID of the category' do
|
7
|
-
category = Taobao::Category.new(28)
|
8
|
-
category.id.should == 28
|
9
|
-
end
|
10
|
-
end
|
11
|
-
describe '#name' do
|
12
|
-
it 'should returns the name of the category' do
|
13
|
-
category = Taobao::Category.new(28)
|
14
|
-
fixture = 'category'.json_fixture
|
15
|
-
args = {
|
16
|
-
method: 'taobao.itemcats.get',
|
17
|
-
fields: 'cid,parent_cid,name,is_parent',
|
18
|
-
cids: 28
|
19
|
-
}
|
20
|
-
Taobao.stub(:api_request).with(args).and_return(fixture)
|
21
|
-
category.name.should == 'ZIPPO/瑞士军刀/眼镜'
|
22
|
-
end
|
23
|
-
it 'should throws an exception if the category ID is incorrect' do
|
24
|
-
Net::HTTP.stub(:post_form).and_return 'incorrect_category'.to_response
|
25
|
-
category = Taobao::Category.new(-20)
|
26
|
-
expect {
|
27
|
-
category.name
|
28
|
-
}.to raise_error Taobao::ApiError, 'Invalid arguments:cids'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#subcategories' do
|
33
|
-
before :each do
|
34
|
-
@category = Taobao::Category.new(28)
|
35
|
-
end
|
36
|
-
it 'should returns subcategories if they are exists' do
|
37
|
-
Taobao.stub(:api_request).and_return 'subcategories'.json_fixture
|
38
|
-
@category.subcategories.should have_at_least(1).subcategory
|
39
|
-
end
|
40
|
-
it 'should returns empty array if subcategories do not exist' do
|
41
|
-
Taobao.stub(:api_request).and_return 'category_without_subcategories'.json_fixture
|
42
|
-
@category.subcategories.should be_empty
|
43
|
-
end
|
44
|
-
it 'each subcategory should be an object of Taobao::Category class' do
|
45
|
-
Taobao.stub(:api_request).and_return 'subcategories'.json_fixture
|
46
|
-
@category.subcategories[0].should be_a_kind_of(Taobao::Category)
|
47
|
-
@category.subcategories[0].id.should be > 0
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe '#properties' do
|
52
|
-
it 'should return a PropertyList object' do
|
53
|
-
category = Taobao::Category.new(0)
|
54
|
-
category.properties.should be_a_kind_of(Taobao::PropertyList)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#products' do
|
59
|
-
it 'should return a ProductList object' do
|
60
|
-
category = Taobao::Category.new(28)
|
61
|
-
category.products.should be_a_kind_of(Taobao::ProductList)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Taobao::ProductList do
|
5
|
-
|
6
|
-
describe 'init with default options and category id' do
|
7
|
-
pl = Taobao::ProductList.new(cid: 28)
|
8
|
-
|
9
|
-
fixture = 'items'.json_fixture
|
10
|
-
args = {
|
11
|
-
method: 'taobao.items.get',
|
12
|
-
fields: 'num_iid,title,nick,pic_url,cid,price,type,delist_time,post_fee,score,volume',
|
13
|
-
cid: 28
|
14
|
-
}
|
15
|
-
|
16
|
-
it 'should return 40 items' do
|
17
|
-
Taobao.stub(:api_request).with(args).and_return(fixture)
|
18
|
-
pl.should have_exactly(40).items
|
19
|
-
end
|
20
|
-
it 'total count should be greater than zero' do
|
21
|
-
Taobao.stub(:api_request).with(args).and_return(fixture)
|
22
|
-
pl.total_count.should be > 0
|
23
|
-
end
|
24
|
-
it 'items could be iterated' do
|
25
|
-
pl.each { |item| item.should be_a_kind_of(Taobao::Product) }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'init and use advanced options' do
|
30
|
-
pl = Taobao::ProductList.new(cid: 28)
|
31
|
-
.page(15)
|
32
|
-
.per_page(10)
|
33
|
-
.order_by_price
|
34
|
-
|
35
|
-
fixture = 'items_page15'.json_fixture
|
36
|
-
args = {
|
37
|
-
method: 'taobao.items.get',
|
38
|
-
fields: 'num_iid,title,nick,pic_url,cid,price,type,delist_time,post_fee,score,volume',
|
39
|
-
cid: 28,
|
40
|
-
page_no: 15,
|
41
|
-
page_size: 10,
|
42
|
-
order_by: 'price'
|
43
|
-
}
|
44
|
-
|
45
|
-
it 'should return 10 items' do
|
46
|
-
Taobao.stub(:api_request).with(args).and_return(fixture)
|
47
|
-
pl.should have_exactly(10).items
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'unknown method' do
|
52
|
-
it 'should raise exception' do
|
53
|
-
pl = Taobao::ProductList.new(cid: 28)
|
54
|
-
expect {
|
55
|
-
pl.undefined_method
|
56
|
-
}.to raise_error NoMethodError
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe 'category without items' do
|
61
|
-
it 'should return 0 items' do
|
62
|
-
pl = Taobao::ProductList.new(cid: 283333)
|
63
|
-
fixture = 'no_items'.json_fixture
|
64
|
-
args = {
|
65
|
-
method: 'taobao.items.get',
|
66
|
-
fields: 'num_iid,title,nick,pic_url,cid,price,type,delist_time,post_fee,score,volume',
|
67
|
-
cid: 283333
|
68
|
-
}
|
69
|
-
Taobao.stub(:api_request).with(args).and_return(fixture)
|
70
|
-
pl.total_count.should == 0
|
71
|
-
pl.should have_exactly(0).items
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
data/spec/rspec/product_spec.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Taobao::Product do
|
5
|
-
before(:each) do
|
6
|
-
args = {
|
7
|
-
method: 'taobao.item.get',
|
8
|
-
fields: 'cid,num_iid,title,nick,price,pic_url,type,score,delist_time,' +
|
9
|
-
'post_fee,volume,detail_url,seller_cids,props,input_pids,' +
|
10
|
-
'input_str,desc,num,valid_thru,list_time,stuff_status,' +
|
11
|
-
'location,express_fee,ems_fee,has_discount,freight_payer,' +
|
12
|
-
'has_invoice,has_warranty,has_showcase,modified,increment,' +
|
13
|
-
'approve_status,postage_id,product_id,auction_point,' +
|
14
|
-
'property_alias,item_img,prop_img,sku,video,outer_id,is_virtual',
|
15
|
-
num_iid: '2997802325'
|
16
|
-
}
|
17
|
-
fixture = 'product'.json_fixture
|
18
|
-
Taobao.stub(:api_request).with(args).and_return(fixture)
|
19
|
-
@product = Taobao::Product.new(2997802325)
|
20
|
-
end
|
21
|
-
|
22
|
-
describe 'initialize with id' do
|
23
|
-
it 'should returns product' do
|
24
|
-
@product.cid.should == 1512
|
25
|
-
@product.nick.should == '奇迹shouji'
|
26
|
-
@product.num_iid.should == 2997802325
|
27
|
-
@product.pic_url.should == 'http://img03.taobaocdn.com/bao/uploaded/i3/T1YsfeXbxkXXXpZak._110941.jpg'
|
28
|
-
@product.price.should == 4300.00
|
29
|
-
@product.title.should == '可完美越狱 Apple/苹果 iPhone 4S 正品 装软件 未拆封 未激活'
|
30
|
-
|
31
|
-
@product.approve_status.should == 'onsale'
|
32
|
-
@product.auction_point.should == 0
|
33
|
-
@product.delist_time.should == '2012-06-01 22:41:44'
|
34
|
-
@product.type.should == 'fixed'
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'get unknown product property' do
|
38
|
-
it 'should raise an exception' do
|
39
|
-
expect {
|
40
|
-
@product.unknown_property
|
41
|
-
}.to raise_error NoMethodError
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#user' do
|
47
|
-
it 'should returns Taobao::User object' do
|
48
|
-
@product.user.should be_a_kind_of Taobao::User
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Taobao::PropertyList do
|
5
|
-
describe 'initialize with category ID' do
|
6
|
-
|
7
|
-
it 'should returns property' do
|
8
|
-
property_list = Taobao::PropertyList.new(cid: 1512)
|
9
|
-
|
10
|
-
fixture = 'category_properties'.json_fixture
|
11
|
-
args = {
|
12
|
-
method: 'taobao.itemprops.get',
|
13
|
-
fields: 'pid,name,prop_values,must,multi,is_color_prop,is_key_prop,is_enum_prop,is_input_prop,is_sale_prop,is_item_prop',
|
14
|
-
cid: 1512
|
15
|
-
}
|
16
|
-
Taobao.stub(:api_request).with(args).and_return(fixture)
|
17
|
-
property_list.first.should be_a_kind_of(Taobao::Property)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'category without properties' do
|
22
|
-
|
23
|
-
it 'should returns 0 properties' do
|
24
|
-
property_list = Taobao::PropertyList.new(cid: 0)
|
25
|
-
|
26
|
-
fixture = 'top_category_properties'.json_fixture
|
27
|
-
args = {
|
28
|
-
method: 'taobao.itemprops.get',
|
29
|
-
fields: 'pid,name,prop_values,must,multi,is_color_prop,is_key_prop,is_enum_prop,is_input_prop,is_sale_prop,is_item_prop',
|
30
|
-
cid: 0
|
31
|
-
}
|
32
|
-
Taobao.stub(:api_request).with(args).and_return(fixture)
|
33
|
-
property_list.should have(0).items
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
data/spec/rspec/property_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Taobao::Property do
|
5
|
-
describe 'initialize' do
|
6
|
-
describe 'with correct data' do
|
7
|
-
it 'should create Property object' do
|
8
|
-
property_response = 'property'.json_fixture
|
9
|
-
property = Taobao::Property.new(property_response)
|
10
|
-
|
11
|
-
property.multi.should be_false
|
12
|
-
property.must.should be_true
|
13
|
-
property.name.should == "品牌"
|
14
|
-
property.pid.should == 20000
|
15
|
-
property.values.should be_a_kind_of Array
|
16
|
-
property.values.should have_exactly(2).items
|
17
|
-
|
18
|
-
value = property.values.first
|
19
|
-
value[:is_parent].should be_true
|
20
|
-
value[:name].should == "Acer/宏基"
|
21
|
-
value[:vid].should == 26691
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'with incorrect data' do
|
26
|
-
it 'should throws an exception' do
|
27
|
-
expect { Taobao::Property.new({}) }
|
28
|
-
.to raise_error(Taobao::IncorrectProperty, 'Incorrect property data')
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/spec/rspec/search_spec.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Taobao do
|
5
|
-
|
6
|
-
describe 'search method returns product list' do
|
7
|
-
search = Taobao::search('iPhone')
|
8
|
-
|
9
|
-
fixture = 'search'.json_fixture
|
10
|
-
args = {
|
11
|
-
method: 'taobao.items.get',
|
12
|
-
fields: 'num_iid,title,nick,pic_url,cid,price,type,delist_time,post_fee,score,volume',
|
13
|
-
q: 'iPhone'
|
14
|
-
}
|
15
|
-
|
16
|
-
it 'should return 40 items' do
|
17
|
-
Taobao.stub(:api_request).with(args).and_return(fixture)
|
18
|
-
search.should have(40).results
|
19
|
-
end
|
20
|
-
it 'total count should be greater than zero' do
|
21
|
-
Taobao.stub(:api_request).with(args).and_return(fixture)
|
22
|
-
search.total_count.should be > 0
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/spec/rspec/taobao_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Taobao do
|
4
|
-
describe 'set the public API key' do
|
5
|
-
it 'should have rw access' do
|
6
|
-
Taobao.public_key = :test
|
7
|
-
Taobao.public_key.should == :test
|
8
|
-
end
|
9
|
-
end
|
10
|
-
describe 'set the private API key' do
|
11
|
-
it 'should be write-only' do
|
12
|
-
Taobao.private_key = :test
|
13
|
-
expect { Taobao.private_key }
|
14
|
-
.to raise_error NoMethodError
|
15
|
-
end
|
16
|
-
end
|
17
|
-
describe 'API request' do
|
18
|
-
it 'should always return a Hash object' do
|
19
|
-
Net::HTTP.stub(:post_form).and_return 'category'.to_response
|
20
|
-
result = Taobao.api_request(method: 'taobao.itemcats.get',
|
21
|
-
fields: 'cid,parent_cid,name,is_parent', cids: 0)
|
22
|
-
result.should be_a_kind_of(Hash)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
describe 'failed API request' do
|
26
|
-
it 'should throws an exception' do
|
27
|
-
Net::HTTP.stub(:post_form).and_return 'error'.to_response
|
28
|
-
expect { Taobao.api_request({}) }
|
29
|
-
.to raise_error(Taobao::ApiError, 'Invalid arguments:cid')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/spec/rspec/user_spec.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Taobao::User do
|
5
|
-
describe 'getting user by valid nickname' do
|
6
|
-
it 'should returns valid user info' do
|
7
|
-
fixture = 'user'.json_fixture
|
8
|
-
args = {
|
9
|
-
method: 'taobao.user.get',
|
10
|
-
fields: 'user_id,uid,nick,sex,buyer_credit,seller_credit,location,' +
|
11
|
-
'created,last_visit,birthday,type,status,alipay_no,alipay_account,'+
|
12
|
-
'alipay_account,email,consumer_protection,alipay_bind',
|
13
|
-
nick: '喜客多2008'
|
14
|
-
}
|
15
|
-
Taobao.stub(:api_request).with(args).and_return(fixture)
|
16
|
-
|
17
|
-
user = Taobao::User.new('喜客多2008')
|
18
|
-
|
19
|
-
user.nick.should == '喜客多2008'
|
20
|
-
user.good_purchases_count.should == 1292
|
21
|
-
user.buyer_level.should == 8
|
22
|
-
user.buyer_score.should == 1292
|
23
|
-
user.total_purchases_count.should == 1292
|
24
|
-
|
25
|
-
user.good_sales_count.should == 2587208
|
26
|
-
user.seller_level.should == 18
|
27
|
-
user.seller_score.should == 2576453
|
28
|
-
user.total_sales_count.should == 2624203
|
29
|
-
|
30
|
-
user.registration_date.should == DateTime.new(2005,12,10, 19,03,18)
|
31
|
-
user.last_visit.should == DateTime.new(2012,06,29, 23,28,25)
|
32
|
-
|
33
|
-
user.city.should == '金华'
|
34
|
-
user.state.should == '浙江'
|
35
|
-
|
36
|
-
user.sex.should == :female
|
37
|
-
user.type.should == 'C'
|
38
|
-
|
39
|
-
user.uid.should == '6cd6014f007c04426e2437fef870329a'
|
40
|
-
user.id.should == 18139021
|
41
|
-
end
|
42
|
-
end
|
43
|
-
describe 'getting user who does not specify his/her sex' do
|
44
|
-
it 'should returns :unknown value' do
|
45
|
-
fixture = 'user_unknown_sex'.json_fixture
|
46
|
-
args = {
|
47
|
-
method: 'taobao.user.get',
|
48
|
-
fields: 'user_id,uid,nick,sex,buyer_credit,seller_credit,location,' +
|
49
|
-
'created,last_visit,birthday,type,status,alipay_no,alipay_account,'+
|
50
|
-
'alipay_account,email,consumer_protection,alipay_bind',
|
51
|
-
nick: 't400旗舰店'
|
52
|
-
}
|
53
|
-
Taobao.stub(:api_request).with(args).and_return(fixture)
|
54
|
-
user = Taobao::User.new('t400旗舰店')
|
55
|
-
user.sex.should == :unknown
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe 'getting non-existent user' do
|
60
|
-
it 'should throws an exception' do
|
61
|
-
fixture = 'absent_user'.json_fixture
|
62
|
-
args = {
|
63
|
-
method: 'taobao.user.get',
|
64
|
-
fields: 'user_id,uid,nick,sex,buyer_credit,seller_credit,location,' +
|
65
|
-
'created,last_visit,birthday,type,status,alipay_no,alipay_account,'+
|
66
|
-
'alipay_account,email,consumer_protection,alipay_bind',
|
67
|
-
nick: 'nonexistent_user'
|
68
|
-
}
|
69
|
-
Taobao.stub(:api_request).with(args).and_return(fixture)
|
70
|
-
|
71
|
-
expect { Taobao::User.new('nonexistent_user').uid }
|
72
|
-
.to raise_error NoMethodError
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
data/spec/rspec/util_spec.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
class ToObjectTest
|
5
|
-
attr_reader :a, :b
|
6
|
-
include Taobao::Util
|
7
|
-
end
|
8
|
-
|
9
|
-
describe Taobao::Util do
|
10
|
-
describe 'to_object' do
|
11
|
-
it 'should convert some hash to object' do
|
12
|
-
obj = ToObjectTest.new
|
13
|
-
obj.to_object a: 5, b: 6
|
14
|
-
obj.a.should == 5
|
15
|
-
obj.b.should == 6
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'simplecov'
|
3
|
-
|
4
|
-
SimpleCov.start do
|
5
|
-
add_group 'Libraries', 'lib'
|
6
|
-
add_group 'Specs', 'spec'
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'taobaorb'
|
10
|
-
|
11
|
-
Response = Struct.new('Responce', :body)
|
12
|
-
|
13
|
-
class String
|
14
|
-
def to_response
|
15
|
-
Response.new get_fixture_as_text
|
16
|
-
end
|
17
|
-
|
18
|
-
def json_fixture
|
19
|
-
JSON.parse get_fixture_as_text, {symbolize_names: true}
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
def get_fixture_as_text
|
24
|
-
open("spec/fixtures/#{self}.json").read
|
25
|
-
end
|
26
|
-
end
|