Skip to content

Commit a13ead4

Browse files
author
Ben Lavender
committed
allow naked boolean arguments in test helpers
1 parent e9ac7ed commit a13ead4

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

lib/chatops/controller/test_case_helpers.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def extract_named_params(command_string)
5858
arg = command_string[last_index..-1]
5959
matches = arg.match(/ --(\S+)(.*)/)
6060
params[matches[1]] = matches[2].strip
61+
params[matches[1]] = "true" unless params[matches[1]].present?
6162
command_string = command_string.slice(0, last_index)
6263
end
6364

spec/lib/chatops/controller_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,13 @@ def ensure_app_given
227227
expect(chatop_response).to eq "You can deploy foobar just fine."
228228
end
229229

230+
it "works with boolean arguments" do
231+
chat "where can i deploy foobar --this-is-sparta", "bhuga"
232+
expect(request.params["action"]).to eq "wcid"
233+
expect(request.params["user"]).to eq "bhuga"
234+
expect(request.params["params"]["this-is-sparta"]).to eq "true"
235+
end
236+
230237
it "anchors regexes" do
231238
expect {
232239
chat "too bad that this message doesn't start with where can i deploy foobar", "bhuga"

0 commit comments

Comments
 (0)