Skip to content

Commit

Permalink
Initialize the App class #instance is called on
Browse files Browse the repository at this point in the history
Initializes the subclass (for instance `PongBot::App` in the first `README` example) instead of `SlackRubyBot::App` specifically. This allows for easier behavior modification through custom `Hooks` and direct method overriding.
  • Loading branch information
dmvt committed Dec 7, 2015
1 parent b1baf4b commit 4088739
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 0.5.1 (Next)

* [#33](https://github.com/dblock/slack-ruby-bot/pull/33): `SlackRubyBot::App.instance` now creates an instance of the class on which it is called - [@dmvt](https://github.com/dmvt).
* Your contribution here.

### 0.5.0 (12/7/2015)
Expand Down Expand Up @@ -62,4 +63,3 @@
### 0.1.0 (6/2/2015)

* Initial public release - [@dblock](https://github.com/dblock).

2 changes: 1 addition & 1 deletion lib/slack-ruby-bot/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def config
end

def self.instance
@instance ||= SlackRubyBot::App.new
@instance ||= new
end

private
Expand Down
7 changes: 7 additions & 0 deletions spec/slack-ruby-bot/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ def app
SlackRubyBot::App.new
end
it_behaves_like 'a slack ruby bot'

describe '.instance' do
it 'creates an instance of the App subclass' do
klass = Class.new(SlackRubyBot::App)
expect(klass.instance.class).to be klass
end
end
end

0 comments on commit 4088739

Please sign in to comment.