spec/rallycat/update_spec.rb in rallycat-0.4.0 vs spec/rallycat/update_spec.rb in rallycat-0.4.1

- old
+ new

@@ -1,15 +1,14 @@ require 'spec_helper' describe Rallycat::Update do - before do - auth_responder = lambda do |env| - # 'https://rally1.rallydev.com/slm/webservice/current/user' - [200, {}, ['<foo>bar</foo>']] - end + def get_post_request(responder) + responder.requests.detect {|request| request.post? } + end - Artifice.activate_with auth_responder do + before do + Artifice.activate_with RallyAuthResponder.new do @api = Rallycat::Connection.new('foo.bar@rallycat.com', 'password').api end end context "Tasks" do @@ -19,17 +18,17 @@ responder = RallyTaskUpdateResponder.new Artifice.activate_with responder do task_num = "TA6666" update = Rallycat::Update.new(@api) - update.task(task_num, state: "In-Progress") + update.task(task_num, :state => "In-Progress") end - post_request = responder.requests[2] # this is the request that actually updates the task - post_request.should be_post - post_request.url.should == 'https://rally1.rallydev.com/slm/webservice/1.17/task/12345' + post_request = get_post_request(responder) + post_request.path.should == '/slm/webservice/1.17/task/12345' + body = post_request.body.tap(&:rewind).read body.should include('<Blocked>false</Blocked>') body.should include('<State>In-Progress</State>') end @@ -38,18 +37,18 @@ responder = RallyTaskUpdateResponder.new Artifice.activate_with responder do task_num = "TA6666" update = Rallycat::Update.new(@api) - message = update.task(task_num, state: "In-Progress", blocked: true) + message = update.task(task_num, :state => "In-Progress", :blocked => true) message.should include('Task (TA6666) was set to "In-Progress"') end - post_request = responder.requests[2] # this is the request that actually updates the task - post_request.should be_post - post_request.url.should == 'https://rally1.rallydev.com/slm/webservice/1.17/task/12345' + post_request = get_post_request(responder) + post_request.path.should == '/slm/webservice/1.17/task/12345' + body = post_request.body.tap(&:rewind).read body.should include('<Blocked>true</Blocked>') body.should include('<State>In-Progress</State>') end @@ -57,17 +56,17 @@ responder = RallyTaskUpdateResponder.new Artifice.activate_with responder do task_num = "TA6666" update = Rallycat::Update.new(@api) - message = update.task(task_num, state: "Completed") + message = update.task(task_num, :state => "Completed") end - post_request = responder.requests[2] # this is the request that actually updates the task - post_request.should be_post - post_request.url.should == 'https://rally1.rallydev.com/slm/webservice/1.17/task/12345' + post_request = get_post_request(responder) + post_request.path.should == '/slm/webservice/1.17/task/12345' + body = post_request.body.tap(&:rewind).read body.should include('<State>Completed</State>') body.should include('<ToDo>0.0</ToDo>') end @@ -76,36 +75,36 @@ responder = RallyTaskUpdateResponder.new Artifice.activate_with responder do task_num = "TA6666" update = Rallycat::Update.new(@api) - message = update.task(task_num, blocked: true) + message = update.task(task_num, :blocked => true) message.should include('Task (TA6666) was blocked.') end - post_request = responder.requests[2] # this is the request that actually updates the task - post_request.should be_post - post_request.url.should == 'https://rally1.rallydev.com/slm/webservice/1.17/task/12345' + post_request = get_post_request(responder) + post_request.path.should == '/slm/webservice/1.17/task/12345' + body = post_request.body.tap(&:rewind).read body.should include('<Blocked>true</Blocked>') end it 'assigns the owner' do responder = RallyTaskUpdateResponder.new Artifice.activate_with responder do task_num = "TA6666" update = Rallycat::Update.new(@api) - message = update.task(task_num, state: 'Completed', owner: 'Freddy Fender') + message = update.task(task_num, :state => 'Completed', :owner => 'Freddy Fender') message.should include('Task (TA6666) was assigned to "Freddy Fender"') end - post_request = responder.requests[4] # this is the request that actually updates the task - post_request.should be_post - post_request.url.should == 'https://rally1.rallydev.com/slm/webservice/1.17/task/12345' + post_request = get_post_request(responder) + post_request.path.should == '/slm/webservice/1.17/task/12345' + body = post_request.body.tap(&:rewind).read body.should include('<State>Completed</State>') body.should include('<Owner>fred.fender@testing.com</Owner>') end end @@ -116,11 +115,11 @@ Artifice.activate_with responder do task_num = "TA6666" update = Rallycat::Update.new(@api) lambda { - update.task(task_num, state: 'Completed', owner: 'Norman Notreal') + update.task(task_num, :state => 'Completed', :owner => 'Norman Notreal') }.should raise_error(Rallycat::UserNotFound, 'User (Norman Notreal) does not exist.') end end it 'raises when the task could not be found' do @@ -129,11 +128,10 @@ Artifice.activate_with responder do task_num = "TA6666" update = Rallycat::Update.new(@api) lambda { - update.task(task_num, state: 'Completed') + update.task(task_num, :state => 'Completed') }.should raise_error(Rallycat::TaskNotFound, 'Task (TA6666) does not exist.') end - end end