update for missing link scenario

+ if the link isn't found, don't redirect it, keep it on the same page
+ it should have a status code of 404
+ it should have the form fields as well

+ added page status check
pull/18/head
Adam Townsend 2023-10-07 21:10:16 -07:00
parent f8499a79c2
commit c7fee27623
2 changed files with 13 additions and 1 deletions

View File

@ -42,5 +42,8 @@ Feature: Homepage
Scenario: Accessing a nonexistent URL code
Given I visit the "/aaaaaa" location
Then I should be on "/" page
Then I should be on "/aaaaaa" page
And The status code should be 404
And I should see the message "Link aaaaaa doesn't exist"
And I should see a form field "url"
And I should see a "Submit" button

View File

@ -3,6 +3,7 @@ Before('@db-test') do
@links = Sequel.sqlite("db/#{ENV['DB_NAME']}")[:links]
end
# GIVEN
Given('I visit the {string} page') do |string|
@ -17,6 +18,7 @@ Given('A link already exists with the url {string} and code {string}') do |url,
@links.insert(url: url, code: code)
end
# WHEN
When('I click the {string} button') do |string|
@ -31,6 +33,7 @@ When('I visit the {string} location') do |string|
visit string
end
# THEN
Then('I should see text {string}') do |string|
@ -58,6 +61,12 @@ Then('I should be redirected to {string}') do |string|
location = actual.index(string)
location.should equal(0)
end
Then('The status code should be {int}') do |code|
puts page.status_code.should eq(code)
end
# AFTER
After('@db-test') do