浏览代码

Added a simple test and the first entry in the changelog.

Dennis Theisen 15 年之前
父节点
当前提交
9d692f0634
共有 3 个文件被更改,包括 22 次插入2 次删除
  1. 2 0
      CHANGELOG
  2. 13 2
      test/shopify_api_test.rb
  3. 7 0
      test/test_helper.rb

+ 2 - 0
CHANGELOG

@@ -0,0 +1,2 @@
+1.0.0
+  - extracting ShopifyAPI from Shopify into Gem

+ 13 - 2
test/shopify_api_test.rb

@@ -1,7 +1,18 @@
 require 'test_helper'
 
 class ShopifyApiTest < Test::Unit::TestCase
-  def test_something_for_real
-    flunk "hey buddy, you should probably rename this file and start testing for real"
+  def setup
+    @session_no_token = ShopifyAPI::Session.new("testshop.myshopify.com")
+    @session = ShopifyAPI::Session.new("testshop.myshopify.com", "any-token")
   end
+  
+  
+  def test_session_not_valid_without_token
+    assert_not @session_no_token.valid?
+  end
+  
+  def test_session_is_valid_with_any_token
+    assert @session.valid?
+  end
+  
 end

+ 7 - 0
test/test_helper.rb

@@ -5,5 +5,12 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
 $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
 require 'shopify_api'
 
+# setup ShopifyAPI with fake api_key and secret
+ShopifyAPI::Session.setup(:api_key => "API Test key", :secret => "API Test secret")
+
 class Test::Unit::TestCase
+  # Custom Assertions
+  def assert_not(expression)
+    assert_block("Expected <#{expression}> to be false!") { not expression }
+  end  
 end