Commit 7aeb92b8e4bb279346d9dcec7bbca1725cec8eb1
1 parent
d74f5473
Exists in
master
and in
4 other branches
rewrite profile feature steps using spinach
Showing
4 changed files
with
114 additions
and
10 deletions
Show diff stats
features/profile/profile.feature
features/profile/ssh_keys.feature
| 1 | -Feature: SSH Keys | ||
| 2 | - Background: | ||
| 3 | - Given I signin as a user | ||
| 4 | - And I have ssh keys: | ||
| 5 | - | title | | ||
| 6 | - | ssh-rsa Work | | ||
| 7 | - | ssh-rsa Home | | 1 | +Feature: Profile SSH Keys |
| 2 | + Background: | ||
| 3 | + Given I sign in as a user | ||
| 4 | + And I have ssh key "ssh-rsa Work" | ||
| 8 | And I visit profile keys page | 5 | And I visit profile keys page |
| 9 | 6 | ||
| 10 | - Scenario: I should see SSH keys | 7 | + Scenario: I should see ssh keys |
| 11 | Then I should see my ssh keys | 8 | Then I should see my ssh keys |
| 12 | 9 | ||
| 13 | Scenario: Add new ssh key | 10 | Scenario: Add new ssh key |
| @@ -0,0 +1,57 @@ | @@ -0,0 +1,57 @@ | ||
| 1 | +class Profile < Spinach::FeatureSteps | ||
| 2 | + Given 'I visit profile page' do | ||
| 3 | + visit profile_path | ||
| 4 | + end | ||
| 5 | + | ||
| 6 | + Then 'I should see my profile info' do | ||
| 7 | + page.should have_content "Profile" | ||
| 8 | + page.should have_content @user.name | ||
| 9 | + page.should have_content @user.email | ||
| 10 | + end | ||
| 11 | + | ||
| 12 | + Then 'I change my contact info' do | ||
| 13 | + fill_in "user_skype", :with => "testskype" | ||
| 14 | + fill_in "user_linkedin", :with => "testlinkedin" | ||
| 15 | + fill_in "user_twitter", :with => "testtwitter" | ||
| 16 | + click_button "Save" | ||
| 17 | + @user.reload | ||
| 18 | + end | ||
| 19 | + | ||
| 20 | + And 'I should see new contact info' do | ||
| 21 | + @user.skype.should == 'testskype' | ||
| 22 | + @user.linkedin.should == 'testlinkedin' | ||
| 23 | + @user.twitter.should == 'testtwitter' | ||
| 24 | + end | ||
| 25 | + | ||
| 26 | + Given 'I visit profile password page' do | ||
| 27 | + visit profile_password_path | ||
| 28 | + end | ||
| 29 | + | ||
| 30 | + Then 'I change my password' do | ||
| 31 | + fill_in "user_password", :with => "222333" | ||
| 32 | + fill_in "user_password_confirmation", :with => "222333" | ||
| 33 | + click_button "Save" | ||
| 34 | + end | ||
| 35 | + | ||
| 36 | + And 'I should be redirected to sign in page' do | ||
| 37 | + current_path.should == new_user_session_path | ||
| 38 | + end | ||
| 39 | + | ||
| 40 | + Given 'I visit profile token page' do | ||
| 41 | + visit profile_token_path | ||
| 42 | + end | ||
| 43 | + | ||
| 44 | + Then 'I reset my token' do | ||
| 45 | + @old_token = @user.private_token | ||
| 46 | + click_button "Reset" | ||
| 47 | + end | ||
| 48 | + | ||
| 49 | + And 'I should see new token' do | ||
| 50 | + find("#token").value.should_not == @old_token | ||
| 51 | + find("#token").value.should == @user.reload.private_token | ||
| 52 | + end | ||
| 53 | + | ||
| 54 | + Given 'I sign in as a user' do | ||
| 55 | + login_as :user | ||
| 56 | + end | ||
| 57 | +end |
| @@ -0,0 +1,50 @@ | @@ -0,0 +1,50 @@ | ||
| 1 | +class ProfileSshKeys < Spinach::FeatureSteps | ||
| 2 | + Then 'I should see my ssh keys' do | ||
| 3 | + @user.keys.each do |key| | ||
| 4 | + page.should have_content(key.title) | ||
| 5 | + end | ||
| 6 | + end | ||
| 7 | + | ||
| 8 | + Given 'I click link "Add new"' do | ||
| 9 | + click_link "Add new" | ||
| 10 | + end | ||
| 11 | + | ||
| 12 | + And 'I submit new ssh key "Laptop"' do | ||
| 13 | + fill_in "key_title", :with => "Laptop" | ||
| 14 | + fill_in "key_key", :with => "ssh-rsa publickey234=" | ||
| 15 | + click_button "Save" | ||
| 16 | + end | ||
| 17 | + | ||
| 18 | + Then 'I should see new ssh key "Laptop"' do | ||
| 19 | + key = Key.find_by_title("Laptop") | ||
| 20 | + page.should have_content(key.title) | ||
| 21 | + page.should have_content(key.key) | ||
| 22 | + current_path.should == key_path(key) | ||
| 23 | + end | ||
| 24 | + | ||
| 25 | + Given 'I click link "Work"' do | ||
| 26 | + click_link "Work" | ||
| 27 | + end | ||
| 28 | + | ||
| 29 | + And 'I click link "Remove"' do | ||
| 30 | + click_link "Remove" | ||
| 31 | + end | ||
| 32 | + | ||
| 33 | + Then 'I visit profile keys page' do | ||
| 34 | + visit keys_path | ||
| 35 | + end | ||
| 36 | + | ||
| 37 | + And 'I should not see "Work" ssh key' do | ||
| 38 | + within "#keys-table" do | ||
| 39 | + page.should_not have_content "Work" | ||
| 40 | + end | ||
| 41 | + end | ||
| 42 | + | ||
| 43 | + Given 'I sign in as a user' do | ||
| 44 | + login_as :user | ||
| 45 | + end | ||
| 46 | + | ||
| 47 | + And 'I have ssh key "ssh-rsa Work"' do | ||
| 48 | + Factory :key, :user => @user, :title => "ssh-rsa Work", :key => "jfKLJDFKSFJSHFJssh-rsa Work" | ||
| 49 | + end | ||
| 50 | +end |