Merge pull request 'code coverage reporting and test for the redirect function' (#12) from add-flash into master

Reviewed-on: #12
pull/13/head
bucky 2023-10-03 18:32:12 -07:00
commit a0be5c699a
5 changed files with 33 additions and 1 deletions

View File

@ -14,7 +14,7 @@ gem "sqlite3", "~> 1.6"
gem "erubi", "~> 1.12" gem "erubi", "~> 1.12"
group :development do group :test do
gem "cucumber", "~> 9.0" gem "cucumber", "~> 9.0"
@ -24,4 +24,6 @@ group :development do
gem "selenium-webdriver", "~> 4.13" gem "selenium-webdriver", "~> 4.13"
gem "simplecov"
end end

View File

@ -65,6 +65,7 @@ GEM
cucumber-messages (21.0.1) cucumber-messages (21.0.1)
cucumber-tag-expressions (4.1.0) cucumber-tag-expressions (4.1.0)
diff-lcs (1.5.0) diff-lcs (1.5.0)
docile (1.4.0)
erubi (1.12.0) erubi (1.12.0)
falcon (0.42.3) falcon (0.42.3)
async async
@ -138,6 +139,12 @@ GEM
websocket (~> 1.0) websocket (~> 1.0)
sequel (5.73.0) sequel (5.73.0)
bigdecimal bigdecimal
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sqlite3 (1.6.6) sqlite3 (1.6.6)
mini_portile2 (~> 2.8.0) mini_portile2 (~> 2.8.0)
sys-uname (1.2.3) sys-uname (1.2.3)
@ -161,6 +168,7 @@ DEPENDENCIES
rspec (~> 3.12) rspec (~> 3.12)
selenium-webdriver (~> 4.13) selenium-webdriver (~> 4.13)
sequel (~> 5.72) sequel (~> 5.72)
simplecov
sqlite3 (~> 1.6) sqlite3 (~> 1.6)
tilt (~> 2.2) tilt (~> 2.2)

View File

@ -33,3 +33,9 @@ Feature: Homepage
And I click the "Submit" button And I click the "Submit" button
Then I should be on "/create" page Then I should be on "/create" page
And I should see the message "Link exists" 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") @links.insert(url: string, code: "aaaaaa")
end 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
When('I click the {string} button') do |string| 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 fill_in field, with: text
end end
When('I visit the {string} location') do |string|
visit string
end
# THEN # THEN
Then('I should see text {string}') do |string| 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 page.should have_selector '#message', text: message
end 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
After('@db-test') do After('@db-test') do

View File

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