spec/ruboty/handlers/help_spec.rb in ruboty-1.1.9 vs spec/ruboty/handlers/help_spec.rb in ruboty-1.2.0
- old
+ new
@@ -12,30 +12,43 @@
let(:to) do
"#general"
end
- let(:body) do
- <<-EOS.strip_heredoc.strip
- ruboty /help( me)?\\z/i - Show this help message
- ruboty /ping\\z/i - Return PONG to PING
- ruboty /who am i\\?/i - Answer who you are
- EOS
+ context "with valid condition" do
+ let(:body) do
+ <<-EOS.strip_heredoc.strip
+ ruboty /help( me)?(?: (?<filter>.+))?\\z/i - Show this help message
+ ruboty /ping\\z/i - Return PONG to PING
+ ruboty /who am i\\?/i - Answer who you are
+ EOS
+ end
+
+ it "responds to `@ruboty help` and says each handler's description" do
+ robot.should_receive(:say).with(
+ body: body,
+ code: true,
+ from: to,
+ to: from,
+ original: {
+ body: "@ruboty help",
+ from: from,
+ robot: robot,
+ to: to,
+ },
+ )
+ robot.receive(body: "@ruboty help", from: from, to: to)
+ end
end
- it "responds to `@ruboty help` and says each handler's usage" do
- robot.should_receive(:say).with(
- body: body,
- code: true,
- from: to,
- to: from,
- original: {
- body: "@ruboty help",
- from: from,
- robot: robot,
- to: to,
- },
- )
- robot.receive(body: "@ruboty help", from: from, to: to)
+ context "with filter" do
+ it "filters descriptions by given filter" do
+ robot.should_receive(:say).with(
+ hash_including(
+ body: "ruboty /ping\\z/i - Return PONG to PING",
+ ),
+ )
+ robot.receive(body: "@ruboty help ping", from: from, to: to)
+ end
end
end
end