Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Specing out widgets app

  • Loading branch information...
commit b34ee050702f2b516a9d16e7d10a9f409629c5ec 1 parent d7f0614
@jc00ke authored
View
BIN  examples/widgets/public/favicon.ico
Binary file not shown
View
2  examples/widgets/spec/spec_helper.rb
@@ -6,6 +6,7 @@
sinatra
rack/test
pp
+ webrat
spec
spec/autorun
spec/interop/test).each{ |lib| require lib }
@@ -19,4 +20,5 @@
Spec::Runner.configure do |conf|
conf.include Rack::Test::Methods
+ conf.include Webrat::Matchers
end
View
22 examples/widgets/spec/widgets_spec.rb
@@ -13,5 +13,27 @@ def app
last_response.should be_ok
end
+ it 'should have a home link' do
+ get '/'
+ last_response.should be_ok
+ last_response.body.should contain 'Home'
+ end
+
+ end
+
+ context "'/login' route" do
+
+ it 'should have a form' do
+ get '/login'
+ last_response.should be_ok
+ last_response.body.should include("action='/login'")
+ end
+
+ it 'should have a legit login form' do
+ get '/login'
+ last_response.should be_ok
+ last_response.body.should have_selector("form[name='login']")
+ end
+
end
end
View
0  examples/widgets/views/index.haml
No changes.
View
12 examples/widgets/views/layout.haml
@@ -0,0 +1,12 @@
+!!!
+%html
+ %head
+ %title Widgets
+ %link{ :rel => :stylesheet, :href => '/styles.css' }
+ %body
+ #header
+ %h1 Widgets
+ %nav
+ %a{ :href => '/' }Home
+ %a{ :href => '/login' }Login
+ = yield
View
1  examples/widgets/views/login.haml
@@ -0,0 +1 @@
+%form{ :method => :post, :action => '/login', :name => 'login' }
View
3  examples/widgets/views/styles.sass
@@ -0,0 +1,3 @@
+#wrapper
+ :margin 0 auto
+ :width 700px
View
10 examples/widgets/widgets.rb
@@ -1,5 +1,11 @@
%w(rubygems sinatra dm-core haml sass).each{ |lib| require lib }
+
+configure do
+ set :views, "#{File.dirname(__FILE__)}/views"
+ set :haml, { :format => :html5 }
+end
+
configure :development do
Sinatra::Application.reset!
use Rack::Reloader
@@ -9,5 +15,9 @@
get '/' do
+ haml :index
+end
+get '/login' do
+ haml :login
end
Please sign in to comment.
Something went wrong with that request. Please try again.