2nd scenario
+ added a scenario for submitting the button with no text in url field + simplified the visit when clause to be used with any url + edited create route redirect if url param is empty (backend validation for required URL field) + added when clause for clicking submit button + added then clause for current path/pagepull/6/head
parent
94026bdad2
commit
445236d735
1
app.rb
1
app.rb
|
|
@ -19,6 +19,7 @@ class App < Roda
|
||||||
|
|
||||||
r.post "create" do
|
r.post "create" do
|
||||||
url = r.params['url']
|
url = r.params['url']
|
||||||
|
if url.empty? then r.redirect '/' end
|
||||||
if nil == links.filter(:url => url).first
|
if nil == links.filter(:url => url).first
|
||||||
code = SecureRandom.urlsafe_base64 4
|
code = SecureRandom.urlsafe_base64 4
|
||||||
links.insert(url: url, code: code)
|
links.insert(url: url, code: code)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,13 @@ Feature: Homepage
|
||||||
Loading the homepage is the initial starting point for this tool
|
Loading the homepage is the initial starting point for this tool
|
||||||
|
|
||||||
Scenario: Homepage Loads with a form
|
Scenario: Homepage Loads with a form
|
||||||
Given I visit the homepage
|
Given I visit the '/' page
|
||||||
Then I should see text "URL Shortener"
|
Then I should see text "URL Shortener"
|
||||||
And I should see a form field "url"
|
And I should see a form field "url"
|
||||||
And I should see a "Submit" button
|
And I should see a "Submit" button
|
||||||
|
|
||||||
|
Scenario: Submitting the form without entering a URL
|
||||||
|
Given I visit the '/' page
|
||||||
|
When I click the submit button
|
||||||
|
Then I should be on "/" page
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
# GIVEN
|
# GIVEN
|
||||||
|
|
||||||
Given('I visit the homepage') do
|
Given('I visit the {string} page') do |string|
|
||||||
visit '/'
|
visit string
|
||||||
end
|
end
|
||||||
|
|
||||||
# WHEN
|
# WHEN
|
||||||
|
|
||||||
|
When('I click the submit button') do
|
||||||
|
click_button "Submit"
|
||||||
|
end
|
||||||
|
|
||||||
# THEN
|
# THEN
|
||||||
|
|
||||||
|
|
@ -21,3 +23,7 @@ end
|
||||||
Then('I should see a {string} button') do |string|
|
Then('I should see a {string} button') do |string|
|
||||||
page.should have_button string
|
page.should have_button string
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then('I should be on {string} page') do |string|
|
||||||
|
page.should have_current_path string
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue