Created
June 18, 2010 02:30
-
-
Save ozeias/443127 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
require 'capybara' | |
require 'capybara/dsl' | |
require 'selenium-webdriver' | |
class UserFlowsTest < ActionController::IntegrationTest | |
include Capybara | |
def setup | |
Capybara.app_host = 'http://www.soundfolder.dev:3000' | |
Capybara.default_driver = :selenium | |
Capybara.default_selector = :css # instead of xpath | |
end | |
test "make a test user" do | |
make_roland | |
end | |
test "sign up" do | |
visit '/signup' | |
fill_in_signup_form | |
find('button[type=submit]').click | |
assert page.has_content? 'Welcome to SoundFolder' | |
end | |
test "sign up from the home page" do | |
logout | |
visit '/' | |
fill_in_signup_form | |
find('button[type=submit]').click | |
assert page.has_content? 'Welcome to SoundFolder' | |
end | |
test "view a user's site at a subdomain" do | |
Capybara.app_host = 'http://roland.soundfolder.dev:3000' | |
visit '/' | |
assert page.has_css? '#artist-header' | |
assert page.has_content? 'roland' | |
end | |
test "upload a track" do | |
login | |
# remove previously uploaded fixture mp3 | |
Track.find_all_by_title('Full House').each{|track| track.destroy} | |
visit '/mixer' | |
click 'Add a new track' | |
attach_file('track[track]', RAILS_ROOT + 'fixtures/mp3s/id3.mp3') | |
click 'Add this track' | |
#FIXME paperclip says "empty file" | |
#assert page.has_content? 'Full House' | |
end | |
def fill_in_signup_form | |
fill_in 'user[name]', :with => Faker::Name.name | |
fill_in 'user[email]', :with => Faker::Internet.email | |
fill_in 'user[password]', :with => 'shellacofnorthamerica' | |
end | |
def make_roland | |
# gives us a test user. | |
# don't care if this fails, roland might already exist. | |
visit '/signup' | |
fill_in 'user[name]', :with => 'roland' | |
fill_in 'user[email]', :with => '[email protected]' | |
fill_in 'user[password]', :with => 'roland' | |
find('button[type=submit]').click | |
end | |
def login | |
logout | |
visit '/login' | |
fill_in 'email', :with => '[email protected]' | |
fill_in 'password', :with => 'roland' | |
click 'Log in' | |
end | |
def logout | |
click 'Log Out' if page.has_css? '.logged_in' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment