rewrite profile feature steps using spinach
This commit is contained in:
parent
d74f54736b
commit
7aeb92b8e4
|
@ -1,13 +1,10 @@
|
|||
Feature: SSH Keys
|
||||
Feature: Profile SSH Keys
|
||||
Background:
|
||||
Given I sign in as a user
|
||||
And I have ssh keys:
|
||||
| title |
|
||||
| ssh-rsa Work |
|
||||
| ssh-rsa Home |
|
||||
And I have ssh key "ssh-rsa Work"
|
||||
And I visit profile keys page
|
||||
|
||||
Scenario: I should see SSH keys
|
||||
Scenario: I should see ssh keys
|
||||
Then I should see my ssh keys
|
||||
|
||||
Scenario: Add new ssh key
|
||||
|
|
57
features/steps/profile.rb
Normal file
57
features/steps/profile.rb
Normal file
|
@ -0,0 +1,57 @@
|
|||
class Profile < Spinach::FeatureSteps
|
||||
Given 'I visit profile page' do
|
||||
visit profile_path
|
||||
end
|
||||
|
||||
Then 'I should see my profile info' do
|
||||
page.should have_content "Profile"
|
||||
page.should have_content @user.name
|
||||
page.should have_content @user.email
|
||||
end
|
||||
|
||||
Then 'I change my contact info' do
|
||||
fill_in "user_skype", :with => "testskype"
|
||||
fill_in "user_linkedin", :with => "testlinkedin"
|
||||
fill_in "user_twitter", :with => "testtwitter"
|
||||
click_button "Save"
|
||||
@user.reload
|
||||
end
|
||||
|
||||
And 'I should see new contact info' do
|
||||
@user.skype.should == 'testskype'
|
||||
@user.linkedin.should == 'testlinkedin'
|
||||
@user.twitter.should == 'testtwitter'
|
||||
end
|
||||
|
||||
Given 'I visit profile password page' do
|
||||
visit profile_password_path
|
||||
end
|
||||
|
||||
Then 'I change my password' do
|
||||
fill_in "user_password", :with => "222333"
|
||||
fill_in "user_password_confirmation", :with => "222333"
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
And 'I should be redirected to sign in page' do
|
||||
current_path.should == new_user_session_path
|
||||
end
|
||||
|
||||
Given 'I visit profile token page' do
|
||||
visit profile_token_path
|
||||
end
|
||||
|
||||
Then 'I reset my token' do
|
||||
@old_token = @user.private_token
|
||||
click_button "Reset"
|
||||
end
|
||||
|
||||
And 'I should see new token' do
|
||||
find("#token").value.should_not == @old_token
|
||||
find("#token").value.should == @user.reload.private_token
|
||||
end
|
||||
|
||||
Given 'I sign in as a user' do
|
||||
login_as :user
|
||||
end
|
||||
end
|
50
features/steps/profile_ssh_keys.rb
Normal file
50
features/steps/profile_ssh_keys.rb
Normal file
|
@ -0,0 +1,50 @@
|
|||
class ProfileSshKeys < Spinach::FeatureSteps
|
||||
Then 'I should see my ssh keys' do
|
||||
@user.keys.each do |key|
|
||||
page.should have_content(key.title)
|
||||
end
|
||||
end
|
||||
|
||||
Given 'I click link "Add new"' do
|
||||
click_link "Add new"
|
||||
end
|
||||
|
||||
And 'I submit new ssh key "Laptop"' do
|
||||
fill_in "key_title", :with => "Laptop"
|
||||
fill_in "key_key", :with => "ssh-rsa publickey234="
|
||||
click_button "Save"
|
||||
end
|
||||
|
||||
Then 'I should see new ssh key "Laptop"' do
|
||||
key = Key.find_by_title("Laptop")
|
||||
page.should have_content(key.title)
|
||||
page.should have_content(key.key)
|
||||
current_path.should == key_path(key)
|
||||
end
|
||||
|
||||
Given 'I click link "Work"' do
|
||||
click_link "Work"
|
||||
end
|
||||
|
||||
And 'I click link "Remove"' do
|
||||
click_link "Remove"
|
||||
end
|
||||
|
||||
Then 'I visit profile keys page' do
|
||||
visit keys_path
|
||||
end
|
||||
|
||||
And 'I should not see "Work" ssh key' do
|
||||
within "#keys-table" do
|
||||
page.should_not have_content "Work"
|
||||
end
|
||||
end
|
||||
|
||||
Given 'I sign in as a user' do
|
||||
login_as :user
|
||||
end
|
||||
|
||||
And 'I have ssh key "ssh-rsa Work"' do
|
||||
Factory :key, :user => @user, :title => "ssh-rsa Work", :key => "jfKLJDFKSFJSHFJssh-rsa Work"
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue