Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing description error #32

Merged
merged 2 commits into from
Jul 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Unreleased

* Fixed the error of the missing matcher description (https://github.com/krisleech/wisper-rspec/pull/32)

1.1.0 (15/May/2018)

Authors: Nikolai (nikolai-b), David Kennedy (TheTeaNerd)
Expand Down
6 changes: 6 additions & 0 deletions lib/wisper/rspec/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def matches?(block)
@event_recorder.broadcast?(@event, *@args)
end

def description
msg = "broadcast #{@event} event"
msg += " with args: #{@args.inspect}" if @args.size > 0
msg
end

def failure_message
msg = "expected publisher to broadcast #{@event} event"
msg += " with args: #{@args.inspect}" if @args.size > 0
Expand Down
24 changes: 24 additions & 0 deletions spec/wisper/rspec/unit/broadcast_matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@
end.new
end

describe '#description' do
it 'has descriptive message' do
expect(matcher.description).to eq "broadcast #{event_name} event"
end
end

describe '#failure_message_when_negated' do
subject(:message) { matcher.failure_message_when_negated }

context 'when with args' do
let(:matcher) { described_class.new(event_name, 1) }

it 'has descriptive message' do
expect(message).to eq "expected publisher not to broadcast #{event_name} event with args: [1]"
end
end

context 'when without args' do
it 'has descriptive message' do
expect(message).to eq "expected publisher not to broadcast #{event_name} event"
end
end
end

context 'matching event broadcast' do
let(:block) do
Proc.new do
Expand Down