From 9dc0622f7ff98169db064231c2ca82cef6364529 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Thu, 22 Aug 2019 15:22:20 +0200 Subject: [PATCH] CLI interface based on Thor --- .gitignore | 10 ++++ .rspec_status | 26 ++++++++++ Gemfile | 18 ++----- Gemfile.lock | 59 ++++++++++++++++++--- Rakefile | 6 +++ bin/console | 14 +++++ bin/setup | 8 +++ bin/site | 51 ------------------ bin/supervisor | 58 --------------------- exe/rsmp | 3 ++ features/help.feature | 5 ++ features/site.feature | 9 ++++ features/support/setup.rb | 1 + features/support/site.yaml | 1 + lib/rsmp.rb | 11 ++++ lib/rsmp/cli.rb | 52 +++++++++++++++++++ lib/rsmp/site.rb | 3 +- lib/rsmp/version.rb | 3 ++ rsmp.gemspec | 43 +++++++++++++++ spec/command_spec.rb | 5 +- spec/message_spec.rb | 5 +- spec/rsmp_spec.rb | 7 +++ spec/spec_helper.rb | 104 ++++--------------------------------- spec/supervisor_spec.rb | 6 +-- 24 files changed, 270 insertions(+), 238 deletions(-) create mode 100644 .rspec_status create mode 100644 Rakefile create mode 100755 bin/console create mode 100755 bin/setup delete mode 100755 bin/site delete mode 100755 bin/supervisor create mode 100755 exe/rsmp create mode 100644 features/help.feature create mode 100644 features/site.feature create mode 100644 features/support/setup.rb create mode 100644 features/support/site.yaml create mode 100644 lib/rsmp.rb create mode 100644 lib/rsmp/cli.rb create mode 100644 lib/rsmp/version.rb create mode 100644 rsmp.gemspec create mode 100644 spec/rsmp_spec.rb diff --git a/.gitignore b/.gitignore index 7df2616e..9f4b2108 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,13 @@ ignore .DS_Store +/.bundle/ +/.yardoc +/_yardoc/ +/coverage/ +/doc/ +/pkg/ +/spec/reports/ +/tmp/ + + diff --git a/.rspec_status b/.rspec_status new file mode 100644 index 00000000..028698b3 --- /dev/null +++ b/.rspec_status @@ -0,0 +1,26 @@ +example_id | status | run_time | +-------------------------------- | ------ | --------------- | +./spec/command_spec.rb[1:2] | passed | 0.00356 seconds | +./spec/message_spec.rb[1:1:1] | passed | 0.00092 seconds | +./spec/message_spec.rb[1:1:2] | passed | 0.00008 seconds | +./spec/message_spec.rb[1:1:3] | passed | 0.00012 seconds | +./spec/message_spec.rb[1:1:4] | passed | 0.00008 seconds | +./spec/message_spec.rb[1:1:5] | passed | 0.00039 seconds | +./spec/message_spec.rb[1:2:1] | passed | 0.00073 seconds | +./spec/message_spec.rb[1:2:2] | passed | 0.00011 seconds | +./spec/message_spec.rb[1:2:3] | passed | 0.00008 seconds | +./spec/message_spec.rb[1:2:4] | passed | 0.00014 seconds | +./spec/message_spec.rb[1:2:5] | passed | 0.00094 seconds | +./spec/message_spec.rb[1:2:6] | passed | 0.00147 seconds | +./spec/message_spec.rb[1:2:7] | passed | 0.00008 seconds | +./spec/message_spec.rb[1:2:8] | passed | 0.00005 seconds | +./spec/message_spec.rb[1:2:9] | passed | 0.00008 seconds | +./spec/message_spec.rb[1:3:1] | passed | 0.00008 seconds | +./spec/message_spec.rb[1:3:2] | passed | 0.00011 seconds | +./spec/message_spec.rb[1:3:3] | passed | 0.00008 seconds | +./spec/message_spec.rb[1:3:4] | passed | 0.00006 seconds | +./spec/message_spec.rb[1:3:5] | passed | 0.00007 seconds | +./spec/rsmp_spec.rb[1:1] | passed | 0.00046 seconds | +./spec/supervisor_spec.rb[1:1:1] | passed | 0.00008 seconds | +./spec/supervisor_spec.rb[1:1:2] | passed | 0.00006 seconds | +./spec/supervisor_spec.rb[1:1:3] | passed | 0.00988 seconds | diff --git a/Gemfile b/Gemfile index c2f2ab77..702bc03a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,16 +1,4 @@ -# frozen_string_literal: true +source "https://rubygems.org" -source 'https://rubygems.org' - -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } - -gem 'async' -gem 'async-io' -gem 'colorize' - -group :test do - gem 'rspec' - gem 'rspec-expectations' - gem 'timecop' - gem 'rspec-with_params' -end +# Specify your gem's dependencies in rsmp.gemspec +gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 96e3136f..76f64dbf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,16 +1,58 @@ +PATH + remote: . + specs: + rsmp (0.1.0) + async (~> 1.20.1) + async-io (~> 1.24.0) + colorize (~> 0.8.1) + thor + GEM remote: https://rubygems.org/ specs: + aruba (0.14.11) + childprocess (>= 0.6.3, < 3.0.0) + contracts (~> 0.9) + cucumber (>= 1.3.19) + ffi (~> 1.9) + rspec-expectations (>= 2.99) + thor (~> 0.19) async (1.20.1) console (~> 1.0) nio4r (~> 2.3) timers (~> 4.1) async-io (1.24.0) async (~> 1.14) + backports (3.15.0) + builder (3.2.3) + childprocess (2.0.0) + rake (< 13.0) colorize (0.8.1) console (1.4.0) + contracts (0.16.0) + cucumber (3.1.2) + builder (>= 2.1.2) + cucumber-core (~> 3.2.0) + cucumber-expressions (~> 6.0.1) + cucumber-wire (~> 0.0.1) + diff-lcs (~> 1.3) + gherkin (~> 5.1.0) + multi_json (>= 1.7.5, < 2.0) + multi_test (>= 0.1.2) + cucumber-core (3.2.1) + backports (>= 3.8.0) + cucumber-tag_expressions (~> 1.1.0) + gherkin (~> 5.0) + cucumber-expressions (6.0.1) + cucumber-tag_expressions (1.1.1) + cucumber-wire (0.0.1) diff-lcs (1.3) + ffi (1.11.1) + gherkin (5.1.0) + multi_json (1.13.1) + multi_test (0.1.2) nio4r (2.4.0) + rake (10.5.0) rspec (3.8.0) rspec-core (~> 3.8.0) rspec-expectations (~> 3.8.0) @@ -26,6 +68,7 @@ GEM rspec-support (3.8.0) rspec-with_params (0.2.0) rspec (~> 3.0) + thor (0.20.3) timecop (0.9.1) timers (4.3.0) @@ -33,13 +76,15 @@ PLATFORMS ruby DEPENDENCIES - async - async-io - colorize - rspec - rspec-expectations - rspec-with_params - timecop + aruba (~> 0.14.11) + bundler (~> 2.0) + cucumber (~> 3.1.2) + rake (~> 10.0) + rsmp! + rspec (~> 3.0) + rspec-expectations (~> 3.8.3) + rspec-with_params (~> 0.2.0) + timecop (~> 0.9.1) BUNDLED WITH 2.0.2 diff --git a/Rakefile b/Rakefile new file mode 100644 index 00000000..b7e9ed54 --- /dev/null +++ b/Rakefile @@ -0,0 +1,6 @@ +require "bundler/gem_tasks" +require "rspec/core/rake_task" + +RSpec::Core::RakeTask.new(:spec) + +task :default => :spec diff --git a/bin/console b/bin/console new file mode 100755 index 00000000..e2eb9cf6 --- /dev/null +++ b/bin/console @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby + +require "bundler/setup" +require "rsmp" + +# You can add fixtures and/or initialization code here to make experimenting +# with your gem easier. You can also use a different console, if you like. + +# (If you use this, don't forget to add pry to your Gemfile!) +# require "pry" +# Pry.start + +require "irb" +IRB.start(__FILE__) diff --git a/bin/setup b/bin/setup new file mode 100755 index 00000000..dce67d86 --- /dev/null +++ b/bin/setup @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +set -vx + +bundle install + +# Do any other automated setup that you need to do here diff --git a/bin/site b/bin/site deleted file mode 100755 index 67d88215..00000000 --- a/bin/site +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env ruby -# Note: the shebang above expects ruby to be intalled through rbenv -# -# Executable wrapper for starting an RSMP site -# Expect settings files to be present - -require_relative 'site' -require 'optparse' - -dir = File.dirname(__FILE__) -options = { - site_settings: {} -} - -options_parser = OptionParser.new do |opts| - opts.banner = "Usage: site [options]" - - opts.on('-s IP:PORT', '--supervisors IP:PORT', 'Connect supervisor(s) at IP:PORT,...') do |list| - list = list.split ',' - list.each do |supervisor| - ip, port = supervisor.split ':' - ip = '127.0.0.1' if ip.empty? - port = '12111' if port.empty? - options[:site_settings][:supervisors] = [] unless options[:site_settings][:supervisors] - options[:site_settings][:supervisors] << {"ip"=>ip, "port"=>port} - end - end - - opts.on('-i ID', '--site-id ID', 'Use site id ID') do |id| - options[:site_settings][:site_id] = id - end - - opts.on('-c CONFIG', '--config PATH', 'Path to .yaml config file') do |path| - options[:site_settings_path] = path - end - - opts.on( '-h', '--help', 'Show help' ) do - puts opts - exit - end -end - -begin - options_parser.parse! -rescue OptionParser::ParseError => e - puts e - puts options_parser - exit 1 -end - -RSMP::Site.new(options).start diff --git a/bin/supervisor b/bin/supervisor deleted file mode 100755 index 387d95e0..00000000 --- a/bin/supervisor +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env ruby -# Note: the shebang above expects ruby to be intalled through rbenv -# -# Executable wrapper for starting an RSMP supervisor (server) -# Expect a settings files to be present at config/supervisor.yaml - -require_relative 'supervisor' -require 'optparse' - -dir = File.dirname(__FILE__) -options = { - supervisor_settings: {} -} - -options_parser = OptionParser.new do |opts| - opts.banner = "Usage: supervisor [options]" - - opts.on("-p PORT", "--port P", Integer, "Listen on port P") do |port| - options[:supervisor_settings][:port] = port - end - - opts.on('-i ID', '--site-id ID', 'Use site id ID') do |id| - options[:supervisor_settings][:site_id] = id - end - - opts.on('-s ID', '--sites ID', 'Allow sites with ID,...') do |list| - options[:sites_settings] = [] unless options[:sites_settings] - if list == 'any' - options[:sites_settings] << {"site_id"=>:any} - else - list = list.split ',' - list.each do |id| - options[:sites_settings] << {"site_id"=>id} - end - end - end - - opts.on('-c CONFIG', '--config PATH', 'Path to .yaml config file') do |path| - options[:supervisor_settings_path] = path - end - - opts.on( '-h', '--help', 'Show help' ) do - puts opts - exit - end -end - -begin - options_parser.parse! -rescue OptionParser::ParseError => e - puts e - puts options_parser - exit 1 -end - -supervisor = RSMP::Supervisor.new(options) -supervisor.start - diff --git a/exe/rsmp b/exe/rsmp new file mode 100755 index 00000000..c357b6d2 --- /dev/null +++ b/exe/rsmp @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +require 'rsmp/cli' +RSMP::CLI.start diff --git a/features/help.feature b/features/help.feature new file mode 100644 index 00000000..5bb5f9af --- /dev/null +++ b/features/help.feature @@ -0,0 +1,5 @@ +Feature: Help + + Scenario: Displaying help + When I run `rsmp help` + Then the output should contain "options" diff --git a/features/site.feature b/features/site.feature new file mode 100644 index 00000000..0253b552 --- /dev/null +++ b/features/site.feature @@ -0,0 +1,9 @@ +Feature: Run site + + Scenario: Run with no options + When I run `rsmp site` + Then the output should contain "Starting site" + + Scenario: Port option + When I run `rsmp site --port 12117` + Then the output should contain "Starting site on port 12117" diff --git a/features/support/setup.rb b/features/support/setup.rb new file mode 100644 index 00000000..fb0a661b --- /dev/null +++ b/features/support/setup.rb @@ -0,0 +1 @@ +require 'aruba/cucumber' diff --git a/features/support/site.yaml b/features/support/site.yaml new file mode 100644 index 00000000..b1d43d0b --- /dev/null +++ b/features/support/site.yaml @@ -0,0 +1 @@ +site_id: AXV \ No newline at end of file diff --git a/lib/rsmp.rb b/lib/rsmp.rb new file mode 100644 index 00000000..40e20247 --- /dev/null +++ b/lib/rsmp.rb @@ -0,0 +1,11 @@ +require "rsmp/version" +require "rsmp/supervisor" +require "rsmp/site" +require "rsmp/supervisor_connector" +require "rsmp/site_connector" +require "rsmp/error" +require "rsmp/probe" +require "rsmp/probe_collection" +require "rsmp/message" +require "rsmp/logger" +require "rsmp/archive" diff --git a/lib/rsmp/cli.rb b/lib/rsmp/cli.rb new file mode 100644 index 00000000..dea98dbf --- /dev/null +++ b/lib/rsmp/cli.rb @@ -0,0 +1,52 @@ +require 'thor' +require 'rsmp' + +module RSMP + class CLI < Thor + + desc "site", "Run RSMP site" + method_option :config, :type => :string, :aliases => "-c", banner: 'Path to .yaml config file' + method_option :id, :type => :string, :aliases => "-i", banner: 'RSMP site id' + method_option :supervisors, :type => :string, :aliases => "-s", banner: 'ip:port,... list of supervisor to connect to' + def site + converted = { + site_settings_path: options[:config], + site_settings: { + site_id: options[:id], + } + } + + if options[:supervisors] + options[:supervisors].split(',').each do |supervisor| + converted[:site_settings][:supervisors] ||= [] + ip, port = supervisor.split ':' + ip = '127.0.0.1' if ip.empty? + port = '12111' if port.empty? + converted[:site_settings][:supervisors] << {"ip"=>ip, "port"=>port} + end + end + + converted[:site_settings].compact! + RSMP::Site.new(converted).start + end + + desc "supervisor", "Run RSMP supervisor" + method_option :config, :type => :string, :aliases => "-c", banner: 'Path to .yaml config file' + method_option :id, :type => :string, :aliases => "-i", banner: 'RSMP site id' + method_option :ip, :type => :numeric, banner: 'IP address to listen on' + method_option :port, :type => :string, :aliases => "-p", banner: 'Port to listen on' + def supervisor + converted = { + supervisor_settings_path: options[:config], + supervisor_settings: { + site_id: options[:id], + ip: options[:ip], + port: options[:port] + } + } + converted[:supervisor_settings].compact! + RSMP::Supervisor.new(converted).start + end + + end +end \ No newline at end of file diff --git a/lib/rsmp/site.rb b/lib/rsmp/site.rb index 54f448ab..9810db5b 100644 --- a/lib/rsmp/site.rb +++ b/lib/rsmp/site.rb @@ -53,6 +53,7 @@ def handle_site_settings options if options[:site_settings] converted = options[:site_settings].map { |k,v| [k.to_s,v] }.to_h #convert symbol keys to string keys + converted.compact! @site_settings.merge! converted end @@ -124,7 +125,7 @@ def stop end def starting - log str: "Starting site #{@site_settings["site_id"]} on port #{@site_settings["port"]}", + log str: "Starting site #{@site_settings["site_id"]}", level: :info, timestamp: RSMP.now_object end diff --git a/lib/rsmp/version.rb b/lib/rsmp/version.rb new file mode 100644 index 00000000..636b6aac --- /dev/null +++ b/lib/rsmp/version.rb @@ -0,0 +1,3 @@ +module Rsmp + VERSION = "0.1.0" +end diff --git a/rsmp.gemspec b/rsmp.gemspec new file mode 100644 index 00000000..b0591eb9 --- /dev/null +++ b/rsmp.gemspec @@ -0,0 +1,43 @@ +lib = File.expand_path("lib", __dir__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require "rsmp/version" + +Gem::Specification.new do |spec| + spec.name = "rsmp" + spec.version = Rsmp::VERSION + spec.authors = ["Emil Tin"] + spec.email = ["zf0f@kk.dk"] + + spec.summary = %q{RoadSide Message Protocol (RSMP) library.} + spec.description = %q{Easy RSMP site and supervisor communication.} + spec.homepage = "https://github.com/rsmp-nordic/rsmp" + + spec.metadata["allowed_push_host"] = "https://github.com/rsmp-nordic/rsmp" #TODO: Set to 'http://mygemserver.com'" + + spec.metadata["homepage_uri"] = spec.homepage + spec.metadata["source_code_uri"] = "https://github.com/rsmp-nordic/rsmp" #"TODO: Put your gem's public repo URL here." + spec.metadata["changelog_uri"] = "https://github.com/rsmp-nordic/rsmp" #"TODO: Put your gem's CHANGELOG.md URL here." + + # Specify which files should be added to the gem when it is released. + # The `git ls-files -z` loads the files in the RubyGem that have been added into git. + spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do + `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + end + spec.bindir = "exe" + spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } + spec.require_paths = ["lib"] + + spec.add_dependency "async", "~> 1.20.1" + spec.add_dependency "async-io", "~> 1.24.0" + spec.add_dependency "colorize", "~> 0.8.1" + spec.add_dependency "thor" + + spec.add_development_dependency "bundler", "~> 2.0" + spec.add_development_dependency "rake", "~> 10.0" + spec.add_development_dependency "rspec", "~> 3.0" + spec.add_development_dependency "rspec-expectations", "~> 3.8.3" + spec.add_development_dependency "rspec-with_params", "~> 0.2.0" + spec.add_development_dependency "timecop", "~> 0.9.1" + spec.add_development_dependency "cucumber", "~> 3.1.2" + spec.add_development_dependency "aruba", "~> 0.14.11" +end diff --git a/spec/command_spec.rb b/spec/command_spec.rb index e28befef..1ec4d0b3 100644 --- a/spec/command_spec.rb +++ b/spec/command_spec.rb @@ -2,9 +2,6 @@ # supervisor and site can either both be either internal, or one of them can be external, # in case you're testing equipment or other software systems -require_relative '../supervisor' -require_relative '../site' - def up &block Async do |task| @@ -21,7 +18,7 @@ def up &block end end -describe "Sending commands" do +RSpec.describe "Sending commands" do before(:all) do supervisor_settings = { diff --git a/spec/message_spec.rb b/spec/message_spec.rb index 9fa116ea..e039220d 100644 --- a/spec/message_spec.rb +++ b/spec/message_spec.rb @@ -1,12 +1,11 @@ -require_relative '../message' -require 'timecop' +Bundler.require(:default, :development) def build packet attributes = RSMP::Message.parse_attributes(packet) RSMP::Message.build(attributes,packet) end -describe RSMP::Message do +RSpec.describe RSMP::Message do let(:version_str) { '{"mType":"rSMsg","type":"Version","RSMP":[{"vers":"3.1.1"},{"vers":"3.1.2"},{"vers":"3.1.3"},{"vers":"3.1.4"}],"siteId":[{"sId":"RN+SI0001"}],"SXL":"1.1","mId":"8db00f0a-4124-406f-b3f9-ceb0dbe4aeb6"}' } let(:ack_str) { '{"mType":"rSMsg","type":"MessageAck","oMId":"a54dc38b-7ddb-42a6-b6e8-95b0d00dad19","mId":"561c15c9-e050-4ee7-9cf4-8643c6769dcb"}' } let(:not_ack_str) { '{"mType":"rSMsg","type":"MessageNotAck","rea":"since we are a rsmp::siteconnector","oMId":"24b5e2d1-fd32-4f12-80cf-f32f8b2772af","mId":"808b957d-6e93-408b-b5e3-ce7f64dc3c61"}' } diff --git a/spec/rsmp_spec.rb b/spec/rsmp_spec.rb new file mode 100644 index 00000000..5b3c0e90 --- /dev/null +++ b/spec/rsmp_spec.rb @@ -0,0 +1,7 @@ +require 'rsmp' + +RSpec.describe Rsmp do + it "has a version number" do + expect(Rsmp::VERSION).not_to be nil + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 251aa510..0f843c20 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,100 +1,16 @@ -# This file was generated by the `rspec --init` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause -# this file to always be loaded, without a need to explicitly require it in any -# files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need -# it. -# -# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -RSpec.configure do |config| - # rspec-expectations config goes here. You can use an alternate - # assertion/expectation library such as wrong or the stdlib/minitest - # assertions if you prefer. - config.expect_with :rspec do |expectations| - # This option will default to `true` in RSpec 4. It makes the `description` - # and `failure_message` of custom matchers include text for helper methods - # defined using `chain`, e.g.: - # be_bigger_than(2).and_smaller_than(4).description - # # => "be bigger than 2 and smaller than 4" - # ...rather than: - # # => "be bigger than 2" - expectations.include_chain_clauses_in_custom_matcher_descriptions = true - end - - # rspec-mocks config goes here. You can use an alternate test double - # library (such as bogus or mocha) by changing the `mock_with` option here. - config.mock_with :rspec do |mocks| - # Prevents you from mocking or stubbing a method that does not exist on - # a real object. This is generally recommended, and will default to - # `true` in RSpec 4. - mocks.verify_partial_doubles = true - end - - # This option will default to `:apply_to_host_groups` in RSpec 4 (and will - # have no way to turn it off -- the option exists only for backwards - # compatibility in RSpec 3). It causes shared context metadata to be - # inherited by the metadata hash of host groups and examples, rather than - # triggering implicit auto-inclusion in groups with matching metadata. - config.shared_context_metadata_behavior = :apply_to_host_groups - -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus +require "bundler/setup" +require "rsmp" - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" +RSpec.configure do |config| + # Enable flags like --only-failures and --next-failure + config.example_status_persistence_file_path = ".rspec_status" - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ - # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_patching! - # This setting enables warnings. It's recommended, but in some cases may - # be too noisy due to issues in dependencies. - config.warnings = true - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" + config.expect_with :rspec do |c| + c.syntax = :expect end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end end + +include RSpec diff --git a/spec/supervisor_spec.rb b/spec/supervisor_spec.rb index ea3e80a5..fe7dbc70 100644 --- a/spec/supervisor_spec.rb +++ b/spec/supervisor_spec.rb @@ -1,8 +1,4 @@ -require_relative '../supervisor' -require_relative '../site' -require_relative '../supervisor_connector' - -describe RSMP::Supervisor do +RSpec.describe RSMP::Supervisor do context 'when creating' do let(:supervisor_settings) {