Class: Wisper::RSpec::EventRecorder
- Inherits:
-
Object
- Object
- Wisper::RSpec::EventRecorder
show all
- Includes:
- RSpec::Mocks::ArgumentMatchers
- Defined in:
- lib/wisper/rspec/matchers.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of EventRecorder.
10
11
12
|
# File 'lib/wisper/rspec/matchers.rb', line 10
def initialize
@broadcast_events = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
22
23
24
|
# File 'lib/wisper/rspec/matchers.rb', line 22
def method_missing(method_name, *args, &block)
@broadcast_events << [method_name.to_s, *args]
end
|
Instance Attribute Details
#broadcast_events ⇒ Object
Returns the value of attribute broadcast_events.
8
9
10
|
# File 'lib/wisper/rspec/matchers.rb', line 8
def broadcast_events
@broadcast_events
end
|
Instance Method Details
#broadcast?(event_name, *args) ⇒ Boolean
26
27
28
29
30
31
32
|
# File 'lib/wisper/rspec/matchers.rb', line 26
def broadcast?(event_name, *args)
expected_args = args.size > 0 ? args : [any_args]
@broadcast_events.any? do |event_params|
matcher = ::RSpec::Mocks::ArgumentListMatcher.new(event_name.to_s, *expected_args)
matcher.args_match?(*event_params)
end
end
|
#respond_to?(method_name) ⇒ Boolean
14
15
16
|
# File 'lib/wisper/rspec/matchers.rb', line 14
def respond_to?(method_name)
true
end
|
#respond_to_missing? ⇒ Boolean
18
19
20
|
# File 'lib/wisper/rspec/matchers.rb', line 18
def respond_to_missing?(*)
true
end
|