File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ require 'cucumber/rake/task'
44
55Spec ::Rake ::SpecTask . new do |t |
66 t . spec_files = FileList [ 'spec/*_spec.rb' , ]
7+ t . spec_opts = [ "--colour" , "--backtrace" ]
78end
89
910Cucumber ::Rake ::Task . new ( :features ) do |t |
Original file line number Diff line number Diff line change @@ -12,3 +12,9 @@ Feature: The Hackety Blog
1212 Then I should see "Post Created"
1313 And I should see "new title"
1414 And I should see "new body"
15+ Scenario : I can view all posts
16+ Given there is a blog post with the title "First Post"
17+ And there is a blog post with the title "Second Post"
18+ When I go to the posts page
19+ Then I should see "First Post"
20+ And I should see "Second Post"
Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ def path_to(page_name)
1818
1919 when /the new post\s ? page/
2020 '/posts/new'
21+
22+ when /the posts page/
23+ '/posts'
2124
2225 # Add more mappings here.
2326 # Here is an example that pulls values out of the Regexp:
Original file line number Diff line number Diff line change 88use Rack ::Session ::Cookie , :secret => 'h4ck3ty h4ck f0r gr347 g00d'
99use Rack ::Flash
1010
11+ set :views , File . join ( File . dirname ( __FILE__ ) , 'views' )
12+
1113configure do
1214 MongoMapper . connection = Mongo ::Connection . new ( 'localhost' )
1315 MongoMapper . database = 'hackety'
3537 redirect "/posts/#{ @post . id } "
3638end
3739
40+ get "/posts" do
41+ @posts = Post . all
42+ haml :posts_index
43+ end
44+
3845get "/posts/:id" do
3946 @post = Post . find ( params [ :id ] )
4047 haml :posts_show
Original file line number Diff line number Diff line change 1+ require 'rubygems'
2+ require 'sinatra'
3+ require 'spec'
4+ require 'rack/test'
5+ set :environment , :test
6+
7+ require 'hackety'
8+
9+ describe "Hackety Website" do
10+ include Rack ::Test ::Methods
11+ def app ; Sinatra ::Application ; end
12+
13+ describe "routes" do
14+ it "should display all posts at /posts" do
15+ post1 = mock ( "Post" , :title => "title" , :body => "body" )
16+ post2 = mock ( "post" , :title => "title" , :body => "body" )
17+ Post . should_receive ( :all ) . and_return ( [ post1 , post2 ] )
18+ get "/posts"
19+ last_response . status . should == 200
20+ end
21+ end
22+ end
Original file line number Diff line number Diff line change 1+ require 'rubygems'
2+ require 'spec'
3+ require 'mongo_mapper'
4+ require 'models/post'
5+
6+ describe Post do
7+
8+ end
Original file line number Diff line number Diff line change 1+ %ul
2+ - @posts.each do |post|
3+ %li = post.title
You can’t perform that action at this time.
0 commit comments