Home

Awesome

Sitespec

Generate static site from your rack application & test files.

Usage

1. Add sitespec into your Gemfile

# Gemfile
gem "sitespec"

2. Require sitespec/rspec in your specs

# spec/spec_helper.rb
require "sitespec/rspec"

3. Write request-specs with :sitespec metadata

Note: rack/test is automatically enabled in the example groups that have :sitespec.

# spec/site_spec.rb
describe "Sitespec" do
  let(:app) do
    MyRackApp
  end

  %w[
    /
    /2000/01/01/hello
    /stylesheets/all.css
  ].each do |path|
    describe "GET #{path}", :sitespec do
      it "returns 200" do
        expect(get(path).status).to eq 200
      end
    end
  end
end

4. Run rspec to build static files

Note: only successful examples generate static files.

$ bundle exec rspec

Example application
  GET /
    returns 200
  GET /2000/01/01/hello
    returns 200
  GET /stylesheets/all.css
    returns 200

Sitespec generated 3 files into build directory.

Finished in 0.08302 seconds (files took 0.79161 seconds to load)
3 examples, 0 failures

Configuration

Advanced topics

Sitespec is excellent with GitHub Pages. r7kamura/r7kamura.github.io is a working example that uses Sitespec to build static files from Rack application. It uses TravisCI to build and push files to GitHub repo's master branch. See .travis.yml for more information about how to to it.