krisleech/wisper — pull request #42 by jhoffner (2014-03-06 23:53:51+00:00)
Title: allow_private option, custom rspec matcher, add_listeners

These three features got stuck in a single PR because I didn't realize I couldn't cherry pick. Sorry about that.

This PR has the following:

### custom matcher
```ruby
expect { publisher.do_something }.to broadcast(publisher, :something_happened)
```

### allow_private option:
I my case I am using context/interactor objects to handle complex operations. I wanted the interactor itself to be the listener to some of the objects that it was interacting with. However it made sense for those methods to be protected/private since they are used for internal logic only. Here was a simplified example/use case
```ruby
class AttemptContext
attr_accessor :project_item
def execute
# code for attempting something...

project_item.project.subscribe(self, prefix: :on_project, private: true)
# marking the project item as completed may mark the project as completed, depending on some
# hidden logic
project_item.mark_completed!
end

protected

def on_project_completed(project)
# do something with project
end
end
```

### add_listeners/subscribe_many
Allows an easier way to subscribe multiple listeners with the same options.

Example use case:
```ruby
project.subscribe_many(ActivityListener.new, LogListener.new, prefix: :project)

# as opposed to
project.subscribe(ActivityListener.new, prefix: :project)
project.subscribe(LogListener.new, prefix: :project)
```