screengem 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cd749e9d769dc9f60bd7f25b4e5a5d1ef571f7e677b8899e60186b5fec6c351
4
- data.tar.gz: 229544036b8cb8fca593981f91f82915a22488ec16fcdf0d2d81604e3330fda2
3
+ metadata.gz: 59794b81ef61dfaac8b24ada31840f7b06bf10256b49a26d938409902a0733e2
4
+ data.tar.gz: 574b6278358edde4ffcfeda8426b0873949deee001162694045919a5ce2eb706
5
5
  SHA512:
6
- metadata.gz: 4ede6cabff701aa9e0834bd0a430efa9d16b9b9b82fdfb427314e9e00fd5266e4f6955ad99632d336bdbf718f3739dd2ebdbdeb707119a3a0dda6b4fdd7df0bf
7
- data.tar.gz: 3514009fa5061cc2f231c0a2cfff897277d3844d67bc1f051de85d6bce1d01426eac30793c739cf36be5fd9aec32c1da8e79bbeb6177a1930dc57fb88a4611dc
6
+ metadata.gz: a2a37e7c2235866deae4b2462a073735fadb47d48ed187080541169a10b05cfb3445db06bc7740b247e0a27a738216342d33e507ec281eb0b15b01c59264b2a7
7
+ data.tar.gz: 7f361d7e3a584863de72b8fb52964a1194981826a1a6249b6fe5270cddaa65a4ab28c67523682cdd5785eab19d483484969c4f8f68b5e25f609c585e78fa4033
data/.rspec CHANGED
@@ -1,3 +1,4 @@
1
1
  --format documentation
2
2
  --color
3
- --require spec_helper
3
+ --require screengem_spec_helper
4
+
data/.rubocop.yml CHANGED
@@ -15,6 +15,9 @@ Metrics/MethodLength:
15
15
  RSpec/AnyInstance:
16
16
  Enabled: false
17
17
 
18
+ RSpec/DescribedClass:
19
+ Enabled: false
20
+
18
21
  RSpec/ExampleLength:
19
22
  Max: 20
20
23
 
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.3.0 (2019-03-16)
6
+
7
+ ### New Features
8
+
9
+ * Scope screen elements to the `screen` instance variable
10
+ * Screen elements are no longer memoized
11
+ * Add example step definitions to the README
12
+
5
13
  ## 0.2.0 (2019-03-12)
6
14
 
7
15
  ### New features
data/README.md CHANGED
@@ -2,12 +2,19 @@
2
2
 
3
3
  A simple Ruby implementation of the [Screenplay Pattern](https://ideas.riverglide.com/page-objects-refactored-12ec3541990).
4
4
 
5
- ## Installation
5
+ Screengem promotes writing step definitions in terms of actors, the tasks that the actor performs,
6
+ and the questions that the actor asks.
6
7
 
7
- Add this line to your application's Gemfile:
8
+ ## Example Step Definitions
8
9
 
9
10
  ```ruby
10
- gem 'screengem'
11
+ Given(/^that they are signed in and viewing the (.+?)$/) do |section_name|
12
+ actor.performs(task.sign_in, task.remember_signature_counter(section_name))
13
+ end
14
+
15
+ Then(/^their signature is captured$/) do
16
+ actor.asks(question.signature_captured)
17
+ end
11
18
  ```
12
19
 
13
20
  ## Core Domain Model
@@ -21,6 +28,14 @@ A Task responds to perform and may execute one or more actions.
21
28
 
22
29
  ![Core Domain Model](/images/ScreengemCore.png)
23
30
 
31
+ ## Installation
32
+
33
+ Add this line to your application's Gemfile:
34
+
35
+ ```ruby
36
+ gem 'screengem'
37
+ ```
38
+
24
39
  ## Development
25
40
 
26
41
  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.
@@ -8,8 +8,9 @@ module Screengem
8
8
  # The ability to remember and recall values is used to carry state forward from one
9
9
  # step definition to another (as the preferred alternative to instance variables).
10
10
  #
11
- # Action, question, and task instances are extended with PageReferences so that
12
- # they can interact with the application via page objects.
11
+ # Action, question, and task instances (aka primitives) are configured with:
12
+ # (1) a reference to the actor that is interacting with the primitive
13
+ # (2) a reference to the screen instance that hosts accessors to the page objects.
13
14
  #
14
15
  module Actor
15
16
  #
@@ -17,7 +18,7 @@ module Screengem
17
18
  #
18
19
  def asks(*questions)
19
20
  questions.each do |question|
20
- question.configure(self).extend(page_references)
21
+ question.configure(self, screen)
21
22
 
22
23
  next if question.answer
23
24
 
@@ -32,7 +33,7 @@ module Screengem
32
33
  #
33
34
  def performs(*tasks)
34
35
  tasks.each do |task|
35
- task.configure(self).extend(page_references)
36
+ task.configure(self, screen)
36
37
 
37
38
  task.perform
38
39
  end
@@ -63,7 +64,7 @@ module Screengem
63
64
  #
64
65
  def takes_action(*actions)
65
66
  actions.each do |action|
66
- action.configure(self).extend(page_references)
67
+ action.configure(self, screen)
67
68
 
68
69
  action.execute
69
70
  end
@@ -75,12 +76,12 @@ module Screengem
75
76
  Screengem::IncorrectAnswer.new(question)
76
77
  end
77
78
 
78
- def page_references
79
- @page_references ||= Screengem::PageReferences
80
- end
81
-
82
79
  def recollections
83
80
  @recollections ||= ActiveSupport::HashWithIndifferentAccess.new
84
81
  end
82
+
83
+ def screen
84
+ Screengem::PageReferences.instance
85
+ end
85
86
  end
86
87
  end
@@ -1,16 +1,17 @@
1
1
  module Screengem
2
2
  #
3
- # Concern that adds ability to configure with an actor instance.
3
+ # Concern that adds ability to configure a primitive with an actor and screen instance.
4
4
  #
5
5
  module Configurable
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
- attr_reader :actor
9
+ attr_reader :actor, :screen
10
10
  end
11
11
 
12
- def configure(actor)
12
+ def configure(actor, screen)
13
13
  @actor = actor
14
+ @screen = screen
14
15
 
15
16
  self
16
17
  end
@@ -1,23 +1,17 @@
1
1
  module Screengem
2
2
  #
3
- # Mixin that gives the ability to get references to page objects.
3
+ # Singleton that gives the ability to get references to page objects.
4
4
  #
5
+ # On initialization generate a factory method for each page object we can find. Example:
6
+ #
7
+ # def login_page
8
+ # Pages::LoginPage.new
9
+ # end
10
+ #
11
+ class PageReferences
12
+ include Singleton
5
13
 
6
- # rubocop:disable Style/GuardClause
7
- module PageReferences
8
- def self.extended(_mod)
9
- # One time definition of the page object references.
10
- return unless PageReferences.instance_methods.empty?
11
-
12
- #
13
- # Generate a factory method for each page object we can find.
14
- #
15
- # Example:
16
- #
17
- # def login_page
18
- # @login_page ||= Pages::LoginPage.new
19
- # end
20
- #
14
+ def initialize
21
15
  generated_method_names = []
22
16
 
23
17
  Screengem::FeaturePage.descendants.each do |page_object|
@@ -26,17 +20,16 @@ module Screengem
26
20
 
27
21
  if generated_method_names.include?(method_name)
28
22
  raise "Name collision: two page objects resolve to '#{method_name}'."
29
- else
30
- generated_method_names << method_name
31
23
  end
32
24
 
33
- module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
34
- def #{method_name}
35
- @#{method_name} ||= #{class_name}.new
25
+ generated_method_names << method_name
26
+
27
+ class_eval(<<~RUBY, __FILE__, __LINE__ + 1)
28
+ def #{method_name}(*args)
29
+ #{class_name}.new(*args)
36
30
  end
37
31
  RUBY
38
32
  end
39
33
  end
40
34
  end
41
- # rubocop:enable Style/GuardClause
42
35
  end
@@ -1,3 +1,3 @@
1
1
  module Screengem
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/screengem.gemspec CHANGED
@@ -35,6 +35,6 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.add_development_dependency "rake", "~> 12.0"
37
37
  spec.add_development_dependency "rspec", "~> 3.8"
38
- spec.add_development_dependency "rubocop", "~> 0.64"
38
+ spec.add_development_dependency "rubocop", "~> 0.65"
39
39
  spec.add_development_dependency "rubocop-rspec", "~> 1.32"
40
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: screengem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alistair McKinnell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-12 00:00:00.000000000 Z
11
+ date: 2019-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -112,14 +112,14 @@ dependencies:
112
112
  requirements:
113
113
  - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: '0.64'
115
+ version: '0.65'
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: '0.64'
122
+ version: '0.65'
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: rubocop-rspec
125
125
  requirement: !ruby/object:Gem::Requirement