test/unit/generic_application_test.rb in xeroizer-2.20.0 vs test/unit/generic_application_test.rb in xeroizer-3.0.0
- old
+ new
@@ -1,26 +1,37 @@
-require 'test_helper'
+require 'unit_test_helper'
class GenericApplicationTest < Test::Unit::TestCase
include TestHelper
- def setup
+ setup do
@headers = {"User-Agent" => "Xeroizer/2.15.5"}
@unitdp = 4
- @client = Xeroizer::GenericApplication.new(CONSUMER_KEY, CONSUMER_SECRET, :default_headers => @headers, :unitdp => @unitdp)
+ @options = {
+ default_headers: @headers,
+ unitdp: @unitdp
+ }
end
- context "initialization" do
+ it "fails when provided an invalid client" do
+ client = "an invalid client"
+ assert_raises Xeroizer::InvalidClientError do
+ Xeroizer::GenericApplication.new(client, {})
+ end
+ end
+
+ context "oauth 2" do
+ setup do
+ client = Xeroizer::OAuth2.new(CLIENT_ID, CLIENT_SECRET, @options)
+ @application = Xeroizer::GenericApplication.new(client, @options)
+ end
+
should "pass default headers" do
- assert_equal(@headers, @client.default_headers)
+ assert_equal(@headers, @application.default_headers)
end
should "pass unitdp value" do
- assert_equal(@unitdp, @client.unitdp)
+ assert_equal(@unitdp, @application.unitdp)
end
-
end
-
end
-
-