allure-rspec 0.3.4 → 0.4.0
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/allure-rspec.rb +6 -0
- data/lib/allure-rspec/adaptor.rb +2 -0
- data/lib/allure-rspec/dsl.rb +8 -5
- data/lib/allure-rspec/hooks.rb +55 -0
- data/lib/allure-rspec/version.rb +1 -1
- data/spec/another_spec.rb +8 -0
- data/spec/extend_steps_spec.rb +33 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 508534700db94be2b689f750c44328efdd5de1c9
|
4
|
+
data.tar.gz: 1f08ed1aaa1e60d1828e356fd4b0809e71acb714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cd225374e89b44d2b6b6968a5710483e91d62efac8728cc4a296d2bf28d9898590b56c4bc9d1b5a7d1766b0763c41d75f1ef8c88ca41dc7d16edd7c4f4f02da
|
7
|
+
data.tar.gz: 186f6bea16e012666d0c9b6fa16343254b6dcdaff55630cd55ca9f70bb5bf26c6f5f70446424b7da65c526f748697d100d1bc0678fdac511cfe5c8f41cf11a8c
|
data/Gemfile.lock
CHANGED
data/lib/allure-rspec.rb
CHANGED
@@ -3,6 +3,7 @@ require 'allure-rspec/formatter'
|
|
3
3
|
require 'allure-rspec/adaptor'
|
4
4
|
require 'allure-rspec/dsl'
|
5
5
|
require 'allure-rspec/builder'
|
6
|
+
require 'allure-rspec/hooks'
|
6
7
|
|
7
8
|
module AllureRSpec
|
8
9
|
include AllureRSpec::DSL
|
@@ -10,12 +11,17 @@ module AllureRSpec
|
|
10
11
|
module Config
|
11
12
|
class << self
|
12
13
|
attr_accessor :output_dir
|
14
|
+
attr_accessor :rspec
|
13
15
|
|
14
16
|
DEFAULT_OUTPUT_DIR = 'allure/data'
|
15
17
|
|
16
18
|
def output_dir
|
17
19
|
@output_dir || DEFAULT_OUTPUT_DIR
|
18
20
|
end
|
21
|
+
|
22
|
+
def rspec
|
23
|
+
@rspec
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
21
27
|
|
data/lib/allure-rspec/adaptor.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
module AllureRSpec
|
2
2
|
module Adaptor
|
3
3
|
def self.included(base)
|
4
|
+
AllureRSpec::Config.rspec = base
|
4
5
|
base.send :include, AllureRSpec::DSL
|
5
6
|
if RSpec.configuration.formatters.find_all {|f| f.is_a?(AllureRSpec::Formatter)}.empty?
|
6
7
|
RSpec.configuration.add_formatter(AllureRSpec::Formatter)
|
7
8
|
end
|
9
|
+
RSpec::Core::ExampleGroup.send :include, AllureRSpec::Hooks
|
8
10
|
end
|
9
11
|
end
|
10
12
|
end
|
data/lib/allure-rspec/dsl.rb
CHANGED
@@ -3,8 +3,6 @@ require 'mimemagic'
|
|
3
3
|
module AllureRSpec
|
4
4
|
module DSL
|
5
5
|
|
6
|
-
ALLOWED_ATTACH_EXTS = %w[txt html xml png jpg json]
|
7
|
-
|
8
6
|
def __mutex
|
9
7
|
@@__mutex ||= Mutex.new
|
10
8
|
end
|
@@ -19,9 +17,14 @@ module AllureRSpec
|
|
19
17
|
|
20
18
|
def __with_step(step, &block)
|
21
19
|
__mutex.synchronize do
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
begin
|
21
|
+
Config.rspec.send :run_hook, :before, :step, example
|
22
|
+
@@__current_step = step
|
23
|
+
yield
|
24
|
+
ensure
|
25
|
+
Config.rspec.send :run_hook, :after, :step, example
|
26
|
+
@@__current_step = nil
|
27
|
+
end
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module AllureRSpec
|
2
|
+
module Hooks
|
3
|
+
|
4
|
+
def self.included(cls)
|
5
|
+
cls.extend OverrideHooksMethods
|
6
|
+
end
|
7
|
+
|
8
|
+
module OverrideHooksMethods
|
9
|
+
include RSpec::Core::Hooks
|
10
|
+
alias_method :old_extract_scope_from, :extract_scope_from
|
11
|
+
alias_method :old_hooks, :hooks
|
12
|
+
alias_method :old_find_hook, :find_hook
|
13
|
+
|
14
|
+
SCOPES = [:each, :all, :suite, :step]
|
15
|
+
|
16
|
+
def hooks
|
17
|
+
if @__hooks.nil?
|
18
|
+
@__hooks ||= old_hooks
|
19
|
+
[:before, :after].each { |scope|
|
20
|
+
@__hooks[scope][:step] = HookCollection.new
|
21
|
+
}
|
22
|
+
end
|
23
|
+
@__hooks
|
24
|
+
end
|
25
|
+
|
26
|
+
def before_step_hooks_for(example)
|
27
|
+
HookCollection.new(parent_groups.reverse.map { |a| a.hooks[:before][:step] }.flatten).for(example)
|
28
|
+
end
|
29
|
+
|
30
|
+
def after_step_hooks_for(example)
|
31
|
+
HookCollection.new(parent_groups.map { |a| a.hooks[:after][:step] }.flatten).for(example)
|
32
|
+
end
|
33
|
+
|
34
|
+
def find_hook(hook, scope, example_or_group, initial_procsy)
|
35
|
+
case [hook, scope]
|
36
|
+
when [:before, :step]
|
37
|
+
before_step_hooks_for(example_or_group)
|
38
|
+
when [:after, :step]
|
39
|
+
after_step_hooks_for(example_or_group)
|
40
|
+
else
|
41
|
+
old_find_hook(hook, scope, example_or_group, initial_procsy)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def extract_scope_from(args)
|
46
|
+
if SCOPES.include?(args.first)
|
47
|
+
args.shift
|
48
|
+
else
|
49
|
+
old_extract_scope_from(args)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
data/lib/allure-rspec/version.rb
CHANGED
data/spec/another_spec.rb
CHANGED
data/spec/extend_steps_spec.rb
CHANGED
@@ -2,6 +2,39 @@ require 'spec_helper'
|
|
2
2
|
require 'tempfile'
|
3
3
|
|
4
4
|
describe AllureRSpec do
|
5
|
+
|
6
|
+
before(:suite) do
|
7
|
+
puts "before suite"
|
8
|
+
end
|
9
|
+
|
10
|
+
before(:all) do
|
11
|
+
puts "before all"
|
12
|
+
end
|
13
|
+
|
14
|
+
before(:step) do
|
15
|
+
puts "before step"
|
16
|
+
end
|
17
|
+
|
18
|
+
before(:each) do
|
19
|
+
puts "before each"
|
20
|
+
end
|
21
|
+
|
22
|
+
after(:step) do
|
23
|
+
puts "after step"
|
24
|
+
end
|
25
|
+
|
26
|
+
after(:each) do
|
27
|
+
puts "after each"
|
28
|
+
end
|
29
|
+
|
30
|
+
after(:suite) do
|
31
|
+
puts "after suite"
|
32
|
+
end
|
33
|
+
|
34
|
+
after(:all) do
|
35
|
+
puts "after all"
|
36
|
+
end
|
37
|
+
|
5
38
|
it "should build" do
|
6
39
|
attach_file "test-file1", Tempfile.new("test")
|
7
40
|
step "step1" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: allure-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Sadykov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/allure-rspec/builder.rb
|
113
113
|
- lib/allure-rspec/dsl.rb
|
114
114
|
- lib/allure-rspec/formatter.rb
|
115
|
+
- lib/allure-rspec/hooks.rb
|
115
116
|
- lib/allure-rspec/version.rb
|
116
117
|
- logo.png
|
117
118
|
- spec/another_spec.rb
|
@@ -140,5 +141,5 @@ rubyforge_project:
|
|
140
141
|
rubygems_version: 2.0.3
|
141
142
|
signing_key:
|
142
143
|
specification_version: 4
|
143
|
-
summary: allure-rspec-0.
|
144
|
+
summary: allure-rspec-0.4.0
|
144
145
|
test_files: []
|