File: exception_spec.rb

package info (click to toggle)
ruby-cucumber-wire 0.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 224 kB
  • sloc: ruby: 754; makefile: 3
file content (50 lines) | stat: -rw-r--r-- 1,255 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
40
41
42
43
44
45
46
47
48
49
50
require 'cucumber/wire/exception'
require 'cucumber/wire/configuration'

module Cucumber
  module Wire
    describe Exception do
      before(:each) do
        @config = Configuration.new('host' => 'localhost', 'port' => 54321)
      end

      def exception
        Wire::Exception.new(@data, @config)
      end

      describe "with just a message" do
        before(:each) do
          @data = {'message' => 'foo'}
        end

        it "#to_s as expecteds" do
          expect(exception.to_s).to eq "foo"
        end
      end

      describe "with a message and an exception" do
        before(:each) do
          @data = {'message' => 'foo', 'exception' => 'Bar'}
        end

        it "#to_s as expecteds" do
          expect(exception.to_s).to eq "foo"
        end

        it "#class.to_s returns the name of the exception" do
          expect(exception.class.to_s).to eq 'Bar from localhost:54321'
        end
      end

      describe "with a custom backtrace" do
        before(:each) do
          @data = {'message' => 'foo', 'backtrace' => ['foo', 'bar', 'baz']}
        end

        it "#backrace returns the custom backtrace" do
          expect(exception.backtrace).to eq ['foo', 'bar', 'baz']
        end
      end
    end
  end
end