screengem 0.8.1 → 0.9.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: 2f613d52a7f2c21395da3ae69ec06038fd8b0c77b5534fdb6589bd17869787b6
4
- data.tar.gz: 20789cb799e7b7480f22d45537448fe805a17f42c123887598f9d08efab6b55e
3
+ metadata.gz: accc4cf6330e69e04fb0c2ccf8aded873f0cdd6ca7f548f4d15a0acb3d4f1f7d
4
+ data.tar.gz: 68c1c36c5b7763557719751f4e58f5890054e79c09d8fc9fe9cc6dc01fd3a45e
5
5
  SHA512:
6
- metadata.gz: 03ed64caa475c19be70ffb9b9fbf7e5fcef24b6ec9c8ce09b176d8d93ef96dd8d29b08353c3102b91707800dfd3e1c6275fdf3ed2a1debb865be3748cf685714
7
- data.tar.gz: 03d28f961b96b2c87d60700ec2e857d8a55bc79fed093025b3b3bcf2f296f15ec3d91ae753daf9b87545aba180151eb16e156a0e3d9c42717945c1fffa9ba3ba
6
+ metadata.gz: ca06a1fb1c48d88a12b93f56da624dc082535af69608be82b2547fe9da6f4799724cc2294a7fde8db9ef242ccc7374698c05e5f1c97aeeaf921d89ad2a03e245
7
+ data.tar.gz: 6f9ac792ef8b6538a2e1d4829a6ff9d7ad43c33f8bfc45a70ec325f1a03cc1ec0a13ebbdca1820193e82f5512cb2d4fdaf41968756d5cfd926e4165828c28827
@@ -2,7 +2,11 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
- ## 0.8.1 (2019-09-20)
5
+ ## 0.9.0 (2019-09-25)
6
+
7
+ * Support for actor memory outside actor instances (support ParameterType actors)
8
+
9
+ ## 0.8.1 (2019-08-20)
6
10
 
7
11
  * Support for Rails 6 (only ActiveSupport)
8
12
  * Latest development dependencies
data/README.md CHANGED
@@ -8,11 +8,11 @@ and the questions that the actor asks.
8
8
  ## Example Step Definitions
9
9
 
10
10
  ```ruby
11
- Given(/^that they are signed in and viewing the (.+?)$/) do |section_name|
11
+ Given("that they are signed in and viewing the {section_name}") do |section_name|
12
12
  actor.performs(task.sign_in, task.remember_signature_counter(section_name))
13
13
  end
14
14
 
15
- Then(/^their signature is captured$/) do
15
+ Then("their signature is captured") do
16
16
  actor.asks(question.signature_captured)
17
17
  end
18
18
  ```
@@ -28,12 +28,16 @@ A Task responds to perform and may execute one or more actions.
28
28
 
29
29
  ![Core Domain Model](/images/ScreengemCore.png)
30
30
 
31
- ## Installation
31
+ ## Actor Memory
32
32
 
33
- Add this line to your application's Gemfile:
33
+ Actors are able to remember and recall facts. This is the recommended way to
34
+ pass state between steps. To clear all actor's memory before each scenario
35
+ add a hook:
34
36
 
35
- ```ruby
36
- gem 'screengem'
37
+ ```
38
+ Before do
39
+ Screengem::ActorMemory.instance.clear
40
+ end
37
41
  ```
38
42
 
39
43
  ## Dampening
@@ -49,6 +53,14 @@ To enable and configure dampening perform the following steps:
49
53
 
50
54
  To stop dampening, run `unset APPLY_DAMPENING`
51
55
 
56
+ ## Installation
57
+
58
+ Add this line to your application's Gemfile:
59
+
60
+ ```ruby
61
+ gem 'screengem'
62
+ ```
63
+
52
64
  ## Development
53
65
 
54
66
  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.
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "rubocop/rake_task"
3
4
 
5
+ RuboCop::RakeTask.new
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task default: :spec
8
+ task default: [:rubocop, :spec]
@@ -30,6 +30,7 @@ require "screengem/browser_action"
30
30
  require "screengem/question"
31
31
  require "screengem/task"
32
32
 
33
+ require "screengem/actor_memory"
33
34
  require "screengem/actor"
34
35
 
35
36
  require "screengem/factories/factory_creation_error"
@@ -86,7 +86,7 @@ module Screengem
86
86
  end
87
87
 
88
88
  def recollections
89
- @recollections ||= ActiveSupport::HashWithIndifferentAccess.new
89
+ ActorMemory.instance.recollections(self)
90
90
  end
91
91
 
92
92
  def screen
@@ -0,0 +1,27 @@
1
+ module Screengem
2
+ #
3
+ # Ensures that the memory/recollections that an actor uses are effectively global (using the actor name).
4
+ #
5
+ # This is required to use Cucumber ParameterTypes because the block arguments are cloned before they are
6
+ # provided to the step definitions. This is intentional by the cucumber team to prevent leaking state
7
+ # between step definitions. See https://github.com/cucumber/cucumber-ruby/issues/1275.
8
+ #
9
+ # The cloning of the actor means that is is effectively treated like a value object, and there will be
10
+ # many instances of the same actor instantiated in the execution of a single test.
11
+ #
12
+ class ActorMemory
13
+ include ::Singleton
14
+
15
+ def recollections(actor)
16
+ @recollections ||= ActiveSupport::HashWithIndifferentAccess.new
17
+ @recollections[actor.name] ||= ActiveSupport::HashWithIndifferentAccess.new
18
+ end
19
+
20
+ #
21
+ # Use this method to clear actor memory to avoid actor memory persisting across scenarios.
22
+ #
23
+ def clear
24
+ @recollections = ActiveSupport::HashWithIndifferentAccess.new
25
+ end
26
+ end
27
+ end
@@ -29,7 +29,7 @@ module Screengem
29
29
 
30
30
  method_name = class_name.demodulize.underscore
31
31
 
32
- # Create some safety by detecting and failing fast for duplicate creation method names
32
+ # Create some safety by detecting and failing fast for duplicate creation method names.
33
33
  if generated_method_names.include?(method_name)
34
34
  raise "Name collision: two screen elements resolve to '#{method_name}'."
35
35
  end
@@ -1,3 +1,3 @@
1
1
  module Screengem
2
- VERSION = "0.8.1"
2
+ VERSION = "0.9.0"
3
3
  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.8.1
4
+ version: 0.9.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-08-20 00:00:00.000000000 Z
11
+ date: 2019-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -189,6 +189,7 @@ files:
189
189
  - lib/screengem.rb
190
190
  - lib/screengem/action.rb
191
191
  - lib/screengem/actor.rb
192
+ - lib/screengem/actor_memory.rb
192
193
  - lib/screengem/automatic_visit.rb
193
194
  - lib/screengem/browser_action.rb
194
195
  - lib/screengem/cli.rb
@@ -239,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
240
  - !ruby/object:Gem::Version
240
241
  version: '0'
241
242
  requirements: []
242
- rubygems_version: 3.0.4
243
+ rubygems_version: 3.0.6
243
244
  signing_key:
244
245
  specification_version: 4
245
246
  summary: Ruby implementation of the Screengem Pattern.