Skip to content

Instantly share code, notes, and snippets.

@thbar
Created July 30, 2009 00:08
Show Gist options
  • Save thbar/158464 to your computer and use it in GitHub Desktop.
Save thbar/158464 to your computer and use it in GitHub Desktop.
# not sure if it's the simpliest way, yet it works
# I'm using this to test ramaze application
require 'rubygems'
require 'spec'
require 'webrat'
Webrat.configure do |config|
config.mode = :mechanize
end
describe MyFeature do
include Webrat::Matchers
include Webrat::Methods
attr_reader :session
before(:each) do
@session = Webrat::MechanizeSession.new
@session.visit("http://localhost:7000")
end
def response
session.response
end
it "handles 404" do
begin
session.visit("/plurk")
raise "404 expected!"
rescue WWW::Mechanize::ResponseCodeError => e
e.response_code.should == "404"
end
end
it "handles search input when input was originally here" do
session.visit("/search/css")
session.fill_in 'search', :with => 'rails'
session.click_button 'Go'
session.response.uri.path.should == '/search/rails'
end
it "serves feed as application/rss+xml" do
session.visit("/feed")
response.response['content-type'].should == 'application/rss+xml'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment