You mention not driving your Ford Ranger often... is it possible that you recently had to jump start your truck, or replaced it's battery? If so, it is very possible that the ECU (engine control unit) reset the OBDII Emission Monitors. You will need to complete a "drive cycle" in order to make the monitors READY or COMPLETE again.
Not having driven your Ford Ranger much the day of the smog test does not matter. Back in the days (during the BAR-97 smog inspection) it was important to make sure your vehicle was properly warmed up in order for exhaust emissions be as low as possible. The new OIS-DAD smog test system does not test exhaust emissions. The complete focus is on your Ford's check engine light, existing trouble codes, and emission monitor readiness.
Below we detail a Ford Ranger Drive Cycle. If the only reason your truck failed the smog test was because the emission monitors were not ready, completing the drive cycle below will get your Ford to pass the smog test. If trouble codes exist or the check engine light is ON, the emission monitors will not become READY until the faults which are triggering the trouble codes are repaired, the ECU reset, and a drive cycle then be completed.
We'd like to say purchase a scan tool and retrieve the trouble codes (if any are present) but chances are without some technical automotive repair knowledge it will be unlikely that you find the root cause of the faults and/or repair them yourself. This is best left to the smog repair stations unless you are cable of repair diagnosis.
If your Ford Ranger's failure is more than simply having to complete a drive cycle to get the emission monitors to become READY or COMPLETE, and you feel competent enough to find the faults and repair them yourself feel free to purchase a scan tool from a local auto parts store and pull the trouble codes. The trouble codes will indicate which emission system has a fault. From there you can go to the system in question and test individual components (sensors/solenoid) for functionality.
Ford Ranger Drive Cycle
The following procedure is designed to complete the OBDII monitors required to get your Ford Ranger to pass the OBDII Monitors portion of the smog check, also known of the I/M readiness test. You may use a scan tool in order to monitor the status of the emission monitors as your Ford Ranger is being driven.
Take extra caution when performing this drive cycle on public roadways. If you feel you might be unable to safely perform the Ford Ranger Drive Cycle below, please seek assistance from a qualified auto smog and repair center.
Drive Cycle Recommendations:
Your Ford Ranger's emission monitors (readiness flags) will complete quicker when using a "steady foot" driving style during cruise or acceleration modes.
Your trucks fuel tank level must be between 1/2 and 3/4 full during the drive cycle. The EVAP monitor will not run if fuel levels are too low or too high.
The Evaporative Monitor can only operate during the first 30 minutes of engine operation. During the EVAP portion of the drive cycle, drive in a smooth fashion to minimize "fuel slosh".
A. Start your truck. Idle the vehicle for 15 seconds, and then drive at 40 MPH until engine coolant temperature is at least 170°F, which is normal engine operating temperature. 10 to 15 minutes of drive will achieve this.
B. HEGO Monitor - Cruise at 40 MPH for up to 4 minutes.
C. EVAP Monitor - Cruise at 45 to 65 MPH for 10 minutes (avoid sharp turns and hills).
D. Catalyst Monitor - Next, drive your Ford Focus in stop and go traffic conditions. Include five different constant cruise speeds, ranging from 25 to 45 MPH over a 10 minute period.
E. EGR Monitor - From a stop, accelerate to 45 MPH at 1/2 to 3/4 throttle. Repeat this pattern 3 times.
F. SEC AIR/CCM (Continuous Monitors) - Bring your Ford Ranger to a stop. Idle with transmission in drive (neutral for M/T) for 2 minutes.
G. CCM (Transmission) - If your Ford has a manual transmission, go ahead and accelerate from 0 to 50 MPH, continue to step (H). For Automatic Transmissions, start from a stop and in overdrive, then moderately accelerate to 50 MPH and cruise for at least 15 seconds. Stop the vehicle and repeat without overdrive to 40 MPH cruising for at least 30 seconds. While at 40 MPH, activate overdrive and accelerate to 50 MPH and cruise for at least 15 seconds. Stop for at least 20 seconds and repeat step 10 five times.
H. Misfire & Fuel Monitors - From a stop, accelerate to 65 MPH. Decelerate at closed throttle until 40 MPH (no brakes). Repeat this 3 times.
I. Readiness Check - If using a scan tool, go ahead and access the ON-Board System Readiness (OBDII monitor status) function on the scan tool. Determine whether all emission monitors have completed.
J. Evap Monitor "Bypass" - Park vehicle for a minimum of 8 hours. Repeat steps A through I.