Skip to content

Instantly share code, notes, and snippets.

@cschneid
Created August 1, 2008 15:46
Show Gist options
  • Save cschneid/3635 to your computer and use it in GitHub Desktop.
Save cschneid/3635 to your computer and use it in GitHub Desktop.
require File.dirname(__FILE__) + '/spec_helper'
describe 'Sinatra app controllers' do
require 'sinatra_app'
specify "should retrieve a proper response from /" do
get_it '/'
@response.should be_ok
@response.elem('title').inner_text.should == "Web App Title Element"
end
specify "should have a login textbox and a submit button for /login" do
get_it '/login'
@response.should be_ok
@response.elem('input').first['type'].should == 'text'
@response.elem('input').last['type'].should == 'submit'
end
end
$:.unshift("../sinatra/lib")
require 'sinatra'
require 'spec/interop/test'
require 'sinatra/test/unit'
set :views, File.join(File.dirname(__FILE__), '..', 'views')
class Rack::MockResponse
require 'hpricot'
def elem method
@page = Hpricot(self.body) unless @page
return (@page/method)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment