File: connection_test.rb

package info (click to toggle)
ruby-train 3.13.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,208 kB
  • sloc: ruby: 10,002; sh: 17; makefile: 8
file content (39 lines) | stat: -rw-r--r-- 1,514 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# This is a unit test for the example Train plugin, LocalRot13.
# Its job is to verify that the Connection class is setup correctly.

# Include our test harness
require_relative "../helper"

# Load the class under test, the Connection definition.
require "train-local-rot13/connection"

# Because InSpec is a Spec-style test suite, we're going to use MiniTest::Spec
# here, for familiar look and feel. However, this isn't InSpec (or RSpec) code.
describe TrainPlugins::LocalRot13::Connection do

  # When writing tests, you can use `let` to create variables that you
  # can reference easily.

  # This is a long name.  Shorten it for clarity.
  let(:connection_class) { TrainPlugins::LocalRot13::Connection }

  # Some tests through here use minitest Expectations, which attach to all
  # Objects, and begin with 'must' (positive) or 'wont' (negative)
  # See https://ruby-doc.org/stdlib-2.1.0/libdoc/minitest/rdoc/MiniTest/Expectations.html

  it "should inherit from the Train Connection base" do
    # For Class, '<' means 'is a descendant of'
    (connection_class < Train::Plugins::Transport::BaseConnection).must_equal(true)
  end

  # Since this is a Local-type connection, we MUST implement these three.
  %i{
    file_via_connection
    run_command_via_connection
  }.each do |method_name|
    it "should provide a #{method_name}() method" do
      # false passed to instance_methods says 'don't use inheritance'
      connection_class.instance_methods(false).must_include(method_name)
    end
  end
end