瀏覽代碼

Add tests for articles

Having boxen problems, but this Should Work™
Lydia Krupp-Hunter 12 年之前
父節點
當前提交
071da026b3
共有 2 個文件被更改,包括 67 次插入0 次删除
  1. 28 0
      test/article_test.rb
  2. 39 0
      test/fixtures/articles.json

+ 28 - 0
test/article_test.rb

@@ -0,0 +1,28 @@
+require 'test_helper'
+
+class ArticleTest < Test::Unit::TestCase
+
+  def test_get_article
+    fake "articles/6242736", :method => :get, :body => load_fixture('article')
+    article = ShopifyAPI::Article.find(6242736)
+    assert_equal "First Post", article.title
+  end
+
+  def test_get_articles
+    fake "articles", :method => :get, :body => load_fixture('article')
+    articles = ShopifyAPI::Article.all
+    asert_equal 3, articles.length
+  end
+
+  def test_get_articles_namespaced
+    fake "blogs/1008414260/articles", :method => :get, :body => load_fixture('article')
+    articles = ShopifyAPI::Article.find(:all, :params => {:blog_id => 1008414260})
+    asert_equal 3, articles.length
+  end
+
+  def test_get_article_namespaced
+    fake "blogs/1008414260/articles/6242736", :method => :get, :body => load_fixture('article')
+    articles = ShopifyAPI::Article.find(6242736, :params => {:blog_id => 1008414260})
+    assert_equal "First Post", article.title
+  end
+end

+ 39 - 0
test/fixtures/articles.json

@@ -0,0 +1,39 @@
+{
+  "articles": [{
+    "author": "Shopify",
+    "blog_id": 1008414260,
+    "body_html": null,
+    "created_at": "2012-07-06T13:57:28-04:00",
+    "id": 6242736,
+    "published_at": "2012-07-06T13:57:28-04:00",
+    "summary_html": null,
+    "title": "First Post",
+    "updated_at": "2012-07-06T13:57:51-04:00",
+    "user_id": null,
+    "tags": "consequuntur, cupiditate, repellendus"
+  }, {
+    "author": "development shop",
+    "blog_id": 1008414260,
+    "body_html": null,
+    "created_at": "2013-04-21T18:10:35-04:00",
+    "id": 7739673,
+    "published_at": "2013-04-21T18:10:22-04:00",
+    "summary_html": null,
+    "title": "My second blog post",
+    "updated_at": "2013-04-21T18:10:35-04:00",
+    "user_id": 2221540,
+    "tags": ""
+  }, {
+    "author": "development shop",
+    "blog_id": 1008414260,
+    "body_html": null,
+    "created_at": "2013-04-21T18:11:19-04:00",
+    "id": 7739683,
+    "published_at": "2013-04-21T18:10:45-04:00",
+    "summary_html": null,
+    "title": "50% off sale",
+    "updated_at": "2013-04-21T18:11:19-04:00",
+    "user_id": 2221540,
+    "tags": ""
+  }]
+}