playwright 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +7 -0
- data/LICENSE +7 -0
- data/README.md +125 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/playwright.rb +11 -0
- data/lib/playwright/dsl/actor_dsl.rb +31 -0
- data/lib/playwright/dsl/scene_dsl.rb +49 -0
- data/lib/playwright/errors.rb +4 -0
- data/lib/playwright/extensions.rb +13 -0
- data/lib/playwright/narrator.rb +80 -0
- data/lib/playwright/props.rb +38 -0
- data/lib/playwright/scene.rb +61 -0
- data/lib/playwright/stage.rb +103 -0
- data/lib/playwright/version.rb +3 -0
- data/playwright.gemspec +27 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 43eed1125904ba3c14998084d8710997300317fb
|
4
|
+
data.tar.gz: c8dda6b2906319bec40992e7a037db060d6f5d08
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 072fc084887b5066ecaadb3af1373e237adb833ecc30d35a1658dc9c18a1e2129432cec6f631fe9a31193c15458d933e3bc11d85342bb68543bca2c37051cfb4
|
7
|
+
data.tar.gz: 44eb5495d51b4bba2af0cef01f7778f3e801f924d7622faa787ec24e89ce55eaa02b0dcacdcc1510b3fce630ba3aa14c67402f579e04e6ab055fc18ebbc14ac7
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2016 Baylor Rae'
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
# Playwright
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/BaylorRae/playwright.svg?branch=master)](https://travis-ci.org/BaylorRae/playwright) [![Code Climate](https://codeclimate.com/github/BaylorRae/playwright/badges/gpa.svg)](https://codeclimate.com/github/BaylorRae/playwright) [![Test Coverage](https://codeclimate.com/github/BaylorRae/playwright/badges/coverage.svg)](https://codeclimate.com/github/BaylorRae/playwright/coverage)
|
4
|
+
|
5
|
+
Playwright is a foundational piece for building a test framework. It allows
|
6
|
+
test cases to be written as a play with all the moving parts to be categorized
|
7
|
+
as a `Stage`, `Scene`, `Props` or `Actor`.
|
8
|
+
|
9
|
+
### What are `Stage`, `Scene` or `Actor`?
|
10
|
+
|
11
|
+
Each test contains a single `Stage` which encapsulates one or many `Scene`s and
|
12
|
+
`Props`. There should only be one stage created in a test as it is the context
|
13
|
+
that everything should go through.
|
14
|
+
|
15
|
+
Once you have a `Stage` the next step is to create the `Scene`s that help build
|
16
|
+
the test or "story". A `Scene` is a service layer between your test and page
|
17
|
+
object models. It also groups two `Actor`s together that will "interact" as the
|
18
|
+
test runs. A `Stage` has multiple `Scene`s as there are generally more than one
|
19
|
+
action in a test.
|
20
|
+
|
21
|
+
An `Actor` will likely be a user in your system but it can be anything that
|
22
|
+
interacts another object type.
|
23
|
+
|
24
|
+
## Example
|
25
|
+
|
26
|
+
Let's imagine we have an platform with **sellers**, **buyers** and **fulfillment
|
27
|
+
agencies**. We need to create a test around fulfilling an order. You can teach
|
28
|
+
Playwright how to group actors together as **buyer** will only interact with
|
29
|
+
**seller** and **seller** will only interact with the **fulfillment agency**.
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
stage = FulfillmentStage.new
|
33
|
+
|
34
|
+
# scenes
|
35
|
+
stage.scenes #=> [PurchaseProduct, FulfillOrder]
|
36
|
+
stage.purchase_product #=> PurchaseProduct
|
37
|
+
stage.fulfill_order #=> FulfillOrder
|
38
|
+
|
39
|
+
# actors
|
40
|
+
stage.actors #=> [:buyer, :seller, :fulfillment_agency]
|
41
|
+
stage.buyer #=> User(username: 'buyer')
|
42
|
+
stage.seller #=> User(username: 'seller')
|
43
|
+
stage.fulfillment_agency #=> FulfillmentAgency
|
44
|
+
|
45
|
+
# props
|
46
|
+
stage.products #=> [Product, Product, ...]
|
47
|
+
stage.orders #=> [Order, Order, ...]
|
48
|
+
stage.fulfillments #=> [OrderFulfillment, OrderFulfillment, ...]
|
49
|
+
```
|
50
|
+
|
51
|
+
The above code example is defined from the following.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
class FulfillmentStage < Playwright::Stage
|
55
|
+
actors do
|
56
|
+
actor(:buyer) { User.find_by(username: 'buyer') }
|
57
|
+
actor(:seller) { User.find_by(username: 'seller') }
|
58
|
+
actor(:fulfillment_agency) { FulfillmentAgency.find_by(name: 'agency-1') }
|
59
|
+
end
|
60
|
+
|
61
|
+
scenes do
|
62
|
+
scene :purchase_product, from: :buyer, to: :seller
|
63
|
+
scene :fulfill_order, from: :seller, to: :fulfillment_agency
|
64
|
+
end
|
65
|
+
|
66
|
+
prop_collection(:products) { |p| p.id }
|
67
|
+
prop_collection(:orders) { |o| o.invoice_number }
|
68
|
+
prop_collection(:fulfillments) { |f| f.id }
|
69
|
+
end
|
70
|
+
|
71
|
+
class PurchaseProduct < Playwright::Scene
|
72
|
+
sender_accessor :buyer
|
73
|
+
|
74
|
+
def purchase_product(product)
|
75
|
+
LoginHelper.login_as(buyer)
|
76
|
+
ProductPage.purchase(product.id)
|
77
|
+
stage.orders.find_or_add(product.orders.last)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class FulfillOrder < Playwright::Scene
|
82
|
+
sender_accessor :seller
|
83
|
+
receiver_accessor :fulfillment_agency
|
84
|
+
|
85
|
+
def fulfill(order)
|
86
|
+
LoginHelper.login_as(seller)
|
87
|
+
OrderPage.fulfill_order(order.invoice_number)
|
88
|
+
|
89
|
+
LoginHelper.login_as(fulfillment_agency)
|
90
|
+
FulfillmentPage.ship_order(order.invoice_number)
|
91
|
+
stage.fulfillments.find_or_add(order.fulfillments.last)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
```
|
95
|
+
|
96
|
+
## Installation
|
97
|
+
|
98
|
+
Add this line to your application's Gemfile:
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
gem 'playwright'
|
102
|
+
```
|
103
|
+
|
104
|
+
And then execute:
|
105
|
+
|
106
|
+
$ bundle
|
107
|
+
|
108
|
+
Or install it yourself as:
|
109
|
+
|
110
|
+
$ gem install playwright
|
111
|
+
|
112
|
+
## Usage
|
113
|
+
|
114
|
+
TODO: Write usage instructions here
|
115
|
+
|
116
|
+
## Development
|
117
|
+
|
118
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
119
|
+
|
120
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
121
|
+
|
122
|
+
## Contributing
|
123
|
+
|
124
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/baylorrae/playwright.
|
125
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "playwright"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/playwright.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'playwright/version'
|
2
|
+
|
3
|
+
module Playwright
|
4
|
+
autoload :Stage, 'playwright/stage'
|
5
|
+
autoload :Scene, 'playwright/scene'
|
6
|
+
autoload :Props, 'playwright/props'
|
7
|
+
autoload :Narrator, 'playwright/narrator'
|
8
|
+
autoload :ActorNotRegistered, 'playwright/errors'
|
9
|
+
autoload :SceneNotRegistered, 'playwright/errors'
|
10
|
+
autoload :ClassMethods, 'playwright/extensions'
|
11
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'active_support/hash_with_indifferent_access'
|
2
|
+
|
3
|
+
module Playwright
|
4
|
+
module DSL
|
5
|
+
# Defines an actor in a stage. The block is only evaluated once when the
|
6
|
+
# method is called the first time.
|
7
|
+
#
|
8
|
+
# class ExampleStage < Playwright::Stage
|
9
|
+
# actors do
|
10
|
+
# actor(:actor_name) { User.first! }
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
class ActorDSL < BasicObject
|
14
|
+
attr_reader :actors
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@actors = ::ActiveSupport::HashWithIndifferentAccess.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.find(&block) # :nodoc:
|
21
|
+
dsl = new
|
22
|
+
dsl.instance_eval(&block)
|
23
|
+
dsl.actors
|
24
|
+
end
|
25
|
+
|
26
|
+
def actor(name, &block)
|
27
|
+
@actors[name] = block
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'active_support/inflector'
|
2
|
+
require 'active_support/hash_with_indifferent_access'
|
3
|
+
|
4
|
+
module Playwright
|
5
|
+
module DSL
|
6
|
+
# Defines an actor in a stage. The block is only evaluated once when the
|
7
|
+
# method is called the first time.
|
8
|
+
#
|
9
|
+
# class ExampleStage < Playwright::Stage
|
10
|
+
# actors do
|
11
|
+
# actor(:buyer) { User.first! }
|
12
|
+
# actor(:seller) { User.first! }
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# scenes do
|
16
|
+
# scene PurchaseProduct, from: :buyer, to: :seller
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
class SceneDSL
|
20
|
+
attr_reader :scenes
|
21
|
+
SceneWithActors = Struct.new(:klass, :from, :to) do
|
22
|
+
def init(narrator, stage)
|
23
|
+
klass.new(stage, narrator.get_actor(from), narrator.get_actor(to))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize # :nodoc:
|
28
|
+
@scenes = ::ActiveSupport::HashWithIndifferentAccess.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.find(&block) # :nodoc:
|
32
|
+
dsl = new
|
33
|
+
dsl.instance_eval(&block)
|
34
|
+
dsl.scenes
|
35
|
+
end
|
36
|
+
|
37
|
+
def scene(klass, options)
|
38
|
+
if klass.kind_of?(Class)
|
39
|
+
accessor = klass.name.demodulize.underscore
|
40
|
+
else
|
41
|
+
accessor = klass.to_s
|
42
|
+
klass = accessor.camelize.constantize
|
43
|
+
end
|
44
|
+
|
45
|
+
@scenes[accessor] = SceneWithActors.new(klass, options[:from], options[:to])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'playwright/dsl/actor_dsl'
|
2
|
+
require 'playwright/dsl/scene_dsl'
|
3
|
+
|
4
|
+
module Playwright
|
5
|
+
class Narrator
|
6
|
+
include DSL
|
7
|
+
|
8
|
+
attr_reader :owner_class
|
9
|
+
|
10
|
+
def self.find_or_create(owner_class)
|
11
|
+
# get narrator from existing class
|
12
|
+
if owner_class.respond_to?(:narrators) && narrator = owner_class.narrators.first
|
13
|
+
|
14
|
+
# child classes should have their own narrator
|
15
|
+
if narrator.owner_class != owner_class
|
16
|
+
narrator = narrator.dup
|
17
|
+
narrator.owner_class = owner_class
|
18
|
+
end
|
19
|
+
else
|
20
|
+
narrator = new(owner_class)
|
21
|
+
end
|
22
|
+
|
23
|
+
return narrator
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(owner_class) # :nodoc:
|
27
|
+
self.owner_class = owner_class
|
28
|
+
@actors = {}
|
29
|
+
end
|
30
|
+
|
31
|
+
def owner_class=(owner_class) # :nodoc:
|
32
|
+
@owner_class = owner_class
|
33
|
+
owner_class.class_eval do
|
34
|
+
extend ClassMethods
|
35
|
+
end
|
36
|
+
|
37
|
+
owner_class.narrators << self
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_actors(&block) # :nodoc:
|
41
|
+
@actors = ActorDSL.find(&block)
|
42
|
+
end
|
43
|
+
|
44
|
+
def add_scenes(&block) # :nodoc
|
45
|
+
@scenes = SceneDSL.find(&block)
|
46
|
+
end
|
47
|
+
|
48
|
+
def actors
|
49
|
+
return @loaded_actors if @loaded_actors
|
50
|
+
@loaded_actors = @actors.each do |key, value|
|
51
|
+
@actors[key] = value.call
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def has_actor?(name)
|
56
|
+
actors.has_key?(name)
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_actor(name)
|
60
|
+
raise ActorNotRegistered unless has_actor?(name)
|
61
|
+
actors[name]
|
62
|
+
end
|
63
|
+
|
64
|
+
def scenes(stage)
|
65
|
+
return @loaded_scenes if @loaded_scenes
|
66
|
+
@loaded_scenes = @scenes.each do |key, value|
|
67
|
+
@scenes[key] = value.init(self, stage)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def has_scene?(stage, name)
|
72
|
+
scenes(stage).has_key?(name)
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_scene(stage, name)
|
76
|
+
raise SceneNotRegistered unless has_scene?(stage, name)
|
77
|
+
scenes(stage)[name]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Playwright
|
2
|
+
# == Playwright::Props
|
3
|
+
#
|
4
|
+
# Props are a collection of items that are used during the test. They are
|
5
|
+
# accessible through the Stage and can be a unique list which is filtered
|
6
|
+
# with the +find_or_add+ method. You can specify a lambda to specify how it
|
7
|
+
# compares existing items.
|
8
|
+
#
|
9
|
+
# first_product = Product.first
|
10
|
+
# products = Playwright::Props.new(Proc.new { |p| p.id })
|
11
|
+
#
|
12
|
+
# 2.times { products.find_or_add(first_product) }
|
13
|
+
#
|
14
|
+
# products #=> [first_product]
|
15
|
+
class Props < Array
|
16
|
+
attr_accessor :include_query # :nodoc:
|
17
|
+
|
18
|
+
# Creates a new prop collection with an optional lambda to determine if it
|
19
|
+
# has already been added from +find_or_add+
|
20
|
+
def initialize(include_query = nil)
|
21
|
+
@include_query = include_query
|
22
|
+
end
|
23
|
+
|
24
|
+
# Finds the first item in the array or adds it to the end.
|
25
|
+
def find_or_add(item)
|
26
|
+
self << item unless include?(item) || include_from_query?(item)
|
27
|
+
item
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def include_from_query?(item)
|
33
|
+
return if include_query.nil?
|
34
|
+
item_value = include_query.call(item)
|
35
|
+
any? { |v| include_query.call(v) == item_value }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Playwright
|
2
|
+
# == Playwright::Scene
|
3
|
+
#
|
4
|
+
# Scene is the service layer between your test and page object models. It
|
5
|
+
# allows common interactions to be duplicated in tests without letting the
|
6
|
+
# tests know too much about the page.
|
7
|
+
#
|
8
|
+
# class PurchaseProduct < Playwright::Scene
|
9
|
+
# sender_accessor :buyer
|
10
|
+
#
|
11
|
+
# def purchase_product(product)
|
12
|
+
# LoginHelper.login_as(buyer)
|
13
|
+
# ProductPage.purchase(product.id)
|
14
|
+
# stage.orders.find_or_add(product.orders.last)
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
class Scene
|
18
|
+
attr_reader :stage
|
19
|
+
attr_accessor :sender, :receiver
|
20
|
+
|
21
|
+
def initialize(stage, sender, receiver)
|
22
|
+
@stage = stage
|
23
|
+
@sender = sender
|
24
|
+
@receiver = receiver
|
25
|
+
end
|
26
|
+
|
27
|
+
# Aliases the +sender+ method to better describe who the action is coming
|
28
|
+
# from.
|
29
|
+
#
|
30
|
+
# class OrderScene < Playwright::Scene
|
31
|
+
# sender_accessor :buyer
|
32
|
+
#
|
33
|
+
# def purchase_product(product)
|
34
|
+
# LoginHelper.login_as(buyer)
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
def self.sender_accessor(name)
|
38
|
+
define_method(name, instance_method(:sender))
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
# Aliases the +receiver+ method to better describe who is receiving the
|
43
|
+
# action.
|
44
|
+
#
|
45
|
+
# class OrderScene < Playwright::Scene
|
46
|
+
# receiver_accessor :seller
|
47
|
+
#
|
48
|
+
# def deliver_order(order)
|
49
|
+
# LoginHelper.login_as(seller)
|
50
|
+
# end
|
51
|
+
# end
|
52
|
+
def self.receiver_accessor(name)
|
53
|
+
define_method(name, instance_method(:receiver))
|
54
|
+
end
|
55
|
+
|
56
|
+
def ==(other) # :nodoc:
|
57
|
+
return false unless other.is_a?(Scene)
|
58
|
+
stage == other.stage && sender == other.sender && receiver == other.receiver
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Playwright
|
2
|
+
# == Playwright::Stage
|
3
|
+
#
|
4
|
+
# Stage encapsulates the Actors, Scenes and Props for a test.
|
5
|
+
#
|
6
|
+
# === Actors
|
7
|
+
#
|
8
|
+
# Every stage needs actors. Actors added to the stage are available as
|
9
|
+
# instance methods and can be assigned a sender or receiver to a Scene.
|
10
|
+
#
|
11
|
+
# class ActorStage < Playwright::Stage
|
12
|
+
# actors do
|
13
|
+
# actor(:actor_1) { User.first! }
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# stage = ActorStage.new
|
18
|
+
# stage.actor_1 #=> User
|
19
|
+
#
|
20
|
+
# === Scenes
|
21
|
+
#
|
22
|
+
# Scenes are the service layer in your tests. They are the middleware between
|
23
|
+
# the test and the page object models.
|
24
|
+
#
|
25
|
+
# class SceneStage < Playwright::Stage
|
26
|
+
# actors do
|
27
|
+
# actor(:actor_1) { User.first! }
|
28
|
+
# actor(:actor_2) { User.second! }
|
29
|
+
# actor(:actor_3) { User.last! }
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# scenes do
|
33
|
+
# scene Scene1, from: :actor_1, to: actor_2
|
34
|
+
# scene Scene2, from: :actor_2, to: actor_3
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# stage = SceneStage.new
|
39
|
+
#
|
40
|
+
# # current scene with actors
|
41
|
+
# scene = stage.current_scene
|
42
|
+
# scene.sender #=> stage.actor_1
|
43
|
+
# scene.receiver #=> stage.actor_2
|
44
|
+
#
|
45
|
+
# # next scene with actors
|
46
|
+
# scene = stage.next_scene
|
47
|
+
# scene.sender #=> stage.actor_2
|
48
|
+
# scene.receiver #=> stage.actor_3
|
49
|
+
#
|
50
|
+
# === Full Example
|
51
|
+
#
|
52
|
+
# class FulfillmentStage < Playwright::Stage
|
53
|
+
# actors do
|
54
|
+
# actor(:buyer) { User.find_by(username: 'buyer') }
|
55
|
+
# actor(:seller) { User.find_by(username: 'seller') }
|
56
|
+
# actor(:fulfillment_agency) { FulfillmentAgency.find_by(name: 'agency-1') }
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# scenes do
|
60
|
+
# scene PurchaseProduct, from: :buyer, to: :seller
|
61
|
+
# scene FulfillOrder, from: :seller, to: :fulfillment_agency
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# prop_collection(:products) { |p| p.id }
|
65
|
+
# prop_collection(:orders) { |o| o.invoice_number }
|
66
|
+
# prop_collection(:fulfillments) { |f| f.id }
|
67
|
+
# end
|
68
|
+
class Stage
|
69
|
+
|
70
|
+
def method_missing(name, *args, &block)
|
71
|
+
narrator = self.class.narrator
|
72
|
+
return narrator.get_actor(name) if narrator.has_actor?(name)
|
73
|
+
return narrator.get_scene(self, name) if narrator.has_scene?(self, name)
|
74
|
+
super
|
75
|
+
end
|
76
|
+
|
77
|
+
def actors
|
78
|
+
self.class.narrator.actors
|
79
|
+
end
|
80
|
+
|
81
|
+
def scenes
|
82
|
+
self.class.narrator.scenes(self)
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.actors(&block)
|
86
|
+
narrator.add_actors(&block)
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.scenes(&block)
|
90
|
+
narrator.add_scenes(&block)
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.prop_collection(name, &block)
|
94
|
+
define_method name do
|
95
|
+
Props.new(block)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.narrator
|
100
|
+
Narrator.find_or_create(self)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/playwright.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'playwright/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "playwright"
|
8
|
+
spec.version = Playwright::VERSION
|
9
|
+
spec.authors = ["Baylor Rae'"]
|
10
|
+
spec.email = ["baylor@fastmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Playwright is a foundational piece for building a test framework.}
|
13
|
+
spec.description = %q{Playwright is a foundational piece for building a test framework.}
|
14
|
+
spec.homepage = "https://github.com/baylorrae/playwright"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "activesupport", "~> 5.0"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: playwright
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Baylor Rae'
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.11'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: Playwright is a foundational piece for building a test framework.
|
70
|
+
email:
|
71
|
+
- baylor@fastmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/playwright.rb
|
86
|
+
- lib/playwright/dsl/actor_dsl.rb
|
87
|
+
- lib/playwright/dsl/scene_dsl.rb
|
88
|
+
- lib/playwright/errors.rb
|
89
|
+
- lib/playwright/extensions.rb
|
90
|
+
- lib/playwright/narrator.rb
|
91
|
+
- lib/playwright/props.rb
|
92
|
+
- lib/playwright/scene.rb
|
93
|
+
- lib/playwright/stage.rb
|
94
|
+
- lib/playwright/version.rb
|
95
|
+
- playwright.gemspec
|
96
|
+
homepage: https://github.com/baylorrae/playwright
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.5.2
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Playwright is a foundational piece for building a test framework.
|
120
|
+
test_files: []
|