Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shabbir Solution #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 78 additions & 39 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,61 +1,95 @@
GEM
remote: https://rubygems.org/
specs:
builder (3.2.2)
capybara (2.4.4)
mime-types (>= 1.16)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
backports (3.11.1)
builder (3.2.3)
capybara (2.18.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
coderay (1.1.0)
cucumber (1.3.17)
xpath (>= 2.0, < 4.0)
coderay (1.1.2)
cucumber (3.1.0)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.12)
cucumber-core (~> 3.1.0)
cucumber-expressions (~> 5.0.4)
cucumber-wire (~> 0.0.1)
diff-lcs (~> 1.3)
gherkin (~> 5.0)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.1)
multi_test (>= 0.1.2)
cucumber-core (3.1.0)
backports (>= 3.8.0)
cucumber-tag_expressions (~> 1.1.0)
gherkin (>= 5.0.0)
cucumber-expressions (5.0.13)
cucumber-sinatra (0.5.0)
templater (>= 1.0.0)
diff-lcs (1.2.5)
cucumber-tag_expressions (1.1.1)
cucumber-wire (0.0.1)
diff-lcs (1.3)
extlib (0.9.16)
gherkin (2.12.2)
multi_json (~> 1.3)
haml (4.0.6)
ffi (1.9.21)
gherkin (5.0.0)
haml (5.0.4)
temple (>= 0.8.0)
tilt
highline (1.6.21)
method_source (0.8.2)
mime-types (2.4.3)
mini_portile (0.6.1)
multi_json (1.10.1)
multi_test (0.1.1)
nokogiri (1.6.4.1)
mini_portile (~> 0.6.0)
pry (0.10.1)
highline (1.7.10)
method_source (0.9.0)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
multi_json (1.13.1)
multi_test (0.1.2)
mustermann (1.0.2)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.5.2)
rack-protection (1.5.3)
method_source (~> 0.9.0)
public_suffix (3.0.2)
rack (2.0.4)
rack-protection (2.0.1)
rack
rack-test (0.6.2)
rack (>= 1.0)
rspec-expectations (3.1.2)
rack-test (0.8.2)
rack (>= 1.0, < 3)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0)
rspec-support (3.1.2)
sinatra (1.4.5)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
slop (3.6.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
sass (3.5.5)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sinatra (2.0.1)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.1)
tilt (~> 2.0)
templater (1.0.0)
diff-lcs (>= 1.1.2)
extlib (>= 0.9.5)
highline (>= 1.4.0)
tilt (1.4.1)
xpath (2.0.0)
nokogiri (~> 1.3)
temple (0.8.0)
tilt (2.0.8)
xpath (3.0.0)
nokogiri (~> 1.8)

PLATFORMS
ruby
Expand All @@ -66,5 +100,10 @@ DEPENDENCIES
cucumber-sinatra
haml
pry
rspec
rspec-expectations
sass
sinatra

BUNDLED WITH
1.16.1
14 changes: 12 additions & 2 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,17 @@ def logged_in?
end

get "/dashboard" do
@username = session[:user]
haml :dashboard
#@username = session[:user]
#haml :dashboard
#first check if user is authenticated or not
if logged_in?
@username = session[:user]
haml :dashboard
else
@message = 'Unauthorized access!'
#redirect to home page
haml :index
end

end
end
Binary file added features/.DS_Store
Binary file not shown.
5 changes: 2 additions & 3 deletions features/login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ Feature: Login Page

Scenario: Authenticated User
Given the login page
When I log in with proper credentials
Then I should see the secret page

When I log in with username and password as "admin"
Then I should see the secret page with my my username "admin"
9 changes: 8 additions & 1 deletion features/logout.feature
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
#Add your codez here
Feature: Logout functionality
When I want to end my session
I should be able to logout

Scenario: User logs out
Given user secret page with credentials "admin"
When I click on "Logout"
Then I should be redirected to logout page with a message "You have been logged out"
15 changes: 7 additions & 8 deletions features/step_definitions/login_steps.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
Given(/^the login page$/) do
#put your code here
pending
visit('http://localhost:4567')
end

When(/^I log in with proper credentials$/) do
#put your code here
pending
When(/^I log in with username and password as "(.*?)"$/) do |credential|
fill_in 'username', :with => credential
fill_in 'password', :with => credential
click_button 'Login'
end

Then(/^I should see the secret page$/) do
#put your code here
pending
Then(/^I should see the secret page with my my username "(.*?)"$/) do |username|
expect(page).to have_content username
end
16 changes: 15 additions & 1 deletion features/step_definitions/logout_steps.rb
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
#Add your codez here
Given (/^user secret page with credentials "(.*?)"$/) do |credentails|
steps %{
Given the login page
When I log in with username and password as "#{credentails}"
Then I should see the secret page with my my username "#{credentails}"
}
end

When (/^I click on "(.*?)"$/) do |link|
click_link link
end

Then(/^I should be redirected to logout page with a message "(.*?)"$/) do |message|
expect(page).to have_content message
end