test/streambot/test_http.rb in streambot-0.3.0 vs test/streambot/test_http.rb in streambot-0.4.0

- old
+ new

@@ -3,25 +3,26 @@ module StreamBot # test for http wrapper class class TestHttp < StreamBot::BaseTest # setup def setup - @http = StreamBot::HTTP.new - # override auth - @auth = {:username=>'test', :password=>'test'} - stub_request(:post, "http://test:test@testing.com/path/to/data").to_return(:body => @auth) + super + WebMock.disable_net_connect! + @http = StreamBot::HTTP.new(@params['http']) + stub_request(:post, "http://#{@params['http']['username']}:#{@params['http']['password']}@api.twitter.com/path/to/data").to_return(:body => "response") end + # test a post with basic authentication + def test_post + res = @http.post('/path/to/data',nil) + assert_not_nil(res) + assert_equal("response", res) + end + # nil all variables def teardown @http = nil + WebMock.allow_net_connect! end - # test a post with basic authentication - def test_post - WebMock.disable_net_connect! - res = @http.post_with_auth(@auth, 'http://testing.com/path/to/data') - assert_not_nil(res) - assert_equal(@auth, res.body) - end end end \ No newline at end of file