Class: Playwright::Scene
- Inherits:
-
Object
- Object
- Playwright::Scene
- Defined in:
- lib/playwright/scene.rb
Overview
Playwright::Scene
Scene is the service layer between your test and page object models. It allows common interactions to be duplicated in tests without letting the tests know too much about the page.
class PurchaseProduct < Playwright::Scene
sender_accessor :buyer
def purchase_product(product)
LoginHelper.login_as(buyer)
ProductPage.purchase(product.id)
stage.orders.find_or_add(product.orders.last)
end
end
Instance Attribute Summary collapse
-
#receiver ⇒ Object
Returns the value of attribute receiver.
-
#sender ⇒ Object
Returns the value of attribute sender.
-
#stage ⇒ Object
readonly
Returns the value of attribute stage.
Class Method Summary collapse
-
.receiver_accessor(name) ⇒ Object
Aliases the
receivermethod to better describe who is receiving the action. -
.sender_accessor(name) ⇒ Object
Aliases the
sendermethod to better describe who the action is coming from.
Instance Method Summary collapse
-
#==(other) ⇒ Object
:nodoc:.
-
#initialize(stage, sender, receiver) ⇒ Scene
constructor
A new instance of Scene.
Constructor Details
#initialize(stage, sender, receiver) ⇒ Scene
Returns a new instance of Scene.
21 22 23 24 25 |
# File 'lib/playwright/scene.rb', line 21 def initialize(stage, sender, receiver) @stage = stage @sender = sender @receiver = receiver end |
Instance Attribute Details
#receiver ⇒ Object
Returns the value of attribute receiver.
19 20 21 |
# File 'lib/playwright/scene.rb', line 19 def receiver @receiver end |
#sender ⇒ Object
Returns the value of attribute sender.
19 20 21 |
# File 'lib/playwright/scene.rb', line 19 def sender @sender end |
#stage ⇒ Object (readonly)
Returns the value of attribute stage.
18 19 20 |
# File 'lib/playwright/scene.rb', line 18 def stage @stage end |
Class Method Details
.receiver_accessor(name) ⇒ Object
Aliases the receiver method to better describe who is receiving the action.
class OrderScene < Playwright::Scene
receiver_accessor :seller
def deliver_order(order)
LoginHelper.login_as(seller)
end
end
52 53 54 |
# File 'lib/playwright/scene.rb', line 52 def self.receiver_accessor(name) define_method(name, instance_method(:receiver)) end |
.sender_accessor(name) ⇒ Object
Aliases the sender method to better describe who the action is coming from.
class OrderScene < Playwright::Scene
sender_accessor :buyer
def purchase_product(product)
LoginHelper.login_as(buyer)
end
end
37 38 39 |
# File 'lib/playwright/scene.rb', line 37 def self.sender_accessor(name) define_method(name, instance_method(:sender)) end |
Instance Method Details
#==(other) ⇒ Object
:nodoc:
56 57 58 59 |
# File 'lib/playwright/scene.rb', line 56 def ==(other) # :nodoc: return false unless other.is_a?(Scene) stage == other.stage && sender == other.sender && receiver == other.receiver end |