├── img ├── 1.png ├── hi.gif ├── help.gif ├── question.gif ├── bot_avatar.png ├── question_1.gif ├── question_2.gif ├── question_3.gif ├── slack_bot_i.gif ├── wolfram_api.gif ├── help_are_you_there.gif └── help_could_you_please.gif ├── .rspec ├── config.ru ├── Gemfile ├── spec ├── bot_spec.rb └── spec_helper.rb ├── .stickler.yml ├── .rubocop.yml ├── TUTORIAL.md ├── LICENSE ├── .gitignore ├── mb_ruby └── bot.rb ├── Gemfile.lock └── README.md /img/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardovaltierra/slackbot/HEAD/img/1.png -------------------------------------------------------------------------------- /img/hi.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardovaltierra/slackbot/HEAD/img/hi.gif -------------------------------------------------------------------------------- /img/help.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardovaltierra/slackbot/HEAD/img/help.gif -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --require spec_helper 2 | --require 'slack-ruby-bot/rspec' 3 | --format documentation -------------------------------------------------------------------------------- /img/question.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardovaltierra/slackbot/HEAD/img/question.gif -------------------------------------------------------------------------------- /img/bot_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardovaltierra/slackbot/HEAD/img/bot_avatar.png -------------------------------------------------------------------------------- /img/question_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardovaltierra/slackbot/HEAD/img/question_1.gif -------------------------------------------------------------------------------- /img/question_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardovaltierra/slackbot/HEAD/img/question_2.gif -------------------------------------------------------------------------------- /img/question_3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardovaltierra/slackbot/HEAD/img/question_3.gif -------------------------------------------------------------------------------- /img/slack_bot_i.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardovaltierra/slackbot/HEAD/img/slack_bot_i.gif -------------------------------------------------------------------------------- /img/wolfram_api.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardovaltierra/slackbot/HEAD/img/wolfram_api.gif -------------------------------------------------------------------------------- /img/help_are_you_there.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardovaltierra/slackbot/HEAD/img/help_are_you_there.gif -------------------------------------------------------------------------------- /img/help_could_you_please.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ricardovaltierra/slackbot/HEAD/img/help_could_you_please.gif -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | $LOAD_PATH.unshift(File.dirname(__FILE__)) 2 | 3 | require 'slack-ruby-bot' 4 | require 'dotenv' 5 | Dotenv.load 6 | 7 | require 'wolfram' 8 | require 'mb_ruby/bot' 9 | MbRuby::Bot.instance.run -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } 6 | 7 | gem 'slack-ruby-bot' 8 | gem 'dotenv' 9 | gem 'wolfram' 10 | 11 | #rspec dependencies 12 | group :development, :test do 13 | gem 'rack-test' 14 | gem 'rspec' 15 | gem 'vcr' 16 | gem 'webmock' 17 | end -------------------------------------------------------------------------------- /spec/bot_spec.rb: -------------------------------------------------------------------------------- 1 | 2 | describe SlackRubyBot::App do 3 | 4 | def app 5 | SlackRubyBot::App.new 6 | end 7 | it_behaves_like 'a slack ruby bot' 8 | 9 | describe '.instance' do 10 | it 'creates an instance of the App subclass' do 11 | klass = Class.new(SlackRubyBot::App) 12 | expect(klass.instance.class).to be klass 13 | end 14 | end 15 | 16 | describe 'executable' do 17 | it 'can be required as a dependency' do 18 | response = system("ruby -e \"Bundler = nil ; require 'slack-ruby-bot'\"") 19 | expect(response).to be true 20 | end 21 | end 22 | end -------------------------------------------------------------------------------- /.stickler.yml: -------------------------------------------------------------------------------- 1 | # add the linters you want stickler to use for this project 2 | linters: 3 | rubocop: 4 | display_cop_names: true 5 | # indicate where is the config file for stylelint 6 | config: './rubocop.yml' 7 | 8 | # add the files here you want to be ignored by stylelint 9 | files: 10 | ignore: 11 | - "db/*" 12 | - "config/*" 13 | - "Guardfile" 14 | - "Rakefile" 15 | 16 | # PLEASE DO NOT enable auto fixing options 17 | # if you need extra support from you linter - do it in your local env as described in README for this config 18 | 19 | # find full documentation here: https://stickler-ci.com/docs 20 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | Exclude: 3 | - "bin/*" 4 | - "db/**/*" 5 | - "config/**/*" 6 | - "Guardfile" 7 | - "Rakefile" 8 | DisplayCopNames: true 9 | 10 | Metrics/ModuleLength: 11 | Max: 150 12 | Metrics/MethodLength: 13 | Include: ["app/controllers/*"] 14 | Max: 20 15 | Metrics/AbcSize: 16 | Include: ["app/controllers/*"] 17 | Max: 30 18 | Metrics/ClassLength: 19 | Max: 150 20 | Metrics/CyclomaticComplexity: 21 | Max: 8 22 | Metrics/PerceivedComplexity: 23 | Max: 10 24 | Metrics/BlockLength: 25 | ExcludedMethods: ['describe'] 26 | 27 | 28 | 29 | Style/Documentation: 30 | Enabled: false 31 | Style/ClassAndModuleChildren: 32 | Enabled: false 33 | Style/CaseEquality: 34 | Enabled: false 35 | Style/ConditionalAssignment: 36 | Enabled: false 37 | 38 | Layout/AlignHash: 39 | EnforcedColonStyle: key 40 | Layout/LineLength: 41 | Max: 150 42 | Layout/ExtraSpacing: 43 | AllowForAlignment: false 44 | Layout/MultilineMethodCallIndentation: 45 | Enabled: true 46 | EnforcedStyle: indented 47 | -------------------------------------------------------------------------------- /TUTORIAL.md: -------------------------------------------------------------------------------- 1 | ## Register Bot Tutorial 2 | 3 | In this tutorial we'll register our [Slack Bot Integration](http://slack.com/services/new/bot) and [Wolfram API](https://account.wolfram.com/auth/sign-in) to get our access tokens. 4 | 5 | ### Slack API 6 | 7 | 1. Once on the [bot](http://slack.com/services/new/bot) section, type Bot's name and click Add 8 | 2. Copy your token and fill out as many fields as you want, altough I recommend to give an avatar and description. Click Save 9 | 3. Once we are on our channel, just click 'Add an app' and select it 10 | 11 | ![Slack Bot Integration](img/slack_bot_i.gif) 12 | 13 | ### Wolfram API 14 | 15 | 1. On the [auth page](https://account.wolfram.com/auth/sign-in) click 'Create one' 16 | 2. Fill out the fields and click 'Create a Wolfram ID' 17 | 3. Now that you have credentials go [here](https://products.wolframalpha.com/api/) on Get API Access 18 | 4. Go 'Sign up to get your first AppID' and fill all the required fields 19 | 5. Remember to copy your AppID 20 | 21 | ![Slack Bot Integration](img/wolfram_api.gif) 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 ricardovaltierra 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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | *.txt 4 | /.config 5 | /coverage/ 6 | /InstalledFiles 7 | /pkg/ 8 | /spec/reports/ 9 | /spec/examples.txt 10 | /test/tmp/ 11 | /test/version_tmp/ 12 | /tmp/ 13 | 14 | # Used by dotenv library to load environment variables. 15 | .env 16 | 17 | # Ignore Byebug command history file. 18 | .byebug_history 19 | 20 | ## Specific to RubyMotion: 21 | .dat* 22 | .repl_history 23 | build/ 24 | *.bridgesupport 25 | build-iPhoneOS/ 26 | build-iPhoneSimulator/ 27 | 28 | ## Specific to RubyMotion (use of CocoaPods): 29 | # 30 | # We recommend against adding the Pods directory to your .gitignore. However 31 | # you should judge for yourself, the pros and cons are mentioned at: 32 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 33 | # 34 | # vendor/Pods/ 35 | 36 | ## Documentation cache and generated files: 37 | /.yardoc/ 38 | /_yardoc/ 39 | /doc/ 40 | /rdoc/ 41 | 42 | ## Environment normalization: 43 | /.bundle/ 44 | /vendor/bundle 45 | /lib/bundler/man/ 46 | 47 | # for a library or gem, you might want to ignore these files since the code is 48 | # intended to run in multiple environments; otherwise, check them in: 49 | # Gemfile.lock 50 | # .ruby-version 51 | # .ruby-gemset 52 | 53 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 54 | .rvmrc 55 | 56 | # Used by RuboCop. Remote config files pulled in from inherit_from directive. 57 | # .rubocop-https?--* 58 | -------------------------------------------------------------------------------- /mb_ruby/bot.rb: -------------------------------------------------------------------------------- 1 | module MbRuby 2 | class Bot < SlackRubyBot::Bot 3 | help do 4 | title 'About me' 5 | desc 'Bot for searching purposes. Ask for something that you would usually google to get it fast' 6 | 7 | command :are_you_there? do 8 | title 'are you there?' 9 | desc "Welcome command, to recieve you properly :)" 10 | long_desc "\n\nI'll give you a brief explanation of how can you interact with me" 11 | end 12 | 13 | command :Could_you_please? do 14 | title 'Could you please' 15 | desc "Ask me..." 16 | long_desc "\n\nBegin a sentence to ask me something like: 'Could you please tell me the distance between" + 17 | " Earth and Sun?' \n\nOr: Could you please tell me what time is on Paris?" + 18 | "\n\nPlease avoid personal questions. I refuse to guess." 19 | end 20 | end 21 | end 22 | 23 | class WFSearch < SlackRubyBot::Commands::Base 24 | 25 | command 'are you there?' do |client, data, _match| 26 | client.say(channel: data.channel, text: HelloText.say_hello) 27 | end 28 | 29 | command 'Could you please' do |client, data, _match| 30 | 31 | q = _match[:expression] 32 | result = Wolfram::Query.new(q).fetch 33 | hash = Wolfram::HashPresenter.new(result).to_hash 34 | 35 | result = "" 36 | 37 | hash.fetch(:pods, {}).each do |key, values| 38 | next if values.join("") == "" 39 | result << "\n" + key + "\n" 40 | result << values.join("\n") 41 | end 42 | 43 | if result != "" 44 | client.message text: "Here's your answer: \n" + result, channel: data.channel 45 | else 46 | client.message text: " 47 | Sorry, I don't know \nBut you find it here! \n 48 | https://duckduckgo.com/?q=#{URI.escape(q)}+!google", 49 | channel: data.channel 50 | end 51 | end 52 | end 53 | 54 | class HelloText 55 | def self.say_hello 56 | "Hello, I'm your Research Bot Assistant! \nAsk me anything (altough I'm not a smarty) and I'll show up what you need \nOtherwize I'll google it! :D" 57 | end 58 | end 59 | end -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | activesupport (6.0.3.2) 5 | concurrent-ruby (~> 1.0, >= 1.0.2) 6 | i18n (>= 0.7, < 2) 7 | minitest (~> 5.1) 8 | tzinfo (~> 1.1) 9 | zeitwerk (~> 2.2, >= 2.2.2) 10 | addressable (2.8.1) 11 | public_suffix (>= 2.0.2, < 6.0) 12 | concurrent-ruby (1.1.6) 13 | crack (0.4.3) 14 | safe_yaml (~> 1.0.0) 15 | diff-lcs (1.3) 16 | dotenv (2.7.5) 17 | faraday (0.17.3) 18 | multipart-post (>= 1.2, < 3) 19 | faraday_middleware (0.13.1) 20 | faraday (>= 0.7.4, < 1.0) 21 | gli (2.19.0) 22 | hashdiff (1.0.0) 23 | hashie (4.0.0) 24 | i18n (1.8.5) 25 | concurrent-ruby (~> 1.0) 26 | mini_portile2 (2.4.0) 27 | minitest (5.14.1) 28 | multipart-post (2.1.1) 29 | nokogiri (1.10.10) 30 | mini_portile2 (~> 2.4.0) 31 | public_suffix (5.0.0) 32 | rack (2.2.4) 33 | rack-test (1.1.0) 34 | rack (>= 1.0, < 3) 35 | rspec (3.9.0) 36 | rspec-core (~> 3.9.0) 37 | rspec-expectations (~> 3.9.0) 38 | rspec-mocks (~> 3.9.0) 39 | rspec-core (3.9.1) 40 | rspec-support (~> 3.9.1) 41 | rspec-expectations (3.9.0) 42 | diff-lcs (>= 1.2.0, < 2.0) 43 | rspec-support (~> 3.9.0) 44 | rspec-mocks (3.9.1) 45 | diff-lcs (>= 1.2.0, < 2.0) 46 | rspec-support (~> 3.9.0) 47 | rspec-support (3.9.2) 48 | safe_yaml (1.0.5) 49 | slack-ruby-bot (0.12.0) 50 | hashie 51 | slack-ruby-client (>= 0.14.0) 52 | slack-ruby-client (0.14.5) 53 | activesupport 54 | faraday (>= 0.9) 55 | faraday_middleware 56 | gli 57 | hashie 58 | websocket-driver 59 | thread_safe (0.3.6) 60 | tzinfo (1.2.10) 61 | thread_safe (~> 0.1) 62 | vcr (5.0.0) 63 | webmock (3.7.6) 64 | addressable (>= 2.3.6) 65 | crack (>= 0.3.2) 66 | hashdiff (>= 0.4.0, < 2.0.0) 67 | websocket-driver (0.7.1) 68 | websocket-extensions (>= 0.1.0) 69 | websocket-extensions (0.1.4) 70 | wolfram (0.2.1) 71 | nokogiri (>= 1.4.3) 72 | zeitwerk (2.4.0) 73 | 74 | PLATFORMS 75 | ruby 76 | 77 | DEPENDENCIES 78 | dotenv 79 | rack-test 80 | rspec 81 | slack-ruby-bot 82 | vcr 83 | webmock 84 | wolfram 85 | 86 | BUNDLED WITH 87 | 1.17.2 88 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Slackbot 2 | 3 | > Microverse Ruby Capstone Project. 4 | 5 |

6 |
7 | Explore the repo » 8 |
9 | Request Feature 10 |

11 | 12 | ## Table of Contents 13 | 14 | * [About the Project](#about-the-project) 15 | 16 | * [Preview](#preview) 17 | 18 | * [Built With](#built-with) 19 | 20 | * [Getting Started](#getting-started) 21 | 22 | * [How it Works](#how-it-works) 23 | 24 | * [Contributing](#contributing) 25 | 26 | * [Contact](#contact) 27 | 28 | * [MIT License](#mit-license) 29 | 30 | ## About The Project 31 | 32 | Slack bot developed on official Wolfram and Slack API's resources to interact on a given workspace and make questions like weather, location places, and more. 33 | 34 | It allows you to make a quick web query by asking your bot without leaving Slack. 35 | 36 | ## Preview 37 | 38 | 39 | 40 | 41 | 42 | Feel free to use and recommend it. 43 | 44 | ## Built With 45 | 46 | * [Ruby =< 2.6.5](https://www.ruby-lang.org/en/) 47 | 48 | * [YAML](https://yaml.org/) 49 | 50 | * [Slack-Ruby-Bot](https://github.com/slack-ruby/slack-ruby-bot#slack-ruby-bot) 51 | 52 | * [Slack API](http://api.slack.com) 53 | 54 | * [Wolfram API](https://account.wolfram.com/auth/sign-in) 55 | 56 | ## Getting Started 57 | 58 | To get a local copy up and running follow these simple steps. 59 | 60 | Clone or fork the repo [git@github.com:ricardovaltierra/slackbot.git]. 61 | 62 | ## How it Works 63 | 64 | ### Step 1: Clone and install dependencies 65 | 66 | Clone the repo and run `bundle install` to get all the gems on your terminal. 67 | 68 | ### Step 2: Get your tokens for Slack & Wolfram APIs 69 | 70 | You will have to register on [WolframID](http://account.wolfram.com/wolframid) and [Slack Bot Integration](http://slack.com/services/new/bot) to get your access tokens (for a register tutorial on Slack and Wolfram click [here](TUTORIAL.md)). Once that done just paste on your `.env` file. 71 | 72 | ### Step 3: Add your bot to a channel and run 73 | 74 | You're almost done with code part. Now just execute with `rackup` and have fun! Above are some examples, but feel free to see description of each command with '@your_bot's_name are you there?' or '@your_bot's_name help'. 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | Also feel free to play with the code for some commands, like changing responses or adding them on `bot.rb`. 83 | 84 | ## Contributing 85 | 86 | Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. 87 | 88 | 1. Fork the Project. 89 | 90 | 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`). 91 | 92 | 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`). 93 | 94 | 4. Push to the Branch (`git push origin feature/AmazingFeature`). 95 | 96 | 5. Open a Pull Request. 97 | 98 | ## Contact 99 | 100 | Ricardo Valtierra - [@RicardoValtie15](https://twitter.com/RicardoValtie15) - ricardo_valtierra@outlook.com - [linkedin.com/in/ricardovaltierra/](https://www.linkedin.com/in/ricardovaltierra/) 101 | 102 | ## MIT License 103 | 104 | This project is under the [MIT](LICENSE) license. 105 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'slack-ruby-bot/rspec' 2 | 3 | # This file was generated by the `rspec --init` command. Conventionally, all 4 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 5 | # The generated `.rspec` file contains `--require spec_helper` which will cause 6 | # this file to always be loaded, without a need to explicitly require it in any 7 | # files. 8 | # 9 | # Given that it is always loaded, you are encouraged to keep this file as 10 | # light-weight as possible. Requiring heavyweight dependencies from this file 11 | # will add to the boot time of your test suite on EVERY test run, even for an 12 | # individual file that may not need all of that loaded. Instead, consider making 13 | # a separate helper file that requires the additional dependencies and performs 14 | # the additional setup, and require it from the spec files that actually need 15 | # it. 16 | # 17 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 18 | RSpec.configure do |config| 19 | # rspec-expectations config goes here. You can use an alternate 20 | # assertion/expectation library such as wrong or the stdlib/minitest 21 | # assertions if you prefer. 22 | config.expect_with :rspec do |expectations| 23 | # This option will default to `true` in RSpec 4. It makes the `description` 24 | # and `failure_message` of custom matchers include text for helper methods 25 | # defined using `chain`, e.g.: 26 | # be_bigger_than(2).and_smaller_than(4).description 27 | # # => "be bigger than 2 and smaller than 4" 28 | # ...rather than: 29 | # # => "be bigger than 2" 30 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 31 | end 32 | 33 | # rspec-mocks config goes here. You can use an alternate test double 34 | # library (such as bogus or mocha) by changing the `mock_with` option here. 35 | config.mock_with :rspec do |mocks| 36 | # Prevents you from mocking or stubbing a method that does not exist on 37 | # a real object. This is generally recommended, and will default to 38 | # `true` in RSpec 4. 39 | mocks.verify_partial_doubles = true 40 | end 41 | 42 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will 43 | # have no way to turn it off -- the option exists only for backwards 44 | # compatibility in RSpec 3). It causes shared context metadata to be 45 | # inherited by the metadata hash of host groups and examples, rather than 46 | # triggering implicit auto-inclusion in groups with matching metadata. 47 | config.shared_context_metadata_behavior = :apply_to_host_groups 48 | 49 | # The settings below are suggested to provide a good initial experience 50 | # with RSpec, but feel free to customize to your heart's content. 51 | =begin 52 | # This allows you to limit a spec run to individual examples or groups 53 | # you care about by tagging them with `:focus` metadata. When nothing 54 | # is tagged with `:focus`, all examples get run. RSpec also provides 55 | # aliases for `it`, `describe`, and `context` that include `:focus` 56 | # metadata: `fit`, `fdescribe` and `fcontext`, respectively. 57 | config.filter_run_when_matching :focus 58 | 59 | # Allows RSpec to persist some state between runs in order to support 60 | # the `--only-failures` and `--next-failure` CLI options. We recommend 61 | # you configure your source control system to ignore this file. 62 | config.example_status_persistence_file_path = "spec/examples.txt" 63 | 64 | # Limits the available syntax to the non-monkey patched syntax that is 65 | # recommended. For more details, see: 66 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 67 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 68 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 69 | config.disable_monkey_patching! 70 | 71 | # This setting enables warnings. It's recommended, but in some cases may 72 | # be too noisy due to issues in dependencies. 73 | config.warnings = true 74 | 75 | # Many RSpec users commonly either run the entire suite or an individual 76 | # file, and it's useful to allow more verbose output when running an 77 | # individual spec file. 78 | if config.files_to_run.one? 79 | # Use the documentation formatter for detailed output, 80 | # unless a formatter has already been configured 81 | # (e.g. via a command-line flag). 82 | config.default_formatter = "doc" 83 | end 84 | 85 | # Print the 10 slowest examples and example groups at the 86 | # end of the spec run, to help surface which specs are running 87 | # particularly slow. 88 | config.profile_examples = 10 89 | 90 | # Run specs in random order to surface order dependencies. If you find an 91 | # order dependency and want to debug it, you can fix the order by providing 92 | # the seed, which is printed after each run. 93 | # --seed 1234 94 | config.order = :random 95 | 96 | # Seed global randomization in this process using the `--seed` CLI option. 97 | # Setting this allows you to use `--seed` to deterministically reproduce 98 | # test failures related to randomization by passing the same `--seed` value 99 | # as the one that triggered the failure. 100 | Kernel.srand config.seed 101 | =end 102 | end 103 | --------------------------------------------------------------------------------