Skip to content

Commit

Permalink
Update README.md with images, change test due to codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
Murchibik committed Feb 9, 2022
1 parent 9a897c5 commit 9c61838
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 57 deletions.
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
# test-task-skeleton
# Test task skeleton
**Repository for test task for Ruby Internship 2022**

As participant you should fork this repository, add needed code in file `test_skeleton.rb` and create contribute request to main repository.

Beforehand you should install Ruby 2.7 and gem Rspec (`gem install rspec`)
***How to fork repository***

Tests should be passed before creating contribute request. For running tests you should run `ruby test.rb` in directory of repository
![how to fork](./images/1.png)

Beforehand you should install Ruby 2.7 and gem Rspec (`gem install rspec`). Tests should be passed before creating contribute request. For running tests you should run `rspec` in directory of repository

***If you will try run `rspec` after cloning repository to local directory you will get this***

![failed run](./images/2.jpg)

***Then you should add correct code here***

![code](./images/3.png)

***and after that number of failures should decrease, repeat this until you all tests will be passed***

![success](./images/4.jpg)

***After that you could create contribute pull request or just send link of repository***

![contribute](./images/5.jpg)

List of tasks to implement(All credits to https://codewars.com):
* [Even or Odd](https://github.com/Murchibik/test-task-skeleton/blob/main/test_skeleton.rb#L12)
Expand Down
Binary file added images/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions spec/test_sceleton_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# frozen_string_literal: true

require_relative '../test_skeleton.rb'

RSpec.describe TestSkeleton do
let(:suite) { described_class.new }

describe '#even_or_odd' do
context 'when number is given' do
it 'should return word "even" or "odd"' do
expect(suite.even_or_odd(0)).to eq('even')
expect(suite.even_or_odd(121)).to eq('odd')
expect(suite.even_or_odd(-5)).to eq('odd')
expect(suite.even_or_odd(44)).to eq('even')
end
end
end

describe '#reverse_array' do
context 'when number is given' do
it 'should return reversed array of digits' do
expect(suite.reverse_array(12)).to eq([2, 1])
expect(suite.reverse_array(5896)).to eq([6, 9, 8, 5])
expect(suite.reverse_array(0)).to eq([0])
expect(suite.reverse_array(62854)).to eq([4, 5, 8, 2, 6])
end
end
end

describe '#high_and_low' do
context 'when string with numbers is given' do
it 'should return highest and lowest numbers' do
expect(suite.high_and_low('0 1 2 3 4 5')).to eq('5 0')
expect(suite.high_and_low('-3 -2 -1 0 1 2 3')).to eq('3 -3')
expect(suite.high_and_low('0')).to eq('0 0')
expect(suite.high_and_low('-3 -2 -1')).to eq('-1 -3')
end
end
end

describe '#my_languages' do
context 'when hash with string keys is given' do
it 'should return array of keys where value more than 60' do
expect(suite.my_languages('Hindi' => 65, 'Greek' => 70, 'German' => 20)).to eq(%w[Hindi Greek])
expect(suite.my_languages({})).to eq([])
expect(suite.my_languages('A' => 30, 'B' => 50, 'C' => 25)).to eq([])
end
end
end

describe '#remove_array_elements' do
context 'when two arrays is given' do
it 'should return array of numbers that not in second array' do
expect(suite.remove_array_elements([1, 2], [1])).to eq([2])
expect(suite.remove_array_elements([1, 1, 2, 5, 3, 3], [1, 3])).to eq([2, 5])
expect(suite.remove_array_elements([1, 2, 3, 4, nil, nil], [1, 2, nil])).to eq([3, 4])
end
end
end

describe '#consecutive_duplicates' do
context 'when string with words is given' do
it 'should return string where words not consecutive repeated' do
expect(suite.consecutive_duplicates('aa bb bb cc dd')).to eq('aa bb cc dd')
expect(suite.consecutive_duplicates('apple banana cherry')).to eq('apple banana cherry')
expect(suite.consecutive_duplicates('aaa aaa aaa bbb bbb bbb aaa aaa ccc ccc ddd')).to eq('aaa bbb aaa ccc ddd')
end
end
end

describe '#middle_chars' do
context 'when string is given' do
it 'should return middle character(s) of string' do
expect(suite.middle_chars('A')).to eq('A')
expect(suite.middle_chars('Cherry')).to eq('r')
expect(suite.middle_chars('push')).to eq('us')
expect(suite.middle_chars('Do Androids Dream of Electric Sheep?')).to eq(' o')
end
end
end

end
54 changes: 0 additions & 54 deletions test.rb

This file was deleted.

0 comments on commit 9c61838

Please sign in to comment.