Sha256: 2dce9dc165518cb76f069a0f8212169185149b629b6f759647773100ee83f78e

Contents?: true

Size: 1.01 KB

Versions: 48

Compression:

Stored size: 1.01 KB

Contents

require "rubygems"
require "sinatra"

use_in_file_templates!

get "/" do
  erb :home
end

get "/go" do
  erb :go
end

get "/internal_redirect" do
  redirect "/"
end

get "/external_redirect" do
  redirect "http://google.com"
end

post "/go" do
  @user = params[:name]
  @email = params[:email]
  erb :hello
end

__END__

@@ layout
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <title>sinatra testing with webrat</title>
  <body>
    <%= yield %>
  </body>
</html>

@@ home
<p> visit <a href="/go">there</a></p>

<form>
  <label>
    Prefilled
    <input type="text" name="prefilled" value="text" />
  </label>
</form>

@@ go
<form method="post" action="/go">
  <div>
    <label for="name">Name</label>
    <input type="text" name="name" id="name">
  </div>
  <div>
    <label for="email">Email</label>
    <input type="text" name="email" id="email">
  </div>
  <input type="submit" value="Submit" />
</form>

@@ hello
<p>Hello, <%= @user %></p>
<p>Your email is: <%= @email %></p>

Version data entries

48 entries across 48 versions & 19 rubygems

Version Path
davidtrogers-webrat-0.4.4.2 spec/integration/sinatra/classic_app.rb
diabolo-webrat-0.4.4.1 spec/integration/sinatra/classic_app.rb
diabolo-webrat-0.4.4.2 spec/integration/sinatra/classic_app.rb
diabolo-webrat-0.4.4 spec/integration/sinatra/classic_app.rb
diabolo-webrat-0.5.1 spec/integration/sinatra/classic_app.rb
dstrelau-webrat-0.5.1 spec/integration/sinatra/classic_app.rb
emipair-webrat-0.0.1 spec/integration/sinatra/classic_app.rb
hardbap-webrat-0.5.1 spec/integration/sinatra/classic_app.rb
hardbap-webrat-0.5.2 spec/integration/sinatra/classic_app.rb
raldred-webrat-0.4.4.2 spec/integration/sinatra/classic_app.rb
sr-webrat-0.4.4.1 spec/integration/sinatra/classic_app.rb
winton-sum-0.1.0 vendor/webrat/spec/integration/sinatra/classic_app.rb
winton-sum-0.1.1 vendor/webrat/spec/integration/sinatra/classic_app.rb
revo-webrat-0.7.0.1 spec/integration/sinatra/classic_app.rb
davidtrogers-webrat-0.7.0 spec/integration/sinatra/classic_app.rb
revo-webrat-0.7.0 spec/integration/sinatra/classic_app.rb
revo-webrat-0.7.1.pre spec/integration/sinatra/classic_app.rb
webrat-0.7.0 spec/integration/sinatra/classic_app.rb
honkster-webrat-0.6.0.10 spec/integration/sinatra/classic_app.rb
honkster-webrat-0.6.0.9 spec/integration/sinatra/classic_app.rb