forked from hacketyhack/hackety-hack.com
/
program_steps.rb
71 lines (59 loc) · 1.89 KB
/
program_steps.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Given /^there is a featured program$/ do
@program = Program.create!(:author_username => "username",
:slug => "slug",
:title => "My Featured Program",
:featured => true)
end
Then /^I should be able to view a highlighted program$/ do
visit programs_path
within "#featured" do
page.should have_content("My Featured Program")
end
end
def upload_program(user)
@program = Program.create!(:author_username => user.username,
:slug => "slug",
:title => "#{user.username}'s program",
:source_code => "puts 'Hello world'")
end
Given /^I have uploaded a program$/ do
upload_program(@user)
end
Given /^a user has uploaded a program$/ do
@user = User.create!(:username => "some_user",
:password => "password",
:password_confirmation => "password",
:email => "some_user@example.com")
upload_program(@user)
end
Given /^they have given their program a description$/ do
@program = Program.last
@program.description = "A really cool program!"
@program.save
end
def visit_user_programs_page
visit user_path(@user)
within ".about-user" do
find(".user-programs").click()
end
page.should have_content(@program.title.titleize)
end
Then /^I should be able to view my programs$/ do
visit_user_programs_page
end
Then /^I should be able to view their programs$/ do
visit_user_programs_page
end
When /^I click the first program link$/ do
within ".programs_list" do
find("li:first-child a").click()
end
end
Then /^I should see the program source$/ do
within("#program") do
page.should have_content("puts 'Hello world'")
end
end
Then /^I should see the description of their program$/ do
page.should have_content("A really cool program!")
end