Skip to content

Commit

Permalink
Updated ex_docs
Browse files Browse the repository at this point in the history
Added is_in matcher
  • Loading branch information
Brian Balser authored and bbalser committed Dec 5, 2020
1 parent 1772cd5 commit 89a5784
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/placebo/matchers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ defmodule Placebo.Matchers do
matcher :ne, do: arg != input

matcher :contains_member, do: Enum.member?(arg, input)
matcher :is_in, do: arg in input
matcher :is_empty, do: Enum.empty?(arg)

matcher :is_alive, do: Process.alive?(arg)
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule Placebo.MixProject do
[
{:meck, "~> 0.9"},
{:mix_test_watch, "~> 0.6.0", only: :dev, runtime: false},
{:ex_doc, "~> 0.19.1", only: :dev, runtime: false},
{:ex_doc, "~> 0.23.0", only: :dev, runtime: false},
{:stream_data, "~> 0.4", only: [:dev, :test]}
]
end
Expand Down
9 changes: 5 additions & 4 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
%{
"earmark": {:hex, :earmark, "1.2.6", "b6da42b3831458d3ecc57314dff3051b080b9b2be88c2e5aa41cd642a5b044ed", [:mix], [], "hexpm", "b42a23e9bd92d65d16db2f75553982e58519054095356a418bb8320bbacb58b1"},
"earmark_parser": {:hex, :earmark_parser, "1.4.10", "6603d7a603b9c18d3d20db69921527f82ef09990885ed7525003c7fe7dc86c56", [:mix], [], "hexpm", "8e2d5370b732385db2c9b22215c3f59c84ac7dda7ed7e544d7c459496ae519c0"},
"espec": {:hex, :espec, "1.5.1", "46c603c4adb4244b152ea53c4d5f4545ab1eb1de1556588ec908b8e4ba570188", [:mix], [{:meck, "0.8.9", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.19.1", "519bb9c19526ca51d326c060cb1778d4a9056b190086a8c6c115828eaccea6cf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.7", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "dc87f778d8260da0189a622f62790f6202af72f2f3dee6e78d91a18dd2fcd137"},
"ex_doc": {:hex, :ex_doc, "0.23.0", "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"},
"file_system": {:hex, :file_system, "0.2.5", "a3060f063b116daf56c044c273f65202e36f75ec42e678dc10653056d3366054", [:mix], [], "hexpm", "c11255c9af50d831a09d469533b9dbb0fcfe4586ef6681f2205ad0e29cda89ef"},
"hamcrest": {:hex, :hamcrest, "0.1.3", "6c79b5bbdde0bea1563e1ce4810ff89fdcec41ab1019dcaace146c4925506b65", [:make, :rebar3], [], "hexpm"},
"makeup": {:hex, :makeup, "0.5.5", "9e08dfc45280c5684d771ad58159f718a7b5788596099bdfb0284597d368a882", [:mix], [{:nimble_parsec, "~> 0.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d7152ff93f2eac07905f510dfa03397134345ba4673a00fbf7119bab98632940"},
"makeup_elixir": {:hex, :makeup_elixir, "0.10.0", "0f09c2ddf352887a956d84f8f7e702111122ca32fbbc84c2f0569b8b65cbf7fa", [:mix], [{:makeup, "~> 0.5.5", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "4a36dd2d0d5c5f98d95b3f410d7071cd661d5af310472229dd0e92161f168a44"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.0", "98312c9f0d3730fde4049985a1105da5155bfe5c11e47bdc7406d88e01e4219b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "75ffa34ab1056b7e24844c90bfc62aaf6f3a37a15faa76b07bc5eba27e4a8b4a"},
"meck": {:hex, :meck, "0.9.0", "cb40c223cf403db2d09def59d32d3682074ebecceb64f3e6f6c4477458df124d", [:rebar3], [], "hexpm", "f813e90dd0b89b2516a0201a355e84b1abc78b5751aa0cbf669a9d85a810ac63"},
"mix_test_watch": {:hex, :mix_test_watch, "0.6.0", "5e206ed04860555a455de2983937efd3ce79f42bd8536fc6b900cc286f5bb830", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "ea6f2a3766f18c2f53ca5b2d40b623ce2831c1646f36ff2b608607e20fc6c63c"},
"nimble_parsec": {:hex, :nimble_parsec, "0.4.0", "ee261bb53214943679422be70f1658fff573c5d0b0a1ecd0f18738944f818efe", [:mix], [], "hexpm", "ebb595e19456a72786db6dcd370d320350cb624f0b6203fcc7e23161d49b0ffb"},
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
"stream_data": {:hex, :stream_data, "0.4.2", "fa86b78c88ec4eaa482c0891350fcc23f19a79059a687760ddcf8680aac2799b", [:mix], [], "hexpm", "54d6bf6f1e5e27fbf4a7784a2bffbb993446d0efd079debca0f27bf859c0d1cf"},
}
2 changes: 2 additions & 0 deletions test/async_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule Placebo.Async.Test1 do
allow Regex.regex?(:foo), return: :foo
Process.sleep(1_000)
assert :foo == Regex.regex?(:foo)
assert false == Regex.regex?(:fool)
Process.sleep(1_000)
assert_called Regex.regex?(:foo)
end
Expand All @@ -19,6 +20,7 @@ defmodule Placebo.Async.Test2 do
allow Regex.regex?(:fool), return: :bar
Process.sleep(1_000)
assert :bar == Regex.regex?(:fool)
assert false == Regex.regex?(:foo)
Process.sleep(1_000)
assert_called Regex.regex?(:fool)
end
Expand Down
16 changes: 16 additions & 0 deletions test/matchers_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,20 @@ defmodule Placebo.MatchersTest do
assert URI.decode("foobaz") == :baz
assert URI.decode("other") == :no_match
end

test "is_in" do
allow Regex.regex?(any()), return: :no_match
allow Regex.regex?(is_in([1, 2, 3])), return: :match

assert Regex.regex?(2) == :match
assert Regex.regex?(4) == :no_match
end

test "contains_member" do
allow Regex.regex?(any()), return: :no_match
allow Regex.regex?(contains_member("a")), return: :match

assert Regex.regex?(["b", "a", "c"]) == :match
assert Regex.regex?(["d", "e", "f"]) == :no_match
end
end

0 comments on commit 89a5784

Please sign in to comment.