diff options
| author | Zack Hobson | 2013-12-22 23:28:00 -0800 | 
|---|---|---|
| committer | Zack Hobson | 2013-12-22 23:28:00 -0800 | 
| commit | 11310cefb8206487337b8040f9ceb70e570a06f7 (patch) | |
| tree | f9b3624e4210616e48108ff650fa229c125d894d /test/net_test.rb | |
| parent | d315a241dbd6c959085b26a413fc5e40683d63f0 (diff) | |
| parent | b8d0ef7022541999c2267fc7937f2a60e0da602c (diff) | |
| download | hcl-11310cefb8206487337b8040f9ceb70e570a06f7.tar.bz2 | |
Merge pull request #46 from zenhob/faraday
Switch to a Faraday-based JSON API client for Harvest.
Diffstat (limited to 'test/net_test.rb')
| -rw-r--r-- | test/net_test.rb | 41 | 
1 files changed, 41 insertions, 0 deletions
| diff --git a/test/net_test.rb b/test/net_test.rb new file mode 100644 index 0000000..c4e39e1 --- /dev/null +++ b/test/net_test.rb @@ -0,0 +1,41 @@ +require 'test_helper' + +class NetTest < HCl::TestCase + +  def setup +    FakeWeb.allow_net_connect = false +    HCl::Net.configure \ +      'login' => 'bob', +      'password' => 'secret', +      'subdomain' => 'bobclock', +      'ssl' => true +  end + +  def test_configure +    assert_equal 'bob', HCl::Net.login +    assert_equal 'secret', HCl::Net.password +    assert_equal 'bobclock', HCl::Net.subdomain +    assert_equal true, HCl::Net.ssl +  end + +  def test_http_get +    FakeWeb.register_uri(:get, "https://bob:secret@bobclock.harvestapp.com/foo", +                         :body => 'gotten!'.inspect) +    body = HCl::Net.get 'foo' +    assert_equal 'gotten!', body +  end + +  def test_http_post +    FakeWeb.register_uri(:post, "https://bob:secret@bobclock.harvestapp.com/foo", +                         :body => 'posted!'.inspect) +    body = HCl::Net.post 'foo', {pizza:'taco'} +    assert_equal 'posted!', body +  end + +  def test_http_delete +    FakeWeb.register_uri(:delete, "https://bob:secret@bobclock.harvestapp.com/foo", +                         :body => 'wiped!'.inspect) +    body = HCl::Net.delete 'foo' +    assert_equal 'wiped!', body +  end +end | 
