Cucumber-Messages
view release on metacpan or search on metacpan
lib/Cucumber/Messages.pm view on Meta::CPAN
=cut
package Cucumber::Messages::Attachment {
$Cucumber::Messages::Attachment::VERSION = '32.3.1';
=head2 Cucumber::Messages::Attachment
=head3 DESCRIPTION
Represents the Attachment message in Cucumber's
L<message protocol|https://github.com/cucumber/messages>.
Attachments (parse errors, execution errors, screenshots, links...)
An attachment represents any kind of data associated with a line in a
[Source](#io.cucumber.messages.Source) file. It can be used for:
* Syntax errors during parse time
* Screenshots captured and attached during execution
* Logs captured and attached during execution
It is not to be used for runtime errors raised/thrown during execution. This
is captured in `TestResult`.
=head3 ATTRIBUTES
=cut
use Moo;
extends 'Cucumber::Messages::Message';
use Scalar::Util qw( blessed );
my %types = (
body => 'string',
content_encoding => '',
file_name => 'string',
media_type => 'string',
source => 'Cucumber::Messages::Source',
test_case_started_id => 'string',
test_step_id => 'string',
url => 'string',
test_run_started_id => 'string',
test_run_hook_started_id => 'string',
timestamp => 'Cucumber::Messages::Timestamp',
);
# This is a work-around for the fact that Moo doesn't have introspection
# and Perl doesn't have boolean values...
sub _types {
return \%types;
}
=head4 body
The body of the attachment. If `contentEncoding` is `IDENTITY`, the attachment
is simply the string. If it's `BASE64`, the string should be Base64 decoded to
obtain the attachment.
=cut
has body =>
(is => 'ro',
required => 1,
default => sub { '' },
);
=head4 content_encoding
Whether to interpret `body` "as-is" (IDENTITY) or if it needs to be Base64-decoded (BASE64).
Content encoding is *not* determined by the media type, but rather by the type
of the object being attached:
- string: IDENTITY
- byte array: BASE64
- stream: BASE64
Available constants for valid values of this field:
=over
=item * CONTENTENCODING_IDENTITY
=item * CONTENTENCODING_BASE64
=back
=cut
use constant {
CONTENTENCODING_IDENTITY => 'IDENTITY',
CONTENTENCODING_BASE64 => 'BASE64',
};
has content_encoding =>
(is => 'ro',
required => 1,
default => sub { CONTENTENCODING_IDENTITY },
);
=head4 file_name
Suggested file name of the attachment. (Provided by the user as an argument to `attach`)
=cut
has file_name =>
(is => 'ro',
);
=head4 media_type
The media type of the data. This can be any valid
[IANA Media Type](https://www.iana.org/assignments/media-types/media-types.xhtml)
as well as Cucumber-specific media types such as `text/x.cucumber.gherkin+plain`
and `text/x.cucumber.stacktrace+plain`
=cut
has media_type =>
(is => 'ro',
required => 1,
default => sub { '' },
);
=head4 source
( run in 1.894 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )