Fluffy.Download (Fluffy v0.2.0)

Copy Markdown View Source

A normalized download captured by Fluffy.wait_for/3,4 with Fluffy.Event.download/2.

Assertion constructors accept the capture key and return a Fluffy.Expect value for Fluffy.expect/2. Capture waits for the event; assertions inspect the retained result. Options follow Fluffy.Expect.

Summary

Assertions

Expects the complete downloaded bytes to equal the supplied binary; no text decoding is performed.

Expects the captured download's content type to equal the supplied value.

Expects the download size in bytes.

Expects the captured download's suggested filename to equal the supplied value.

Expects the captured download URL to match a string, regex, or structured components.

Types

t()

@type t() :: %Fluffy.Download{
  bytes: binary(),
  content_type: String.t(),
  filename: String.t(),
  url: String.t()
}

Assertions

to_have_content(key, expected, options \\ [])

@spec to_have_content(term(), binary(), [Fluffy.Expect.option()]) :: Fluffy.Expect.t()

Expects the complete downloaded bytes to equal the supplied binary; no text decoding is performed.

to_have_content_type(key, expected, options \\ [])

@spec to_have_content_type(term(), String.t(), [Fluffy.Expect.option()]) ::
  Fluffy.Expect.t()

Expects the captured download's content type to equal the supplied value.

to_have_size(key, expected, options \\ [])

@spec to_have_size(term(), non_neg_integer(), [Fluffy.Expect.option()]) ::
  Fluffy.Expect.t()

Expects the download size in bytes.

to_have_suggested_filename(key, expected, options \\ [])

@spec to_have_suggested_filename(term(), String.t(), [Fluffy.Expect.option()]) ::
  Fluffy.Expect.t()

Expects the captured download's suggested filename to equal the supplied value.

to_have_url(key, expected, options \\ [])

Expects the captured download URL to match a string, regex, or structured components.

Strings match exactly and regexes match against the complete captured URL. Relative strings are not resolved. Structured keywords use the same path, query, and fragment rules as Fluffy.Page.to_have_url/2.