File: transport_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,559 bytes parent folder | download | duplicates (2)
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 Transport class is setup correctly.

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

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

# 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::Transport 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(:plugin_class) { TrainPlugins::LocalRot13::Transport }

  # 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 be registered with the plugin registry without the train- prefix" do
    # Note that Train uses String keys here, not Symbols
    Train::Plugins.registry.keys.wont_include("train-local-rot13")
    Train::Plugins.registry.keys.must_include("local-rot13")
  end

  it "should inherit from the Train plugin base" do
    # For Class, '<' means 'is a descendant of'
    (plugin_class < Train.plugin(1)).must_equal(true)
  end

  it "should provide a connection() method" do
    # false passed to instance_methods says 'don't use inheritance'
    plugin_class.instance_methods(false).must_include(:connection)
  end
end