File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,3 +8,4 @@ gem "mongo_mapper"
88gem "cucumber-sinatra"
99gem "capybara"
1010gem "factory_girl"
11+ gem "bson_ext"
Original file line number Diff line number Diff line change 1+ Factory . define :post do |p |
2+ p . title "default title"
3+ end
Original file line number Diff line number Diff line change 1+ Feature : The Hackety Blog
2+ Scenario : I can see the blog
3+ Given there is a blog post with the title "First Post"
4+ When I go to the blog page
5+ Then I should see "First Post"
Original file line number Diff line number Diff line change 1+ Given /^there is a blog post with the title "([^"]*)"$/ do |title |
2+ Factory ( :post , :title => title )
3+ end
4+
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ def path_to(page_name)
1313 when /the home\s ?page/
1414 '/'
1515
16+ when /the blog page/
17+ '/blog'
18+
1619 # Add more mappings here.
1720 # Here is an example that pulls values out of the Regexp:
1821 #
Original file line number Diff line number Diff line change 11require 'rubygems'
22require 'sinatra'
3+ require 'mongo_mapper'
4+
5+ configure do
6+ MongoMapper . connection = Mongo ::Connection . new ( 'localhost' )
7+ MongoMapper . database = 'hackety'
8+ Dir . glob ( "#{ File . expand_path ( File . dirname ( __FILE__ ) ) } /models/*.rb" ) . each do |f |
9+ require f
10+ end
11+ end
312
413get "/" do
514 haml :index
615end
16+
17+ get "/blog" do
18+ @posts = Post . all
19+ haml :blog_index
20+ end
Original file line number Diff line number Diff line change 1+ class Post
2+ include MongoMapper ::Document
3+ key :title , String
4+ timestamps!
5+ end
6+
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