Skip to content

Commit

Permalink
Add stray rule validation
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineGagne committed Nov 21, 2023
1 parent 839025a commit ea09037
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/robots_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"# ---------------------------\n"
"# END YOAST BLOCK\n"
>>).
-define(A_STRAY_RULE, <<"Disallow: /path/">>).
-define(ANOTHER_VALID_CONTENT,
<<"User-Agent: ", ?USER_AGENT/binary, "\nAllow: ", ?A_RULE/binary, "\nDisallow: ",
?ANOTHER_RULE/binary>>
Expand Down Expand Up @@ -67,7 +68,8 @@ groups() ->
return_false_if_agent_is_disallowed,
return_true_if_no_matching_rules_can_be_found,
return_true_if_everything_is_allowed_for_the_corresponding_agent,
ignore_empty_rules
ignore_empty_rules,
ignore_stray_rules
]}
].

Expand Down Expand Up @@ -259,6 +261,13 @@ ignore_empty_rules(_Config) ->

?assert(robots:is_allowed(?USER_AGENT, ?AN_URL, RulesIndex)).

ignore_stray_rules() ->
[{doc, "Given a stray rule, when parsing, then ignores the stray rules."}].
ignore_stray_rules(_Config) ->
{ok, RulesIndex} = robots:parse(?A_STRAY_RULE, ?A_VALID_CODE),

?assertEqual(#{}, RulesIndex).

%%%===================================================================
%%% Internal functions
%%%===================================================================

0 comments on commit ea09037

Please sign in to comment.