diff options
| author | Zack Hobson | 2013-12-27 13:19:57 -0800 |
|---|---|---|
| committer | Zack Hobson | 2013-12-27 13:19:57 -0800 |
| commit | 8e2e788909c6a634976c80eeb75c79af8f8ab734 (patch) | |
| tree | 8314e9ad539476d0e327ad20abde667203f4115f /test | |
| parent | 89867bd84610d6d5622540a7e26b6c3467d632bf (diff) | |
| download | hcl-8e2e788909c6a634976c80eeb75c79af8f8ab734.tar.bz2 | |
pass http client into instance commands
Diffstat (limited to 'test')
| -rw-r--r-- | test/command_test.rb | 4 | ||||
| -rw-r--r-- | test/day_entry_test.rb | 10 | ||||
| -rw-r--r-- | test/task_test.rb | 6 | ||||
| -rw-r--r-- | test/test_helper.rb | 3 |
4 files changed, 12 insertions, 11 deletions
diff --git a/test/command_test.rb b/test/command_test.rb index 56c7d93..a0cdca1 100644 --- a/test/command_test.rb +++ b/test/command_test.rb @@ -69,7 +69,7 @@ class CommandTest < HCl::TestCase project: HCl::Project.new(id:456, name:'App', client:'Bob', code:'b') ) HCl::Task.expects(:find).with('456','123').returns(task) - task.expects(:start).with(starting_time:nil, note:'do stuff') + task.expects(:start).with(http, starting_time:nil, note:'do stuff') start *%w[ 456 123 do stuff ] end @@ -106,7 +106,7 @@ class CommandTest < HCl::TestCase def test_note entry = stub HCl::DayEntry.expects(:with_timer).returns(entry) - entry.expects(:append_note).with('hi world') + entry.expects(:append_note).with(http, 'hi world') note 'hi world' end diff --git a/test/day_entry_test.rb b/test/day_entry_test.rb index 5b53463..a685bc0 100644 --- a/test/day_entry_test.rb +++ b/test/day_entry_test.rb @@ -25,19 +25,19 @@ class DayEntryTest < HCl::TestCase def test_toggle entry = HCl::DayEntry.new(id:123) register_uri(:get, '/daily/timer/123', {note:'hi'}) - entry.toggle + entry.toggle http end def test_cancel_success entry = HCl::DayEntry.new(id:123) register_uri(:delete, '/daily/delete/123') - assert entry.cancel + assert entry.cancel http end def test_cancel_failure entry = HCl::DayEntry.new(id:123) HCl::Net.expects(:delete).raises(HCl::HarvestMiddleware::Failure) - assert !entry.cancel + assert !entry.cancel(http) end def test_to_s @@ -49,14 +49,14 @@ class DayEntryTest < HCl::TestCase def test_append_note entry = HCl::DayEntry.new(:id => '1', :notes => 'yourmom.', :hours => '1.0') HCl::Net.stubs(:post) - entry.append_note('hi world') + entry.append_note(http, 'hi world') assert_equal "yourmom.\nhi world", entry.notes end def test_append_note_to_empty entry = HCl::DayEntry.new(:id => '1', :notes => nil, :hours => '1.0') HCl::Net.stubs(:post) - entry.append_note('hi world') + entry.append_note(http, 'hi world') assert_equal 'hi world', entry.notes end end diff --git a/test/task_test.rb b/test/task_test.rb index 3deb620..b224ed3 100644 --- a/test/task_test.rb +++ b/test/task_test.rb @@ -23,7 +23,7 @@ class TaskTest < HCl::TestCase task = HCl::Task.new(id:1, project:HCl::Project.new({id:2})) register_uri(:post, '/daily/add', { note:'good stuff', hours:0.2, project_id:2, task_id:1, spent_at: Date.today}) - entry = task.add(note:'good stuff', starting_time:0.2) + entry = task.add(http, note:'good stuff', starting_time:0.2) assert_equal 'good stuff', entry.note end @@ -32,7 +32,7 @@ class TaskTest < HCl::TestCase register_uri(:post, '/daily/add', { note:'good stuff', timer_started_at:DateTime.now, hours:0.2, project_id:2, task_id:1, spent_at: Date.today}) - entry = task.start(note:'good stuff', starting_time:0.2) + entry = task.start(http, note:'good stuff', starting_time:0.2) assert_equal 'good stuff', entry.note end @@ -41,7 +41,7 @@ class TaskTest < HCl::TestCase register_uri(:post, '/daily/add', {id:123, note:'woot'}) register_uri(:get, '/daily/timer/123', {note:'good stuff', hours:0.2, project_id:2, task_id:1, spent_at: Date.today}) - entry = task.start(note:'good stuff', starting_time:0.2) + entry = task.start(http, note:'good stuff', starting_time:0.2) assert_equal 'good stuff', entry.note end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 47d3517..33cf499 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -28,9 +28,10 @@ require 'fakeweb' Dir[File.dirname(__FILE__) + '/ext/*.rb'].each { |ext| require ext } class HCl::TestCase < MiniTest::Unit::TestCase + attr_reader :http def setup FakeWeb.allow_net_connect = false - HCl::Net.configure \ + @http = HCl::Net.configure \ 'login' => 'bob', 'password' => 'secret', 'subdomain' => 'bobclock', |
