Sha256: 58efeb7730fad5a3ccb1413f38d4009f83ce84e5d3872dd547609357d2232505

Contents?: true

Size: 857 Bytes

Versions: 1

Compression:

Stored size: 857 Bytes

Contents

require 'spec_helper'
require 'sinatra'
require 'sinatra/petroglyph'
require 'rack/test'

class PetroglyphApp < Sinatra::Base
  set :root, File.dirname(__FILE__)+"/fixtures"
  set :show_exceptions, false

  get "/" do
    tea = OpenStruct.new(:type => 'tea', :temperature => 'hot')
    coffee = OpenStruct.new(:type => 'coffee', :temperature => 'lukewarm')
    pg :index, :locals => {:drinks => [tea, coffee]}
  end

  post '/' do
    pg :post, :locals => {:post => 'a post'}
  end
end

describe "Sinatra integration" do
  include Rack::Test::Methods

  def app
    PetroglyphApp
  end

  it "works" do
    get "/"
    last_response.body.should eq '{"drinks":[{"type":"tea","temperature":"hot"},{"type":"coffee","temperature":"lukewarm"}]}'
  end

  xit "doesn't freak out on the HTTP method" do
    post '/'
    last_response.body.should eq '{}'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
petroglyph-0.0.1 spec/sinatra_integration_spec.rb