Retrospring/spec/features/users/user_show_spec.rb

67 lines
1.9 KiB
Ruby
Raw Normal View History

2014-12-07 03:42:03 -08:00
include Warden::Test::Helpers
Warden.test_mode!
2014-11-17 14:25:28 -08:00
2014-12-07 03:42:03 -08:00
# Feature: User profile page
# As a user
# I want to visit my user profile page
# So I can see my personal account data
feature "User profile page", :devise do
after :each do
Warden.test_reset!
end
# Scenario: User sees own profile
# Given I am signed in
# When I visit the user profile page
# Then I see my own screen name and follower count
scenario 'user sees own profile', js: true do
2020-04-19 08:27:42 -07:00
user = FactoryBot.create(:user)
2014-12-07 03:42:03 -08:00
login_as(user, :scope => :user)
visit show_user_profile_path(user.screen_name)
expect(page).to have_content user.screen_name
expect(page).to have_content user.follower_count
2014-11-17 14:25:28 -08:00
end
2014-12-07 03:42:03 -08:00
# Scenario: User sees another user's profile
# Given I am signed in
# When I visit another user's profile
# Then I see that user's screen name and follower count
scenario "user sees another user's profile", js: true do
2020-04-19 08:27:42 -07:00
me = FactoryBot.create(:user)
other = FactoryBot.create(:user)
2014-11-17 14:25:28 -08:00
2014-12-07 03:42:03 -08:00
login_as me, scope: :user
visit show_user_profile_path(other.screen_name)
expect(page).to have_content other.screen_name
expect(page).to have_content other.follower_count
end
# Scenario: User gets asked a question
# Given I am signed in
# When I visit another user's profile
# And I fill something in the question box
# And I click on "Ask"
# Then I see "Question asked successfully."
scenario "user gets asked a question", js: true do
2020-04-19 08:27:42 -07:00
me = FactoryBot.create(:user)
other = FactoryBot.create(:user)
2014-12-07 03:42:03 -08:00
login_as me, scope: :user
visit show_user_profile_path(other.screen_name)
2014-11-18 11:58:55 -08:00
page.driver.render Rails.root.join("tmp/#{Time.now.to_i}_1.png"), full: true
2014-11-17 14:25:28 -08:00
fill_in "qb-question", with: Faker::Lorem.sentence
click_button "Ask"
wait_for_ajax
2014-11-18 11:58:55 -08:00
page.driver.render Rails.root.join("tmp/#{Time.now.to_i}_2.png"), full: true
2014-11-17 14:25:28 -08:00
expect(page).to have_text("Question asked successfully.")
end
end