Difference between Fourier-Transform and FFT of rectangular pulse
Assuming that the relevant portion of a continuous-time signal $x(t)$ is inside (or has been shifted to) the interval $[0,T]$, the DFT of a sampled version of the signal approximates the continuous-time Fourier transform (CTFT) in the following way:

$$\begin{align}X(f)&amp;=\int_{-\infty}^{\infty}x(t)e^{-j2\pi ft}dt\\&amp;\stackrel{\textrm{truncation}}{\approx}\int_{0}^{T}x(t)e^{-j2\pi ft}dt\\&amp;\stackrel{\textrm{sampling}}{\approx}\sum_{n=0}^{N-1}x(n\Delta t)e^{-j2\pi f n\Delta t}\Delta t\tag{1}\end{align}$$

with $T=N\Delta t$.
From $(1)$ with $\Delta t=T/N$ and with $f=k/T$, a sampled version of $X(f)$ can be approximated by

$$X\left(\frac{k}{T}\right)\approx \Delta t \sum_{n=0}^{N-1}x(n\Delta t)e^{-j2\pi k n/N}=\Delta t \cdot X_d[k]\tag{2}$$

where $X_d[k]$ is the length $N$ DFT of $x_d[n]=x(n\Delta t)$.

Note that for time-limited signals, the truncation error can be made zero, and for perfectly band-limited signals, the sampling error can be made zero. Since a signal cannot be time-limited and band-limited at the same time, there's always at least one of the two errors present. In practice, you usually have to deal with both types of errors.

The following Matlab/Octave code shows an example:

Fs = 1e3;   % sampling frequency
Ts = 1/Fs;
T1 = 0.1;
T2 = 2;
tgrid = 0:Ts:T2;
N = length(tgrid);
x = zeros(1,N);
x( find( tgrid &lt;= T1 ) ) = 1;
fgrid = (0:N-1)*Fs/N;

% analytic continuous-time Fourier transform
X = T * sin( T*fgrid*pi ) ./ (T*fgrid*pi) .* exp( -1i*pi*fgrid*T );
X(1) = T;

% DFT approximation
X2 = fft(x,N) * Ts;

plot( fgrid,abs(X),fgrid,abs(X2),'r' )
axis([0,Fs/2,0,T]), grid on
legend('analytic','DFT')