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 @@ class Program
44 key :author_username , String
55 key :slug , String
66 key :title , String
7+ key :description , String
78 key :source_code , String
89 key :featured , Boolean
910 timestamps!
Original file line number Diff line number Diff line change 1010 %h3 Featured
1111 .description Our favorite selection of projects.
1212
13- %ul
13+ %ul .featured_programs_list
1414 - @featured.each do |program|
1515 %li
1616 .title = program_link program
2222 %h3 All Programs
2323 .description Every program uploaded by our users!
2424
25- %ul
25+ %ul .programs_list
2626 - @programs.each do |program|
2727 %li
2828 .title = program_link program
Original file line number Diff line number Diff line change 1919 by
2020 = link_to @program.author_username, user_path(@program.author_username)
2121
22+ .description
23+ %p = @program.description
24+
2225#program
2326 %pre .prettyprint = @program.source_code
2427
Original file line number Diff line number Diff line change @@ -13,4 +13,17 @@ Feature: Access Programs
1313
1414 Scenario : View another user's programs
1515 Given a user has uploaded a program
16- Then I should be able to view their programs
16+ Then I should be able to view their programs
17+
18+ Scenario : View an individual program
19+ Given a user has uploaded a program
20+ And I should be able to view their programs
21+ When I click the first program link
22+ Then I should see the program source
23+
24+ Scenario : View a program with a description
25+ Given a user has uploaded a program
26+ And they have given their program a description
27+ And I should be able to view their programs
28+ When I click the first program link
29+ Then I should see the description of their program
Original file line number Diff line number Diff line change 1515def upload_program ( user )
1616 @program = Program . create! ( :author_username => user . username ,
1717 :slug => "slug" ,
18- :title => "#{ user . username } 's program" )
18+ :title => "#{ user . username } 's program" ,
19+ :source_code => "puts 'Hello world'" )
1920end
2021
2122Given /^I have uploaded a program$/ do
@@ -30,6 +31,13 @@ def upload_program(user)
3031 upload_program ( @user )
3132end
3233
34+ Given /^they have given their program a description$/ do
35+ @program = Program . last
36+ @program . description = "A really cool program!"
37+ @program . save
38+ end
39+
40+
3341def visit_user_programs_page
3442 visit user_path ( @user )
3543 within ".about-user" do
@@ -44,4 +52,20 @@ def visit_user_programs_page
4452
4553Then /^I should be able to view their programs$/ do
4654 visit_user_programs_page
47- end
55+ end
56+
57+ When /^I click the first program link$/ do
58+ within ".programs_list" do
59+ find ( "li:first-child a" ) . click ( )
60+ end
61+ end
62+
63+ Then /^I should see the program source$/ do
64+ within ( "#program" ) do
65+ page . should have_content ( "puts 'Hello world'" )
66+ end
67+ end
68+
69+ Then /^I should see the description of their program$/ do
70+ page . should have_content ( "A really cool program!" )
71+ end
Original file line number Diff line number Diff line change 11require 'spec_helper'
22
33describe Program do
4- let ( :prog ) { Program . create ( author_username : 'tester' , title : 'test title' ) }
4+ let ( :prog ) { Program . create ( author_username : 'tester' , title : 'test title' ) }
5+
56 it "sets the slug" do
67 prog . slug . should == 'test-title'
78 end
You can’t perform that action at this time.
0 commit comments