-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
121 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake | ||
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby | ||
|
||
name: Ruby | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
ruby-version: ['3.3.4'] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Ruby | ||
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, | ||
# change this to (see https://github.com/ruby/setup-ruby#versioning): | ||
# uses: ruby/setup-ruby@v1 | ||
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 | ||
with: | ||
ruby-version: ${{ matrix.ruby-version }} | ||
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | ||
- name: Run standard | ||
run: bundle exec standardrb | ||
- name: Run tests | ||
run: bundle exec rake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require "minitest/test_task" | ||
|
||
Minitest::TestTask.create # named test, sensible defaults | ||
|
||
# or more explicitly: | ||
|
||
Minitest::TestTask.create(:test) do |t| | ||
t.libs << "test" | ||
t.libs << "lib" | ||
t.warning = false | ||
t.test_globs = ["test/**/*_test.rb"] | ||
end | ||
|
||
task default: :test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
require "minitest/autorun" | ||
require "./app/pace" | ||
require "./app/converter_service" | ||
class TestPace < Minitest::Test | ||
def test_calculates_pace_run | ||
pace = Pace.new(type: "pace", activity: "run", distance: 5, pace_length: "mile", distance_length: "mile", time_hours: 0, time_minutes: 30, time_seconds: 0) | ||
assert_equal "To run 5.0 mile in 0:30:00, you need a pace of 6:00/mile", pace.print_pace | ||
end | ||
|
||
def test_calculates_time_run | ||
pace = Pace.new(type: "time", activity: "run", distance: 5, pace_length: "mile", distance_length: "mile", pace_minutes: 6, pace_seconds: 0) | ||
assert_equal "If you run 5.0 mile with a pace of 6:00/mile, you'll finish in 0:30:00", pace.print_time | ||
end | ||
|
||
def test_calculates_distance_run | ||
pace = Pace.new(type: "distance", activity: "run", pace_length: "mile", distance_length: "mile", pace_minutes: 6, pace_seconds: 0, time_hours: 0, time_minutes: 30, time_seconds: 0) | ||
assert_equal "If you run a pace of of 6:00/mile for 0:30:00, you will go 5 miles.", pace.print_distance | ||
end | ||
|
||
def test_calculates_pace_swim | ||
skip "this has a bug" | ||
pace = Pace.new(type: "pace", activity: "swim", distance: 500, pace_length: "50yd", distance_length: "meter", time_hours: 0, time_minutes: 10, time_seconds: 0) | ||
assert_equal "If you swim 500.0 meter with a pace of 2:00/50yd, you'll finish in 0:43:44", pace.print_pace | ||
end | ||
|
||
def test_calculates_time_swim | ||
pace = Pace.new(type: "time", activity: "swim", distance: 500, pace_length: "25yd", distance_length: "meter", pace_minutes: 2, pace_seconds: 0) | ||
assert_equal "If you swim 500.0 meter with a pace of 2:00/25yd, you'll finish in 0:43:44", pace.print_time | ||
end | ||
|
||
def test_calculates_distance_swim | ||
skip "this has a bug" | ||
pace = Pace.new(type: "distance", activity: "swim", pace_length: "50m", distance_length: "meter", pace_minutes: 2, pace_seconds: 0, time_hours: 0, time_minutes: 10, time_seconds: 0) | ||
assert_equal "If you swim a pace of of 2:00/50m for 0:10:00, you will go 500 meters.", pace.print_distance | ||
end | ||
|
||
def test_calculates_pace_row | ||
skip "this has a bug" | ||
pace = Pace.new(type: "pace", activity: "row", distance: 2000, pace_length: "500m", distance_length: "meter", time_hours: 0, time_minutes: 10, time_seconds: 0) | ||
assert_equal "To row 2000 m in 0:10:00, you need a pace of 2:30/500m", pace.print_pace | ||
end | ||
|
||
def test_calculates_time_row | ||
pace = Pace.new(type: "time", activity: "row", distance: 2, pace_length: "500meter", distance_length: "mile", pace_minutes: 2, pace_seconds: 30) | ||
assert_equal "If you row 2.0 mile with a pace of 2:30/500meter, you'll finish in 0:08:02", pace.print_time | ||
end | ||
|
||
def test_calculates_distance_row | ||
pace = Pace.new(type: "distance", activity: "row", pace_length: "500meter", distance_length: "mile", pace_minutes: 2, pace_seconds: 30, time_hours: 0, time_minutes: 10, time_seconds: 0) | ||
assert_equal "If you row a pace of of 2:30/500meter for 0:10:00, you will go 6.44 miles.", pace.print_distance | ||
end | ||
end |