sitr.us

posts by Jesse Hallett

How to use RSpec to describe a Sinatra application

This information was written a long time ago and has become pretty outdated.

Sinatra is a fun little web application microframework. Recently I started working on an application using Sinatra - and since I am working on good programming habits, before I dove into any coding I sat down to work out how to write specs for a Sinatra application.

Sinatra comes bundled with support for test/spec: a spec framework that builds on top of Rail’s own Test::Unit to provide support for writing specs. Which is a really neat idea. But I have been using RSpec for my other work, and I wanted to continue doing so.

It turns out that RSpec takes a little bit of manual work to get going with Sinatra. I read a helpful article on gittr.com that pointed me in the right direction. The article advised me to add these lines to my spec files:

require File.expand_path(File.dirname(__FILE__) + '/your_application')
require 'spec'
require 'spec/interop/test'
require 'sinatra/test/unit'

The first line loads your application; the second line loads RSpec; the third loads an RSpec-Test::Unit compatibility layer; and the fourth loads Sinatra’s test helpers, which are written for Test::Unit.

International Phonetic Alphabet

In last week’s post I provided phonetic transcriptions of some example words using the International Phonetic Alphabet, or IPA for short. I thought it would be helpful to follow that up with some information about what the IPA is, and how to read it. And as a bonus, after learning about IPA transcription you will be able to better read pronunciation guides on Wikipedia.

You have probably seen many phonetic transcriptions before - especially as pronunciation guides in dictionaries. In dictionaries it is common to see a transcription convention that uses English spelling conventions to represent sounds. For example, the word “elucidate” might be transcribed as (ee-LOO-suh-date). That system is handy because it is immediately familiar to anyone who has experience reading stuff in English. But it has drawbacks too. There are a few main problems that are especially important for linguists; there are lots of linguists all over the world who are used to languages with entirely different spelling conventions. For example, the sound in English that is represented as “y” - the consonant, not the vowel - is written in Icelandic as “j”. There are also a lot of languages with sounds that just don’t exist in English. Linguists need to be able to transcribe those sounds; but since they don’t exist in English there is no spelling convention to represent them. In fact there is no one language with enough spelling conventions to represent every sound in every language in the world. And finally, English spelling is ambiguous, as is the spelling of almost any language. That is already demonstrated by the need to add a note to distinguish “y” the consonant from “y” the vowel or any of the other vowel sounds represented by “y”.

Anatomy of a Syllable

The syllable is a constant feature in every spoken language in the world. Each language has its own rules about what kinds of syllables are allowed, and what kinds aren’t - but the general structure is the same everywhere.

A syllable has as many as three parts: onset, nucleus, and coda. The onset and the coda are consonants, or consonant clusters, that appear at the beginning and the end of the syllable respectively. The nucleus forms the the core of the syllable; it is most often a vowel, or a combination of vowels - but there are many exceptions to that. If you examine enough languages you can find almost every kind phone used as a syllable nucleus. In the word “far”, [f] is the syllable onset, [a] is the nucleus, and [r] the coda. If a coda is present in a syllable, the nucleus and the coda form a single unit called a rhyme; otherwise the nucleus makes up the rhyme by itself. Looking at “far” again, [ar] forms the rhyme. A syllable does not necessarily have to have an onset or a coda - depending on the language - but a nucleus is always present.

Even in English, syllable nuclei are not restricted to vowels. For example, in the monosyllabic word, “hmm”, the syllable nucleus is [ṃ], which is a consonant but is more specifically a nasal. Another nasal, [n], can be seen as a syllable nucleus in the word “isn’t”, which is transcribed into the International Phonetic Alphabet (IPA) as [ɪzzṇt]. In this case there are two syllables, and [ṇ] forms the nucleus of the second syllable.

Deixis

When someone says to you, “here” or “now”, you probably know what he means. “Here” might the room that you are both sitting in. “Now” would be the span of time you spent sitting together. But if either word were uttered under different circumstances, it could mean something very different. For example, if I called you from the Andes and I used the word, “here”, it would mean a mountainside somewhere - possibly thousands of miles away from the aforementioned room. The same word can mean both the room and the mountainside because of deixis.

Deixis is a form of exophora, which is an utterance that is given meaning by the context it is uttered in. Specifically, deixis represents the speech event itself: deictic expressions reference the speaker, the speaker’s utterances, the speaker’s location, and the time at which the speech event occurs. There are different types of deictic expressions that refer to each particular aspect.

Personal pronouns, such as “I”, “you”, “he”, and “she”, are deictic expressions. “I” refers simply to the speaker. The other pronouns are defined by the relation the referenced person has to the speaker in the discourse. As the role of speaker switches from person to person, the context represented by deixis in understood by participants of the discourse to change too.