Skip to content

Commit

Permalink
Ability to use a Path; More Tests
Browse files Browse the repository at this point in the history
When making the object, you can now use a path to a file instead
of just a string containing URL. Also, more tests.
  • Loading branch information
nicqrocks committed Jun 27, 2016
1 parent 7008098 commit c74d561
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.moarvm
*.swp
lib/.precomp/
.precomp/
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ The idea is to make this module as simple to use as possible.
###`.new`
The `.new` method will require an 'incoming webhook' integration link from Slack, this way it knows where to connect and has the correct authentication to do so. One of these links will be given after setting up an integration using [this link](https://my.slack.com/services/new/incoming-webhook/ "New Slack incoming webhook"). If the url is not given an exception will be thrown. The syntax for this will look like this:
```
my $slack = WebService::Slack::webhook.new($url);
#String containing the URL.
my $slack = WebService::Slack::webhook.new(url => "$url");
#Or...
#Path to a file with the URL.
my $slack = WebService::Slack::webhook.new(path => "/path/to/file");
```

###`.send`
Expand Down
29 changes: 29 additions & 0 deletions t/02-make.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env perl6

use Test;
use lib 'lib';

use WebService::Slack::webhook;

#Make some vars
my $fake-url = "https://host.slack.com/example";
my $file-name = ".slackurl";

#Make a bad object.
dies-ok {WebService::Slack::webhook.new()},
'Bad object fails correctly';

#Make a good object with a url.
isa-ok WebService::Slack::webhook.new(url => "$fake-url"),
'WebService::Slack::webhook',
'Good object can be made with url';

#Make a good object with a path.
"$file-name".IO.spurt($fake-url); #Make the file.
isa-ok WebService::Slack::webhook.new(path => "$file-name"),
'WebService::Slack::webhook',
'Good object can be made with path';
"$file-name".IO.unlink; #Remove the file.


done-testing;
18 changes: 0 additions & 18 deletions t/02-send.t

This file was deleted.

0 comments on commit c74d561

Please sign in to comment.