Browse Source

Add first chapter and example source code

master
Peter J. Jones 9 years ago
parent
commit
cbc318782d
4 changed files with 140 additions and 0 deletions
  1. 13
    0
      Makefile
  2. 67
    0
      adv-ruby.tex
  3. 52
    0
      chapters/testing.tex
  4. 8
    0
      source/testing/example.rb

+ 13
- 0
Makefile View File

@@ -0,0 +1,13 @@
MAIN_TEX_FILE = adv-ruby.tex
MAIN_PDF_FILE = $(MAIN_TEX_FILE:.tex=.pdf)
CHAPTER_TEX_FILES = $(wildcard chapters/*.tex)

all: $(MAIN_PDF_FILE)

$(MAIN_PDF_FILE): $(CHAPTER_TEX_FILES)

open: $(MAIN_PDF_FILE)
@open $<

%.pdf: %.tex
latexmk -pdf $<

+ 67
- 0
adv-ruby.tex View File

@@ -0,0 +1,67 @@
% ============================================================================
\documentclass{book}
\usepackage{multicol}
\usepackage{comment}
\usepackage{todonotes}

% ============================================================================
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\newcommand\pmadefont{Baskerville}
\defaultfontfeatures{Scale=MatchLowercase}
\setmainfont[Mapping=tex-text]{\pmadefont}%{Century Gothic}
\setsansfont[Mapping=tex-text]{Tahoma}
\setmonofont{Monaco}

% ============================================================================
\usepackage{manfnt}
\renewcommand\labelitemi{\mantriangleright}

% ============================================================================
\usepackage{xcolor}
\usepackage{hyperref}

\definecolor{externallinkcolor}{HTML}{003399}
\definecolor{citelinkcolor}{HTML}{36823D}

\hypersetup{
plainpages=false,
colorlinks=true,
linkcolor=black,
filecolor=externallinkcolor,
urlcolor=externallinkcolor,
citecolor=citelinkcolor,
pdfdisplaydoctitle=true,
pdftoolbar=false,
bookmarksopen=true
}


% ============================================================================
\usepackage{listings}

\lstset{
numbers=left,
numberstyle=\tiny,
stepnumber=1,
numbersep=5pt,
language=ruby,
basicstyle=\ttfamily,
frame=single
}

% ============================================================================
\title{Advanced Ruby}
\author{Peter Jones}

% ============================================================================
\begin{document}

\maketitle
\tableofcontents

\include{chapters/testing}

% ============================================================================
\end{document}

+ 52
- 0
chapters/testing.tex View File

@@ -0,0 +1,52 @@
% ============================================================================
\chapter{Testing}

If you can think back to when you first started programming you might
remember feeling less than sure of your ability to write code that
actually worked. Thankfully that faded away as you wrote more and
more code that actually worked (and somebody was actually willing to
give you money for it.)

As you mature as a software developer it's natural to reach a point
where once again you start to doubt that your code always works as it
should. This time it's out of experience and a realization that your
software is running in a very complex stack relying on so many other
things that can go wrong. Automated testing can go a long way toward
instilling confidence in your software.

Testing is also very addictive. As you write tests that uncover bugs
that you were so certain couldn't exist in the first place, the desire
to confirm other sections of code increases along with your resolve.

This chapter quickly moves through the basics of testing and then
slows down for a full treatment of advanced testing.

% ============================================================================
\section{What Testing Is and Isn't}

\todo{Upfront cost that pays dividends.}

\todo{100\% code coverage doesn't make sense.}

% ============================================================================
\section{Approaches to Testing}

\todo{TDD, BDD, Black-box, white-box, etc.}

% ============================================================================
\section{Unit Testing and Assertions}

\todo{Contracts.}

\lstinputlisting{source/testing/example.rb}

% ============================================================================
\section{Regression Testing and Mocking}

\todo{Mocha.}

% ============================================================================
\section{Fuzz Testing}

% ============================================================================
\section{Integration Testing}

+ 8
- 0
source/testing/example.rb View File

@@ -0,0 +1,8 @@
require('test/unit')

class SimpleTest < Test::Unit::TestCase
def test_string_class_words
str = "Hello World"
assert_equal(11, str.length)
end
end

Loading…
Cancel
Save