added simplecov and a new test

+ simplecov is a test coverage tool to show what code is covered and
  where holes are
+ added newest test to validate that the redirect url works as expected
pull/12/head
Adam Townsend 2023-10-03 18:29:03 -07:00
parent b3d5c70c8b
commit 81b12b5d6f
3 changed files with 22 additions and 0 deletions

View File

@ -33,3 +33,9 @@ Feature: Homepage
And I click the "Submit" button
Then I should be on "/create" page
And I should see the message "Link exists"
@db-test
Scenario: Accessing the URL based on the shortcode
Given A link already exists with the url "https://google.com" and code "aaaaaa"
When I visit the "/aaaaaa" location
Then I should be redirected to "https://google.com"

View File

@ -13,6 +13,10 @@ Given('A link already exists with the url {string}') do |string|
@links.insert(url: string, code: "aaaaaa")
end
Given('A link already exists with the url {string} and code {string}') do |url, code|
@links.insert(url: url, code: code)
end
# WHEN
When('I click the {string} button') do |string|
@ -23,6 +27,10 @@ When('I type {string} in the {string} field') do |text, field|
fill_in field, with: text
end
When('I visit the {string} location') do |string|
visit string
end
# THEN
Then('I should see text {string}') do |string|
@ -45,6 +53,11 @@ Then('I should see the message {string}') do |message|
page.should have_selector '#message', text: message
end
Then('I should be redirected to {string}') do |string|
actual = URI.parse(current_url).to_s
location = actual.index(string)
location.should equal(0)
end
# AFTER
After('@db-test') do

View File

@ -1,3 +1,6 @@
require 'simplecov'
SimpleCov.start
require_relative '../../.env'
ENV["DB_NAME"] = "test_#{ENV["DB_NAME"]}"
require_relative '../../app'