From 2f53abe79881392940bf80a227e6e693c2dc6741 Mon Sep 17 00:00:00 2001 From: vzvu3k6k Date: Tue, 27 Oct 2020 05:35:41 +0900 Subject: [PATCH 1/6] Add tests for Sorting/bogo_sort.rb --- sorting/bogo_sort.rb | 8 +++++--- sorting/bogo_sort_test.rb | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 sorting/bogo_sort_test.rb diff --git a/sorting/bogo_sort.rb b/sorting/bogo_sort.rb index c447cd5..c792026 100644 --- a/sorting/bogo_sort.rb +++ b/sorting/bogo_sort.rb @@ -13,6 +13,8 @@ class Array end end -puts "Enter a list of numbers separated by space" -str = gets.chomp.split('') -puts str.bogosort.join('') +if $0 == __FILE__ + puts "Enter a list of numbers separated by space" + str = gets.chomp.split('') + puts str.bogosort.join('') +end diff --git a/sorting/bogo_sort_test.rb b/sorting/bogo_sort_test.rb new file mode 100644 index 0000000..3fc6e83 --- /dev/null +++ b/sorting/bogo_sort_test.rb @@ -0,0 +1,16 @@ +require 'minitest/autorun' +require_relative './bogo_sort' + +class TestBogoSort < Minitest::Test + def test_sorted_array + input = [1, 2, 3, 4, 5] + expected = input.dup + assert_equal expected, input.bogosort + end + + def test_reversed_array + input = [5, 4, 3, 2, 1] + expected = [1, 2, 3, 4, 5] + assert_equal expected, input.bogosort + end +end From f3dc923ccb368551b6207188f702746e6c3bd93b Mon Sep 17 00:00:00 2001 From: vzvu3k6k Date: Tue, 27 Oct 2020 05:41:54 +0900 Subject: [PATCH 2/6] Add Rakefile to run tests --- Rakefile | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Rakefile diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..d4dcdd1 --- /dev/null +++ b/Rakefile @@ -0,0 +1,7 @@ +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.test_files = FileList['**/*_test.rb'] +end + +task default: :test From 99b940ec8efda4c7abc0d1c630b106d82d562f3d Mon Sep 17 00:00:00 2001 From: vzvu3k6k Date: Tue, 27 Oct 2020 05:42:18 +0900 Subject: [PATCH 3/6] Run tests on CI --- .github/workflows/test.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..cfca6b2 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,12 @@ +name: test +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: actions/setup-ruby@master + with: + ruby-version: '2.7' + - name: Run tests + run: rake test From d6e44e6afaedf9ff9cd90021fc7642424a6d0ed0 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Sat, 14 Nov 2020 18:53:02 +0000 Subject: [PATCH 4/6] updating DIRECTORY.md --- DIRECTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 48513cb..2fcb289 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -42,6 +42,7 @@ ## Sorting * [Bogo Sort](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/bogo_sort.rb) + * [Bogo Sort Test](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/bogo_sort_test.rb) * [Bubble Sort](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/bubble_sort.rb) * [Bucket Sort](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/bucket_sort.rb) * [Heap Sort](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/heap_sort.rb) From 40b463589524c7b3c7c167565eb3b38f2f509def Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Mon, 28 Dec 2020 09:00:19 -0800 Subject: [PATCH 5/6] Update DIRECTORY.md --- DIRECTORY.md | 1 - 1 file changed, 1 deletion(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index 2fcb289..48513cb 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -42,7 +42,6 @@ ## Sorting * [Bogo Sort](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/bogo_sort.rb) - * [Bogo Sort Test](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/bogo_sort_test.rb) * [Bubble Sort](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/bubble_sort.rb) * [Bucket Sort](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/bucket_sort.rb) * [Heap Sort](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/heap_sort.rb) From 082a02e7613545a63a253fc926e53129d3cb726b Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Mon, 28 Dec 2020 17:00:35 +0000 Subject: [PATCH 6/6] updating DIRECTORY.md --- DIRECTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 48513cb..2fcb289 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -42,6 +42,7 @@ ## Sorting * [Bogo Sort](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/bogo_sort.rb) + * [Bogo Sort Test](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/bogo_sort_test.rb) * [Bubble Sort](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/bubble_sort.rb) * [Bucket Sort](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/bucket_sort.rb) * [Heap Sort](https://github.com/TheAlgorithms/Ruby/blob/master/sorting/heap_sort.rb)