cafepress-alpha 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,83 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+ require File.dirname(__FILE__) + '/../lib/cafepress'
3
+ require File.dirname(__FILE__) + '/mock/cafepress'
4
+ require 'soap/soap'
5
+ require 'soap/wsdlDriver'
6
+
7
+ class CafePressSearchTest < Test::Unit::TestCase
8
+
9
+ def setup
10
+ @api_key = ENV['CPDN_API_KEY']
11
+ end
12
+
13
+ def test_create
14
+ cp = CafePress::Search.new
15
+ assert_equal CafePress::Search, cp.class
16
+ end
17
+
18
+ def test_camelize
19
+ assert_equal 'apiKey' , 'api_key'.camelize
20
+ end
21
+
22
+ def test_build_url
23
+ cp = CafePress::Search.new
24
+ query = { :query => 'donkey', :version => 1 }
25
+ url = cp.send( :build_url , 'Search', query )
26
+ assert url =~ /^http/i
27
+ assert url =~ /\/Search/
28
+ assert url =~ /query=donkey/
29
+ assert url =~ /version=1/
30
+ assert url =~ /apiKey=#{ENV['CPDN_API_KEY']}/
31
+
32
+ end
33
+
34
+ def test_soap_wsdl
35
+ wsdl_url = "http://api.cafepress.com/index.asmx?WSDL"
36
+ soap = SOAP::WSDLDriverFactory.new( wsdl_url ).create_rpc_driver
37
+ end
38
+
39
+ def test_store_lookup
40
+ @site = 'http://api.cafepress.com'
41
+ @store_id = 'rubyhappy'
42
+ @api_key = ENV['CPDN_API_KEY']
43
+ @product_types = ''
44
+ @version = '1'
45
+
46
+ cp = CafePress::Search.new
47
+ query = { :store_id => @store_id ,
48
+ :product_types => @product_types,
49
+ :version => 1 }
50
+ url = cp.send( :build_url , 'StoreLookup', query )
51
+ assert url =~ /^http/i
52
+ assert url =~ /\/StoreLookup/
53
+ assert url =~ /version=1/
54
+ assert url =~ /apiKey=#{ENV['CPDN_API_KEY']}/
55
+ store = cp.store_lookup(query )
56
+ assert_equal CafePress::Store, store.class
57
+ end
58
+
59
+ def test_store_lookup_products
60
+ @site = 'http://api.cafepress.com'
61
+ @store_id = 'rubyhappy'
62
+ @api_key = ENV['CPDN_API_KEY']
63
+ @product_types = ''
64
+ @version = '1'
65
+
66
+ cp = CafePress::Search.new
67
+ query = { :store_id => @store_id ,
68
+ :product_types => @product_types,
69
+ :version => 1 }
70
+ store = cp.store_lookup(query )
71
+ assert_equal CafePress::Store, store.class
72
+ assert_equal 20 , store.products.size
73
+ assert_equal 5 , store.products( { :size => '3XL' }).size
74
+ assert_equal 2 , store.products( { :size => '2XL', :color => 'Black/White' }).size
75
+ end
76
+
77
+ def test_search
78
+ query = { :query => 'donkey', :version => 1 }
79
+ cp = CafePress::Search.new
80
+ results = cp.search(query)
81
+ assert_equal REXML::Document, results.class
82
+ end
83
+ end
@@ -0,0 +1,2 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/cafepress'
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.2
3
+ specification_version: 1
4
+ name: cafepress-alpha
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2007-04-30 00:00:00 -07:00
8
+ summary: Makes the CafePress Web API easy to use!
9
+ require_paths:
10
+ - lib
11
+ email: james@neurogami.com
12
+ homepage: http://cafepress.rubyforge.org
13
+ rubyforge_project: cafepress
14
+ description: Makes the CafePress Web API easy to use!
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - James Britt
31
+ files:
32
+ - Rakefile
33
+ - README.txt
34
+ - CHANGELOG.txt
35
+ - Manifest.txt
36
+ - setup.rb
37
+ - lib/cafepress/version.rb
38
+ - lib/cafepress.rb
39
+ - lib/utils/string.rb
40
+ - test/test_helper.rb
41
+ - test/cafepress_search_test.rb
42
+ test_files:
43
+ - test/cafepress_search_test.rb
44
+ rdoc_options: []
45
+
46
+ extra_rdoc_files: []
47
+
48
+ executables: []
49
+
50
+ extensions: []
51
+
52
+ requirements: []
53
+
54
+ dependencies: []
55
+