Skip to content

Commit

Permalink
Upgrade from the deprecated Sinatra::Test to Rack::Test.
Browse files Browse the repository at this point in the history
  • Loading branch information
eee-c committed Jun 8, 2009
1 parent 058677e commit 985a723
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
27 changes: 12 additions & 15 deletions spec/eee_spec.rb
Expand Up @@ -2,8 +2,6 @@
require 'pp'

describe "eee" do
include Sinatra::Test

before(:all) do
RestClient.put @@db, { }
end
Expand Down Expand Up @@ -45,7 +43,7 @@
describe "GET /meals/YYYY" do
it "should respond OK" do
get "/meals/2009"
response.should be_ok
last_response.should be_ok
end

it "should ask CouchDB for meal from year YYYY" do
Expand All @@ -71,7 +69,7 @@
describe "GET /meals/YYYY/MM" do
it "should respond OK" do
get "/meals/2009/05"
response.should be_ok
last_response.should be_ok
end

it "should ask CouchDB for meal from year YYYY and month MM" do
Expand Down Expand Up @@ -103,7 +101,7 @@

it "should respond OK" do
get "/meals/2009/05/13"
response.should be_ok
last_response.should be_ok
end

it "should request the meal from CouchDB" do
Expand Down Expand Up @@ -140,7 +138,7 @@
describe 'GET /recipes/permalink' do
it "should respond OK" do
get "/recipes/#{@permalink}"
response.should be_ok
last_response.should be_ok
end
end

Expand All @@ -153,14 +151,13 @@
File.read('spec/fixtures/sample.jpg'),
:content_type => 'image/jpeg'


lambda { get "/images/#{@permalink}/sample.jpg" }.
should raise_error(Rack::Lint::LintError)
get "/images/#{@permalink}/sample.jpg"
last_response.should be_ok
end

it "should return 404 for a non-existent image" do
get "/images/#{@permalink}/sample2.jpg"
response.should be_not_found
last_response.should be_not_found
end
end

Expand Down Expand Up @@ -243,7 +240,7 @@

get "/recipes/search?q=title:egg"

response.should contain("No results")
last_response.should contain("No results")
end

it "should redirect without pagination after navigating beyond the pagination window" do
Expand All @@ -252,8 +249,8 @@

get "/recipes/search?q=egg&page=2"

response.status.should == 302
response.headers["Location"].should == "/recipes/search?q=egg"
last_response.status.should == 302
last_response.headers["Location"].should == "/recipes/search?q=egg"
end

it "should treat couchdb errors as no-results" do
Expand All @@ -262,7 +259,7 @@

get "/recipes/search?q=title:egg"

response.should contain("No results")
last_response.should contain("No results")
end

it "should treat couchdb-lucene errors as an empty query" do
Expand All @@ -271,7 +268,7 @@

get "/recipes/search?q=title:egg"

response.should have_selector("input[@name=query][@value='']")
last_response.should have_selector("input[@name=query][@value='']")
end
end
end
8 changes: 7 additions & 1 deletion spec/spec_helper.rb
Expand Up @@ -3,16 +3,22 @@
require 'eee'
require 'spec'
require 'spec/interop/test'
require 'sinatra/test'
require 'rack/test'

require 'webrat'
require 'haml'

Test::Unit::TestCase.send :include, Rack::Test::Methods

Spec::Runner.configure do |config|
config.include Webrat::Matchers, :type => :views
config.include Eee::Helpers
end

def app
Sinatra::Application
end

# Renders the supplied template with Haml::Engine and assigns the
# @response instance variable
def render(template_path)
Expand Down

0 comments on commit 985a723

Please sign in to comment.