├── lib ├── .gitkeep ├── player.rb ├── rules.rb └── game.rb ├── .rspec ├── Gemfile ├── spec ├── player_spec.rb ├── game_spec.rb └── spec_helper.rb ├── .github └── workflows │ └── linters.yml ├── Gemfile.lock ├── rubocop.yml ├── LICENSE ├── bin └── main.rb └── README.md /lib/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --require spec_helper 2 | --format documentation -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } 4 | gem 'rubocop', '~>0.81.0' 5 | # gem "rails" 6 | -------------------------------------------------------------------------------- /lib/player.rb: -------------------------------------------------------------------------------- 1 | # Class for player 2 | class Player 3 | attr_accessor :name, :symbol 4 | 5 | def initialize(name, symbol) 6 | @name = name 7 | @symbol = symbol 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/player_spec.rb: -------------------------------------------------------------------------------- 1 | require_relative '../lib/player' 2 | 3 | describe Player do 4 | let(:name) { 'Player' } 5 | let(:symbol) { 'Symbol' } 6 | let(:player) { Player.new(name, symbol) } 7 | 8 | context 'initialize' do 9 | it "Start the Player's name" do 10 | expect(player.name).to eql('Player') 11 | end 12 | 13 | it "Start the player's symbol" do 14 | expect(player.symbol).to eql('Symbol') 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /.github/workflows/linters.yml: -------------------------------------------------------------------------------- 1 | name: Linters 2 | 3 | on: pull_request 4 | 5 | jobs: 6 | rubocop: 7 | name: Rubocop 8 | runs-on: ubuntu-18.04 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: actions/setup-ruby@v1 12 | with: 13 | ruby-version: 2.6.x 14 | - name: Setup Rubocop 15 | run: | 16 | gem install --no-document rubocop:'~>0.81.0' # https://docs.rubocop.org/en/stable/installation/ 17 | [ -f .rubocop.yml ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ruby/.rubocop.yml 18 | - name: Rubocop Report 19 | run: rubocop --color 20 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | ast (2.4.1) 5 | jaro_winkler (1.5.4) 6 | parallel (1.20.1) 7 | parser (2.7.2.0) 8 | ast (~> 2.4.1) 9 | rainbow (3.0.0) 10 | rexml (3.2.4) 11 | rubocop (0.81.0) 12 | jaro_winkler (~> 1.5.1) 13 | parallel (~> 1.10) 14 | parser (>= 2.7.0.1) 15 | rainbow (>= 2.2.2, < 4.0) 16 | rexml 17 | ruby-progressbar (~> 1.7) 18 | unicode-display_width (>= 1.4.0, < 2.0) 19 | ruby-progressbar (1.10.1) 20 | unicode-display_width (1.7.0) 21 | 22 | PLATFORMS 23 | ruby 24 | x64-mingw32 25 | 26 | DEPENDENCIES 27 | rubocop (~> 0.81.0) 28 | 29 | BUNDLED WITH 30 | 2.1.4 31 | -------------------------------------------------------------------------------- /lib/rules.rb: -------------------------------------------------------------------------------- 1 | # Class to initialize RULES 2 | class Rules 3 | attr_reader :rules 4 | 5 | def initialize 6 | @rules = rules 7 | end 8 | 9 | def display_rules 10 | " \n === WELCOME TO TIC TAC TOE === 11 | Game Rules: 12 | 1. Type the name of Player1, which will be signed to the symbol 'X'; 13 | 2. Type the name of Player2, which will be signed to the symbol 'O'; 14 | 3. Now the first player ('X') can select any space to insert the value, 15 | follow your number keyboard to compare the available spaces: 16 | 7 | 8 | 9 17 | ----------- 18 | 4 | 5 | 6 --> The number in the virtual board will be represented by the number on your keyboard. 19 | ----------- 20 | 1 | 2 | 3 21 | 4. Remember not to insert any invalid number (above 9) 22 | or repeat the same number that is already taken by a symbol (no cheating!!); 23 | 5. The winner will be the first player/symbol to complete a sequence of a row, column, or diagonal. 24 | Good luck and have fun! :) \n " 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | Exclude: 3 | - "Guardfile" 4 | - "Rakefile" 5 | 6 | DisplayCopNames: true 7 | 8 | Layout/LineLength: 9 | Max: 120 10 | Metrics/MethodLength: 11 | Max: 20 12 | Metrics/AbcSize: 13 | Max: 50 14 | Metrics/ClassLength: 15 | Max: 150 16 | Metrics/BlockLength: 17 | ExcludedMethods: ['describe'] 18 | Max: 30 19 | 20 | 21 | Style/Documentation: 22 | Enabled: false 23 | Style/ClassAndModuleChildren: 24 | Enabled: false 25 | Style/EachForSimpleLoop: 26 | Enabled: false 27 | Style/AndOr: 28 | Enabled: false 29 | Style/DefWithParentheses: 30 | Enabled: false 31 | Style/FrozenStringLiteralComment: 32 | EnforcedStyle: never 33 | 34 | Layout/HashAlignment: 35 | EnforcedColonStyle: key 36 | Layout/ExtraSpacing: 37 | AllowForAlignment: false 38 | Layout/MultilineMethodCallIndentation: 39 | Enabled: true 40 | EnforcedStyle: indented 41 | Lint/RaiseException: 42 | Enabled: false 43 | Lint/StructNewOverride: 44 | Enabled: false 45 | Style/HashEachMethods: 46 | Enabled: false 47 | Style/HashTransformKeys: 48 | Enabled: false 49 | Style/HashTransformValues: 50 | Enabled: false 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Ana Paula Hübner & Abdelrhman Amin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/game.rb: -------------------------------------------------------------------------------- 1 | # rubocop:disable Style/RedundantReturn 2 | # rubocop:disable Metrics/PerceivedComplexity 3 | # rubocop:disable Metrics/CyclomaticComplexity 4 | # rubocop:disable Metrics/AbcSize 5 | 6 | require_relative './player' 7 | require_relative './rules' 8 | 9 | # Class to initialize game. 10 | class Game 11 | attr_reader :player1, :player2 12 | 13 | def initialize(player1, player2) 14 | @player1 = Player.new(player1, 'X') 15 | @player2 = Player.new(player2, 'O') 16 | end 17 | 18 | def valid?(pos) 19 | pos = pos.to_i 20 | return true if pos < 10 && pos.positive? && pos != 0 && pos.is_a?(Integer) 21 | 22 | return false 23 | end 24 | 25 | def free?(pos, arr) 26 | pos = pos.to_i - 1 27 | arr.each_with_index do |num, i| 28 | return true if i == pos && num == ' ' 29 | return false if i == pos && num != ' ' 30 | end 31 | end 32 | 33 | def move(pos, arr, turn) 34 | pos = pos.to_i - 1 35 | arr[pos] = turn == true ? player1.symbol : player2.symbol 36 | end 37 | 38 | def did_win?(board) 39 | return true if board[0] == board[1] && board[1] == board[2] && board[0] != ' ' 40 | return true if board[3] == board[4] && board[4] == board[5] && board[3] != ' ' 41 | return true if board[6] == board[7] && board[7] == board[8] && board[6] != ' ' 42 | return true if board[0] == board[3] && board[3] == board[6] && board[0] != ' ' 43 | return true if board[1] == board[4] && board[4] == board[7] && board[1] != ' ' 44 | return true if board[2] == board[5] && board[5] == board[8] && board[2] != ' ' 45 | return true if board[0] == board[4] && board[4] == board[8] && board[0] != ' ' 46 | return true if board[2] == board[4] && board[4] == board[6] && board[2] != ' ' 47 | end 48 | 49 | def did_draw?(board) 50 | return true if board.include?(' ') == false 51 | end 52 | end 53 | 54 | # rubocop:enable Style/RedundantReturn 55 | # rubocop:enable Metrics/CyclomaticComplexity 56 | # rubocop:enable Metrics/PerceivedComplexity 57 | # rubocop:enable Metrics/AbcSize 58 | -------------------------------------------------------------------------------- /bin/main.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # rubocop:disable Metrics/PerceivedComplexity 3 | # rubocop:disable Metrics/CyclomaticComplexity 4 | 5 | require_relative '../lib/player' 6 | require_relative '../lib/rules' 7 | require_relative '../lib/game' 8 | 9 | def display(board) 10 | puts " 11 | #{board[6] == ' ' ? 7 : board[6]} | #{board[7] == ' ' ? 8 : board[7]} | #{board[8] == ' ' ? 9 : board[8]} 12 | ----------- 13 | #{board[3] == ' ' ? 4 : board[3]} | #{board[4] == ' ' ? 5 : board[4]} | #{board[5] == ' ' ? 6 : board[5]} 14 | ----------- 15 | #{board[0] == ' ' ? 1 : board[0]} | #{board[1] == ' ' ? 2 : board[1]} | #{board[2] == ' ' ? 3 : board[2]}" 16 | end 17 | board = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '] 18 | game_on = true 19 | turn = true 20 | game_rules = Rules.new 21 | puts "Would you like to read the game rules/instructions? 22 | (All answers are accepted! [EASTER EGGS!! Excuslive For Christmas!!], ONLY 'no' Will work!)" 23 | answer = gets.chomp.to_s.downcase 24 | if answer == 'no' 25 | puts " \n Ok, let's start the game! \n " 26 | else 27 | puts game_rules.display_rules 28 | end 29 | puts "Please, enter name of Player 'X':" 30 | player1 = gets.chomp 31 | puts "Please, enter name of Player 'O':" 32 | player2 = gets.chomp 33 | game = Game.new(player1, player2) 34 | display(board) 35 | while game_on 36 | if turn 37 | puts "#{player1} is playing... 38 | CHOOSE YOUR POSITION \n " 39 | else 40 | puts "#{player2} is playing... 41 | CHOOSE YOUR POSITION \n " 42 | end 43 | pos = gets.chomp 44 | if game.valid?(pos) 45 | if game.free?(pos, board) == true 46 | game.move(pos, board, turn) 47 | elsif game.free?(pos, board) == false 48 | puts "POSITION #{pos} TAKEN! Please, Try again." 49 | display(board) 50 | next 51 | end 52 | else 53 | puts " \n INVALID NUMBER! Please, Try again." 54 | next 55 | end 56 | display(board) 57 | if game.did_win?(board) 58 | puts turn ? " \n #{player1} Won! CONGRATULATIONS!!! \n " : " \n #{player2} Won! CONGRATULATIONS!!! \n " 59 | break 60 | end 61 | if game.did_draw?(board) 62 | puts " \n IT'S A DRAW! Game is over, but you can always return. \n " 63 | break 64 | end 65 | turn = !turn 66 | end 67 | 68 | # rubocop:enable Metrics/PerceivedComplexity 69 | # rubocop:enable Metrics/CyclomaticComplexity 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](https://img.shields.io/badge/Microverse-blueviolet) 2 | 3 | # Tic Tac Toe 4 | 5 | This project consists of building a Ruby version of Tic Tac Toe game [Tic Tac Toe](https://en.wikipedia.org/wiki/Tic-tac-toe) using **Ruby**. 6 | 7 | ## About the project 8 | 9 | The goal was to use **classes** and **methods** to set up the basic elements of the game. 10 | 11 | The specifications for this project can be found at [The Odin Project](https://www.theodinproject.com/courses/ruby-programming/lessons/oop). 12 | 13 | ## Installation 14 | 15 | No instalation needed, just download/clone this repository [GitHub Repository](https://github.com/anapdh/TicTacToe-Ruby) on your computer. 16 | 17 | ## How to play 18 | 19 | 1. The interface of this game will be your computer's terminal. Search _terminal_ in your computer to open it. 20 | 2. In the terminal, use the command `cd` to go to the place where you have saved/cloned the Tic Tac Toe repository. For example: _Desktop/User/tic-tac-toe/_. 21 | You may use the comand `ls` to see the files and repositories exitent in your current location. 22 | 3. Now, use the comand `cd bin` again to enter the folder and execute `ruby main.rb` in the terminal to start the game. 23 | 4. Enjoy the game! 24 | 25 | ## Game rules 26 | 27 | 1. Type the name of Player1, which will be signed to the symbol 'X'; 28 | 2. Type the name of Player2, which will be signed to the symbol 'O'; 29 | 3. Now the first player ('X') can select any space to insert the value, follow your number keyboard to compare the available spaces: 30 | > 7 | 8 | 9 31 | > ----------- 32 | > 4 | 5 | 6 --> The number in the virtual board will be represented by the number on your keyboard. 33 | > ----------- 34 | > 1 | 2 | 3 35 | 4. Remember not to insert any invalid number (above 9) or repeat the same number that is already taken by a symbol (no cheating!!); 36 | 5. The winner will be the first player/symbol to complete a sequence of a row, column, or diagonal. 37 | 38 | ## Authors 39 | 40 | 👩🏼‍💻 **Ana Paula Hübner** 41 | 42 | - GitHub: [@anapdh](https://github.com/anapdh) 43 | - Twitter: [@dev_anahub](https://twitter.com/dev_anahub) 44 | - LinkedIn: [Ana Paula Hübner](https://www.linkedin.com/in/anapdh) 45 | 46 | 😎 **Abdo Amin** 47 | - GitHub: [@Abdelrhman-Amin](https://github.com/AbdelrhmanAmin) 48 | - Twitter: [@Abdo Amin](https://twitter.com/AbdoAmi60489112) 49 | - LinkedIn: [@Abdo Amin](https://www.linkedin.com/in/abdo-amin-ab786a1b0/) 50 | 51 | 52 | ## 🤝 Contributing 53 | 54 | Contributions, issues, and feature requests are welcome! 55 | 56 | Feel free to check the [issues page](https://github.com/anapdh/enumerable-methods/issues). 57 | 58 | 59 | ## Show your support 60 | 61 | Give a ⭐️ if you like this project! 62 | 63 | 64 | ## 📝 License 65 | 66 | This project is [MIT](./LICENSE) licensed. 67 | -------------------------------------------------------------------------------- /spec/game_spec.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require_relative '../lib/game' 4 | 5 | describe Game do 6 | let(:arr1) { [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '] } 7 | let(:arr2) { [' ', ' ', ' ', 'O', ' ', 'X', ' ', 'O', 'X'] } 8 | let(:player1) { 'Name1' } 9 | let(:player2) { 'Name2' } 10 | let(:game) { Game.new(player1, player2) } 11 | 12 | context 'initialize' do 13 | it 'Start the player 1' do 14 | expect(player1).to eql('Name1') 15 | expect(game.player1.symbol).to eql('X') 16 | end 17 | 18 | it 'Start the player 2' do 19 | expect(player2).to eql('Name2') 20 | expect(game.player2.symbol).to eql('O') 21 | end 22 | end 23 | 24 | context 'valid?' do 25 | it 'checks valid position' do 26 | expect(game.valid?(6)).to eql(true) 27 | expect(game.valid?(11)).to eql(false) 28 | expect(game.valid?(-2)).to eql(false) 29 | expect(game.valid?('q')).to eql(false) 30 | expect(game.valid?('q')).to eql(false) 31 | end 32 | end 33 | 34 | context 'free?' do 35 | it 'check if the position is free' do 36 | expect(game.free?(2, arr1)).to eql(true) 37 | expect(game.free?(8, arr2)).to eql(false) 38 | expect(game.free?(4, arr2)).to eql(false) 39 | expect(game.free?('r', arr1)).to eql(arr1) 40 | expect(game.free?('r', arr2)).to eql(arr2) 41 | expect(game.free?(-2, arr1)).to eql(arr1) 42 | end 43 | end 44 | 45 | context 'move' do 46 | it 'checks the players turns to fill symbols' do 47 | expect(game.move(1, arr1, true)).to eql(game.player1.symbol) 48 | expect(game.move(3, arr2, false)).to eql(game.player2.symbol) 49 | expect(game.move(8, arr1, true)).to eql(game.player1.symbol) 50 | expect(game.move(4, arr2, false)).to eql(game.player2.symbol) 51 | expect(game.move('rwfffaa', arr2, false)).to eql(game.player2.symbol) 52 | expect(game.move('dwafffa', 'jdjas', false)).to eql(game.player2.symbol) 53 | end 54 | end 55 | 56 | context 'winning_conditions' do 57 | it 'checks if the players symbols are the same in 1st, 2nd or 3rd row to win the game' do 58 | game.move(1, arr1, true) 59 | game.move(2, arr1, true) 60 | game.move(3, arr1, true) 61 | expect(game.did_win?(arr1)).to eql(true) 62 | end 63 | it 'checks if the players symbols are the same in 1st, 2nd or 3rd column to win the game' do 64 | game.move(8, arr1, true) 65 | game.move(5, arr1, true) 66 | game.move(2, arr1, true) 67 | expect(game.did_win?(arr1)).to eql(true) 68 | end 69 | it 'checks if the players symbols are the same in the diagonals to win the game' do 70 | game.move(7, arr1, true) 71 | game.move(5, arr1, true) 72 | game.move(3, arr1, true) 73 | expect(game.did_win?(arr1)).to eql(true) 74 | end 75 | it 'checks if the players symbols are NOT the same in the diagonals, returning nil' do 76 | game.move(7, arr1, true) 77 | game.move(5, arr1, false) 78 | game.move(3, arr1, true) 79 | expect(game.did_win?(arr1)).to eql(nil) 80 | end 81 | end 82 | 83 | context 'draw_condition' do 84 | let(:arr1) { %w[X 0 X 0 0 X X 0 0] } 85 | it "check if there's no more empty spaces on the board, so it's a draw" do 86 | expect(game.did_draw?(arr1)).to eql(true) 87 | end 88 | let(:arr2) { [' ', '0', 'X', '0', ' ', 'X', 'X', '0', '0'] } 89 | it "check if there's IS empty spaces on the board" do 90 | expect(game.did_draw?(arr2)).to eql(nil) 91 | end 92 | end 93 | end 94 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # rubocop:disable Style/BlockComments 2 | # This file was generated by the `rspec --init` command. Conventionally, all 3 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 4 | # The generated `.rspec` file contains `--require spec_helper` which will cause 5 | # this file to always be loaded, without a need to explicitly require it in any 6 | # files. 7 | # 8 | # Given that it is always loaded, you are encouraged to keep this file as 9 | # light-weight as possible. Requiring heavyweight dependencies from this file 10 | # will add to the boot time of your test suite on EVERY test run, even for an 11 | # individual file that may not need all of that loaded. Instead, consider making 12 | # a separate helper file that requires the additional dependencies and performs 13 | # the additional setup, and require it from the spec files that actually need 14 | # it. 15 | # 16 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 17 | RSpec.configure do |config| 18 | # rspec-expectations config goes here. You can use an alternate 19 | # assertion/expectation library such as wrong or the stdlib/minitest 20 | # assertions if you prefer. 21 | config.expect_with :rspec do |expectations| 22 | # This option will default to `true` in RSpec 4. It makes the `description` 23 | # and `failure_message` of custom matchers include text for helper methods 24 | # defined using `chain`, e.g.: 25 | # be_bigger_than(2).and_smaller_than(4).description 26 | # # => "be bigger than 2 and smaller than 4" 27 | # ...rather than: 28 | # # => "be bigger than 2" 29 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 30 | end 31 | 32 | # rspec-mocks config goes here. You can use an alternate test double 33 | # library (such as bogus or mocha) by changing the `mock_with` option here. 34 | config.mock_with :rspec do |mocks| 35 | # Prevents you from mocking or stubbing a method that does not exist on 36 | # a real object. This is generally recommended, and will default to 37 | # `true` in RSpec 4. 38 | mocks.verify_partial_doubles = true 39 | end 40 | 41 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will 42 | # have no way to turn it off -- the option exists only for backwards 43 | # compatibility in RSpec 3). It causes shared context metadata to be 44 | # inherited by the metadata hash of host groups and examples, rather than 45 | # triggering implicit auto-inclusion in groups with matching metadata. 46 | config.shared_context_metadata_behavior = :apply_to_host_groups 47 | 48 | # The settings below are suggested to provide a good initial experience 49 | # with RSpec, but feel free to customize to your heart's content. 50 | =begin 51 | # This allows you to limit a spec run to individual examples or groups 52 | # you care about by tagging them with `:focus` metadata. When nothing 53 | # is tagged with `:focus`, all examples get run. RSpec also provides 54 | # aliases for `it`, `describe`, and `context` that include `:focus` 55 | # metadata: `fit`, `fdescribe` and `fcontext`, respectively. 56 | config.filter_run_when_matching :focus 57 | 58 | # Allows RSpec to persist some state between runs in order to support 59 | # the `--only-failures` and `--next-failure` CLI options. We recommend 60 | # you configure your source control system to ignore this file. 61 | config.example_status_persistence_file_path = "spec/examples.txt" 62 | 63 | # Limits the available syntax to the non-monkey patched syntax that is 64 | # recommended. For more details, see: 65 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 66 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 67 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 68 | config.disable_monkey_patching! 69 | 70 | # This setting enables warnings. It's recommended, but in some cases may 71 | # be too noisy due to issues in dependencies. 72 | config.warnings = true 73 | 74 | # Many RSpec users commonly either run the entire suite or an individual 75 | # file, and it's useful to allow more verbose output when running an 76 | # individual spec file. 77 | if config.files_to_run.one? 78 | # Use the documentation formatter for detailed output, 79 | # unless a formatter has already been configured 80 | # (e.g. via a command-line flag). 81 | config.default_formatter = "doc" 82 | end 83 | 84 | # Print the 10 slowest examples and example groups at the 85 | # end of the spec run, to help surface which specs are running 86 | # particularly slow. 87 | config.profile_examples = 10 88 | 89 | # Run specs in random order to surface order dependencies. If you find an 90 | # order dependency and want to debug it, you can fix the order by providing 91 | # the seed, which is printed after each run. 92 | # --seed 1234 93 | config.order = :random 94 | 95 | # Seed global randomization in this process using the `--seed` CLI option. 96 | # Setting this allows you to use `--seed` to deterministically reproduce 97 | # test failures related to randomization by passing the same `--seed` value 98 | # as the one that triggered the failure. 99 | Kernel.srand config.seed 100 | =end 101 | end 102 | # rubocop:enable Style/BlockComments 103 | --------------------------------------------------------------------------------