shopify-mock 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.
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/.travis.yml +1 -0
- data/Gemfile +4 -0
- data/README.rdoc +61 -0
- data/Rakefile +1 -0
- data/lib/shopify-mock.rb +37 -0
- data/lib/shopify-mock/fixtures.rb +41 -0
- data/lib/shopify-mock/fixtures/articles.json +30 -0
- data/lib/shopify-mock/fixtures/assets.json +136 -0
- data/lib/shopify-mock/fixtures/blogs.json +15 -0
- data/lib/shopify-mock/fixtures/collect.json +11 -0
- data/lib/shopify-mock/fixtures/comments.json +19 -0
- data/lib/shopify-mock/fixtures/count.json +3 -0
- data/lib/shopify-mock/fixtures/countries.json +16 -0
- data/lib/shopify-mock/fixtures/custom_collections.json +14 -0
- data/lib/shopify-mock/fixtures/customer_groups.json +25 -0
- data/lib/shopify-mock/fixtures/customers.json +32 -0
- data/lib/shopify-mock/fixtures/events.json +13 -0
- data/lib/shopify-mock/fixtures/fulfillments.json +35 -0
- data/lib/shopify-mock/fixtures/images.json +12 -0
- data/lib/shopify-mock/fixtures/metafields.json +14 -0
- data/lib/shopify-mock/fixtures/orders.json +141 -0
- data/lib/shopify-mock/fixtures/pages.json +16 -0
- data/lib/shopify-mock/fixtures/product_search_engines.json +8 -0
- data/lib/shopify-mock/fixtures/products.json +114 -0
- data/lib/shopify-mock/fixtures/provinces.json +100 -0
- data/lib/shopify-mock/fixtures/redirects.json +19 -0
- data/lib/shopify-mock/fixtures/script_tags.json +11 -0
- data/lib/shopify-mock/fixtures/shop.json +26 -0
- data/lib/shopify-mock/fixtures/smart_collections.json +21 -0
- data/lib/shopify-mock/fixtures/test.json +3 -0
- data/lib/shopify-mock/fixtures/themes.json +25 -0
- data/lib/shopify-mock/fixtures/transactions.json +13 -0
- data/lib/shopify-mock/fixtures/variants.json +84 -0
- data/lib/shopify-mock/fixtures/webhooks.json +12 -0
- data/lib/shopify-mock/responses.rb +17 -0
- data/lib/shopify-mock/responses/articles.rb +5 -0
- data/lib/shopify-mock/responses/orders.rb +6 -0
- data/lib/shopify-mock/urls.rb +7 -0
- data/lib/shopify-mock/version.rb +3 -0
- data/shopify-mock.gemspec +28 -0
- data/spec/mockify/fixtures_spec.rb +39 -0
- data/spec/mockify/responses/articles_spec.rb +25 -0
- data/spec/mockify/responses/orders_spec.rb +25 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/support/fixture_support.rb +5 -0
- data/spec/support/http_support.rb +11 -0
- data/spec/support/url_support.rb +8 -0
- metadata +126 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"redirects": [
|
3
|
+
{
|
4
|
+
"id": 304339089,
|
5
|
+
"path": "/products.php",
|
6
|
+
"target": "/products"
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"id": 668809255,
|
10
|
+
"path": "/leopard",
|
11
|
+
"target": "/pages/macosx"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"id": 950115854,
|
15
|
+
"path": "/ibook",
|
16
|
+
"target": "/products/macbook"
|
17
|
+
}
|
18
|
+
]
|
19
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"shop": {
|
3
|
+
"name": "Apple Computers",
|
4
|
+
"city": "Cupertino",
|
5
|
+
"address1": "1 Infinite Loop",
|
6
|
+
"zip": "95014",
|
7
|
+
"created_at": "2007-12-31T19:00:00-05:00",
|
8
|
+
"plan_name": "enterprise",
|
9
|
+
"shop_owner": "Steve Jobs",
|
10
|
+
"public": false,
|
11
|
+
"country": "US",
|
12
|
+
"money_with_currency_format": "$ {{amount}} USD",
|
13
|
+
"money_format": "$ {{amount}}",
|
14
|
+
"taxes_included": null,
|
15
|
+
"domain": "shop.apple.com",
|
16
|
+
"id": 690933842,
|
17
|
+
"timezone": "(GMT-05:00) Eastern Time (US & Canada)",
|
18
|
+
"tax_shipping": null,
|
19
|
+
"phone": null,
|
20
|
+
"currency": "USD",
|
21
|
+
"source": null,
|
22
|
+
"province": "CA",
|
23
|
+
"myshopify_domain": "apple.myshopify.com",
|
24
|
+
"email": "steve@apple.com"
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"smart_collections": [
|
3
|
+
{
|
4
|
+
"handle": "smart-ipods",
|
5
|
+
"body_html": "<p>The best selling ipod ever</p>",
|
6
|
+
"title": "Smart iPods",
|
7
|
+
"template_suffix": null,
|
8
|
+
"rules": [
|
9
|
+
{
|
10
|
+
"relation": "equals",
|
11
|
+
"column": "type",
|
12
|
+
"condition": "Cult Products"
|
13
|
+
}
|
14
|
+
],
|
15
|
+
"updated_at": "2008-02-01T19:00:00-05:00",
|
16
|
+
"sort_order": "manual",
|
17
|
+
"id": 482865238,
|
18
|
+
"published_at": "2008-02-01T19:00:00-05:00"
|
19
|
+
}
|
20
|
+
]
|
21
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"themes": [
|
3
|
+
{
|
4
|
+
"name": "Comfort",
|
5
|
+
"created_at": "2011-09-06T11:50:04-04:00",
|
6
|
+
"updated_at": "2011-09-06T11:50:04-04:00",
|
7
|
+
"role": "main",
|
8
|
+
"id": 828155753
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"name": "Speed",
|
12
|
+
"created_at": "2011-09-06T11:50:04-04:00",
|
13
|
+
"updated_at": "2011-09-06T11:50:04-04:00",
|
14
|
+
"role": "mobile",
|
15
|
+
"id": 976877075
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"name": "Sandbox",
|
19
|
+
"created_at": "2011-09-06T11:50:04-04:00",
|
20
|
+
"updated_at": "2011-09-06T11:50:04-04:00",
|
21
|
+
"role": "unpublished",
|
22
|
+
"id": 752253240
|
23
|
+
}
|
24
|
+
]
|
25
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
{
|
2
|
+
"variants": [
|
3
|
+
{
|
4
|
+
"price": "199.00",
|
5
|
+
"position": 1,
|
6
|
+
"created_at": "2011-09-06T11:50:04-04:00",
|
7
|
+
"title": "Pink",
|
8
|
+
"requires_shipping": true,
|
9
|
+
"updated_at": "2011-09-06T11:50:04-04:00",
|
10
|
+
"inventory_policy": "continue",
|
11
|
+
"compare_at_price": null,
|
12
|
+
"inventory_quantity": 10,
|
13
|
+
"inventory_management": "shopify",
|
14
|
+
"taxable": true,
|
15
|
+
"id": 808950810,
|
16
|
+
"grams": 200,
|
17
|
+
"sku": "IPOD2008PINK",
|
18
|
+
"option1": "Pink",
|
19
|
+
"option2": null,
|
20
|
+
"fulfillment_service": "manual",
|
21
|
+
"option3": null
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"price": "199.00",
|
25
|
+
"position": 2,
|
26
|
+
"created_at": "2011-09-06T11:50:04-04:00",
|
27
|
+
"title": "Red",
|
28
|
+
"requires_shipping": true,
|
29
|
+
"updated_at": "2011-09-06T11:50:04-04:00",
|
30
|
+
"inventory_policy": "continue",
|
31
|
+
"compare_at_price": null,
|
32
|
+
"inventory_quantity": 20,
|
33
|
+
"inventory_management": "shopify",
|
34
|
+
"taxable": true,
|
35
|
+
"id": 49148385,
|
36
|
+
"grams": 200,
|
37
|
+
"sku": "IPOD2008RED",
|
38
|
+
"option1": "Red",
|
39
|
+
"option2": null,
|
40
|
+
"fulfillment_service": "manual",
|
41
|
+
"option3": null
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"price": "199.00",
|
45
|
+
"position": 3,
|
46
|
+
"created_at": "2011-09-06T11:50:04-04:00",
|
47
|
+
"title": "Green",
|
48
|
+
"requires_shipping": true,
|
49
|
+
"updated_at": "2011-09-06T11:50:04-04:00",
|
50
|
+
"inventory_policy": "continue",
|
51
|
+
"compare_at_price": null,
|
52
|
+
"inventory_quantity": 30,
|
53
|
+
"inventory_management": "shopify",
|
54
|
+
"taxable": true,
|
55
|
+
"id": 39072856,
|
56
|
+
"grams": 200,
|
57
|
+
"sku": "IPOD2008GREEN",
|
58
|
+
"option1": "Green",
|
59
|
+
"option2": null,
|
60
|
+
"fulfillment_service": "manual",
|
61
|
+
"option3": null
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"price": "199.00",
|
65
|
+
"position": 4,
|
66
|
+
"created_at": "2011-09-06T11:50:04-04:00",
|
67
|
+
"title": "Black",
|
68
|
+
"requires_shipping": true,
|
69
|
+
"updated_at": "2011-09-06T11:50:04-04:00",
|
70
|
+
"inventory_policy": "continue",
|
71
|
+
"compare_at_price": null,
|
72
|
+
"inventory_quantity": 40,
|
73
|
+
"inventory_management": "shopify",
|
74
|
+
"taxable": true,
|
75
|
+
"id": 457924702,
|
76
|
+
"grams": 200,
|
77
|
+
"sku": "IPOD2008BLACK",
|
78
|
+
"option1": "Black",
|
79
|
+
"option2": null,
|
80
|
+
"fulfillment_service": "manual",
|
81
|
+
"option3": null
|
82
|
+
}
|
83
|
+
]
|
84
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ShopifyAPI
|
2
|
+
module Mock
|
3
|
+
class Response
|
4
|
+
class << self
|
5
|
+
def register(method, resource, response)
|
6
|
+
FakeWeb.register_uri(
|
7
|
+
method, /#{SHOPIFY_MOCK_SHOP_BASE_URL}#{resource}/,
|
8
|
+
:body => response
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'shopify-mock/responses/orders'
|
17
|
+
require 'shopify-mock/responses/articles'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "shopify-mock/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "shopify-mock"
|
7
|
+
s.version = ShopifyMock::VERSION
|
8
|
+
s.authors = ["Travis Haynes"]
|
9
|
+
s.email = ["travis.j.haynes@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/travishaynes/shopify-mock"
|
11
|
+
s.summary = %q{Serves Shopify resources via FakeWeb for easily testing Shopify apps.}
|
12
|
+
s.description = %q{This gem is used for testing Shopify apps without having to actually connect to
|
13
|
+
Shopify to develop the application.
|
14
|
+
|
15
|
+
You can use this gem explicitely for testing, or you can also use it in your
|
16
|
+
development environment to speed things up when fiddling around in the web
|
17
|
+
browser, or in the console.}
|
18
|
+
|
19
|
+
s.rubyforge_project = "shopify-mock"
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
|
26
|
+
s.add_dependency("fakeweb", [">= 1.3.0"])
|
27
|
+
s.add_dependency("rspec", [">= 2.6.0"])
|
28
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ShopifyAPI::Mock::Fixtures do
|
4
|
+
|
5
|
+
context "when given a valid fixture name" do
|
6
|
+
it "should return the contents of a fixture" do
|
7
|
+
@json = read_fixture :test
|
8
|
+
ShopifyAPI::Mock::Fixtures.read(:test).should eq @json
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "when given an invalid fixture name" do
|
13
|
+
it "should raise an error" do
|
14
|
+
expect { ShopifyAPI::Mock::Fixtures.read(:brown_chicken_brown_cow) }.should raise_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "custom fixtures" do
|
19
|
+
before { @json = '{ "count": 10 }' }
|
20
|
+
describe "#use" do
|
21
|
+
context "with custom fixture for content" do
|
22
|
+
it "should override default fixture" do
|
23
|
+
ShopifyAPI::Mock::Fixtures.read(:orders).should eq read_fixture :orders
|
24
|
+
ShopifyAPI::Mock::Fixtures.use :count, @json
|
25
|
+
ShopifyAPI::Mock::Fixtures.read(:count).should eq @json
|
26
|
+
end
|
27
|
+
end
|
28
|
+
context "with :default for content" do
|
29
|
+
it "should reset back to default texture" do
|
30
|
+
ShopifyAPI::Mock::Fixtures.use :count, @json
|
31
|
+
ShopifyAPI::Mock::Fixtures.read(:count).should eq @json
|
32
|
+
ShopifyAPI::Mock::Fixtures.use :count, :default
|
33
|
+
ShopifyAPI::Mock::Fixtures.read(:orders).should eq read_fixture :orders
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe :articles do
|
4
|
+
|
5
|
+
describe "GET /articles.json" do
|
6
|
+
before do
|
7
|
+
@json = read_fixture :articles
|
8
|
+
@response = get :articles
|
9
|
+
end
|
10
|
+
it "should return articles.json fixture" do
|
11
|
+
@response.body.should eq @json
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "GET /articles/count.json" do
|
16
|
+
before do
|
17
|
+
@json = read_fixture :count
|
18
|
+
@response = get [:articles, :count]
|
19
|
+
end
|
20
|
+
it "should return count json" do
|
21
|
+
@response.body.should eq @json
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe :orders do
|
4
|
+
|
5
|
+
describe "GET /orders.json" do
|
6
|
+
before do
|
7
|
+
@json = read_fixture :orders
|
8
|
+
@response = get :orders
|
9
|
+
end
|
10
|
+
it "should return orders.json fixture" do
|
11
|
+
@response.body.should eq @json
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "GET /orders/count.json" do
|
16
|
+
before do
|
17
|
+
@json = read_fixture :count
|
18
|
+
@response = get [:orders, :count]
|
19
|
+
end
|
20
|
+
it "should return count json" do
|
21
|
+
@response.body.should eq @json
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# require the ShopifyMock library
|
2
|
+
require File.expand_path("../../lib/shopify-mock", __FILE__)
|
3
|
+
|
4
|
+
# load support files
|
5
|
+
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each {|f| load f}
|
6
|
+
|
7
|
+
# enable ShopifyMock and disable real-world Internet access
|
8
|
+
ShopifyAPI::Mock.enabled = true
|
9
|
+
ShopifyAPI::Mock.allow_internet = false
|
@@ -0,0 +1,11 @@
|
|
1
|
+
def get(path = [], options = {}, user = SHOPIFY_MOCK_SHOP[:api_key], pass = SHOPIFY_MOCK_SHOP[:secret])
|
2
|
+
path = parse_path(path)
|
3
|
+
options = parse_options(options)
|
4
|
+
path = "#{path}?#{options}" unless options.nil?
|
5
|
+
|
6
|
+
http = Net::HTTP.new(SHOPIFY_MOCK_SHOP[:domain], 443)
|
7
|
+
http.use_ssl = true
|
8
|
+
req = Net::HTTP::Get.new path
|
9
|
+
req.basic_auth user, pass
|
10
|
+
http.request req
|
11
|
+
end
|