From 3aa529bc7f872e3287be10ad44ca210bea2d8f99 Mon Sep 17 00:00:00 2001 From: Yomi Colledge Date: Thu, 5 Aug 2010 02:02:47 +0100 Subject: [PATCH] Refactored specs to make more readable as well as removing non essentai specs. --- spec/controllers/parking_controller_spec.rb | 33 +++++++++++---------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/spec/controllers/parking_controller_spec.rb b/spec/controllers/parking_controller_spec.rb index 3678cbb2..9240637b 100644 --- a/spec/controllers/parking_controller_spec.rb +++ b/spec/controllers/parking_controller_spec.rb @@ -3,7 +3,7 @@ describe ParkingController do describe "GET, tickets" do context "requesting a list of tickets" do - it "should do a search using the LightHouse API for tags" do + it "can get tickets from Lighthouse" do @resource = mock_model(Resource, :name => "baphled", :project => '50164').as_null_object Resource.stub!(:find).and_return @resource @resource.should_receive(:tickets).with("feature") @@ -13,7 +13,7 @@ end describe "GET, new" do - it "should create a new resource model" do + it "creates a new resource model" do Resource.should_receive(:new) get :new end @@ -31,12 +31,12 @@ post :create end - it "should save the new resource" do + it "saves the new resource" do @resource.should_receive(:save) post :create, {:resource => @resource} end - it "should redirect to the parking index view" do + it "redirects to the parking page" do @resource.stub!(:save).and_return true post :create, {:resource => @resource} response.should redirect_to parking_index_path @@ -48,46 +48,47 @@ before(:each) do Resource.stub!(:find).and_return mock_model(Resource, :id => 1).as_null_object end - context "imports successful" do - it "should get each tickets content and create a parked item" do + context "successfully imports" do + it "creates a parked items from tickets" do LightHouse.should_receive(:create) post :import, {:lighthouse =>{:ticket_id => ["9"]}, :resource => {:id => 1}} end - it "should display a flash message" do + it "displays a flash message" do post :import, {:lighthouse =>{:ticket_id => ["9"]}, :resource => {:id => 1}} - flash[:notice].should contain 'Parked tickets' + flash[:notice].should_not be_empty end - it "should redirect to the parking index page" do + it "redirects to the parking page" do post :import, {:lighthouse =>{:ticket_id => ["9"]}, :resource => {:id => 1}} response.should redirect_to parking_index_path end - it "should save the tickets content body" do + it "saves the ticket's content body" do post :import, {:lighthouse =>{:ticket_id => ["9"]}, :resource => {:id => 1}} Resource.first.body.should_not be_nil end - it "should save the tickets title" do + it "saves the ticket's title" do post :import, {:lighthouse =>{:ticket_id => ["9"]}, :resource => {:id => 1}} Resource.first.title.should_not be_nil end end - context "imports fail" do + context "failing imports" do + context "with one resource" do before(:each) do LightHouse.stub!(:create).and_return false post :import, {:lighthouse =>{:ticket_id => ["9", "41"]}, :resource => {:id => 1}} end - it "should display a flash message" do + it "displays a flash message" do flash[:error].should contain "Unable to save tickets" end - it "should render the tickets page again" do + it "displays the tickets page" do response.should redirect_to parking_index_path end end @@ -95,9 +96,9 @@ end describe "GET, unique-resource-name" do - context "is not unique" do + context "not unique" do before(:each) do - Resource.create({:name => 'baphled', :project => '50164'}) + Resource.make end it "returns an error message" do