rspec-do_action 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +5 -0
- data/lib/rspec-do_action.rb +19 -16
- data/lib/rspec-do_action/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dd7110fd7c7b6dc3bce0ea12c8ba747b73af684e3288e0a5f4e392ba1ca75383
|
4
|
+
data.tar.gz: dbd38e301b622565e5c949f16fd30a25c650c4bb239dde304acac13c7f77b572
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15d9dd5e2496f790186358f746f8531d9ee4ce926d21a45401c6b293bea151e14068e381d7c4770cfdc2cd4a478c6e277083ddfc142dd09b646c714c67ac0ff7
|
7
|
+
data.tar.gz: 84ca14fccc1531c582acbfa0b34144c0ddc89ee8dbffcf547aa777493cf276ba03ed43deab381a56cbe3345f22ad4b5462d2a1d51a77f40942d8fcfbdf92bd76
|
data/README.md
CHANGED
@@ -45,6 +45,11 @@ describe "skip auto 'do_action' invoke" do
|
|
45
45
|
|
46
46
|
it { expect{ do_action }.to raise_error(RuntimeError) }
|
47
47
|
end
|
48
|
+
|
49
|
+
describe 'action with metadata', foo: 1 do
|
50
|
+
action { |example| expect(example.metadata[:foo]).to eq 1; @result = true }
|
51
|
+
it { expect(@result).to eq true }
|
52
|
+
end
|
48
53
|
```
|
49
54
|
|
50
55
|
## Contributing
|
data/lib/rspec-do_action.rb
CHANGED
@@ -5,23 +5,26 @@ module Rspec
|
|
5
5
|
module DoAction
|
6
6
|
|
7
7
|
module InstanceMethods
|
8
|
-
def do_action
|
9
|
-
expect(
|
10
|
-
|
8
|
+
def do_action(*args)
|
9
|
+
expect(action_proc).to_not be_nil, "need define action block"
|
10
|
+
instance_exec *args, &action_proc
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
return if
|
15
|
-
return if !force &&
|
13
|
+
def invoke_do_action_once(example, force: false)
|
14
|
+
return if !action_proc
|
15
|
+
return if !force && skip_do_action?
|
16
|
+
return if @do_action_once_invoked
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
@auto_do_action_once = true
|
20
|
-
end
|
18
|
+
do_action(example)
|
19
|
+
@do_action_once_invoked = true
|
21
20
|
end
|
22
21
|
|
23
|
-
def
|
24
|
-
find_variable("@
|
22
|
+
def action_proc
|
23
|
+
find_variable("@action_proc")
|
24
|
+
end
|
25
|
+
|
26
|
+
def skip_do_action?
|
27
|
+
!!find_variable("@skip_do_action")
|
25
28
|
end
|
26
29
|
|
27
30
|
def find_variable(name)
|
@@ -33,13 +36,13 @@ module Rspec
|
|
33
36
|
module ClassMethods
|
34
37
|
def action(options = {}, &block)
|
35
38
|
@skip_do_action = options[:skip]
|
36
|
-
@
|
39
|
+
@action_proc = block
|
37
40
|
end
|
38
41
|
|
39
42
|
def do_action(options = {}, &block)
|
40
43
|
@skip_do_action = false
|
41
44
|
action(options, &block) if block
|
42
|
-
before {
|
45
|
+
before { |example| invoke_do_action_once(example, force: true) }
|
43
46
|
end
|
44
47
|
|
45
48
|
def skip_do_action
|
@@ -50,9 +53,9 @@ module Rspec
|
|
50
53
|
end
|
51
54
|
|
52
55
|
class RSpec::Core::Example
|
53
|
-
def run_before_example_with_action
|
56
|
+
def run_before_example_with_action(*args)
|
54
57
|
run_before_example_without_action
|
55
|
-
example_group_instance.send(:
|
58
|
+
example_group_instance.send(:invoke_do_action_once, self, force: false)
|
56
59
|
end
|
57
60
|
|
58
61
|
if private_method_defined?(:run_before_example)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-do_action
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sunteya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.7.6
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: add 'acton' and some useful methods for rspec one-liner syntax.
|