allure-rspec 0.5.4 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- allure-rspec (0.5.3)
5
- allure-ruby-adaptor-api (= 0.6.6)
6
- rspec (~> 2.14.0)
4
+ allure-rspec (0.6.1)
5
+ allure-ruby-adaptor-api (= 0.6.3)
6
+ rspec (= 3.0.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- allure-ruby-adaptor-api (0.6.6)
11
+ allure-ruby-adaptor-api (0.6.3)
12
12
  mimemagic
13
13
  nokogiri (~> 1.6.0)
14
14
  uuid
@@ -16,18 +16,22 @@ GEM
16
16
  macaddr (1.7.1)
17
17
  systemu (~> 2.6.2)
18
18
  mimemagic (0.2.1)
19
- mini_portile (0.6.2)
20
- nokogiri (1.6.6.2)
21
- mini_portile (~> 0.6.0)
22
- rake (10.1.0)
23
- rspec (2.14.1)
24
- rspec-core (~> 2.14.0)
25
- rspec-expectations (~> 2.14.0)
26
- rspec-mocks (~> 2.14.0)
27
- rspec-core (2.14.7)
28
- rspec-expectations (2.14.4)
29
- diff-lcs (>= 1.1.3, < 2.0)
30
- rspec-mocks (2.14.4)
19
+ mini_portile (0.6.0)
20
+ nokogiri (1.6.3.1)
21
+ mini_portile (= 0.6.0)
22
+ rake (10.3.2)
23
+ rspec (3.0.0)
24
+ rspec-core (~> 3.0.0)
25
+ rspec-expectations (~> 3.0.0)
26
+ rspec-mocks (~> 3.0.0)
27
+ rspec-core (3.0.4)
28
+ rspec-support (~> 3.0.0)
29
+ rspec-expectations (3.0.4)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.0.0)
32
+ rspec-mocks (3.0.4)
33
+ rspec-support (~> 3.0.0)
34
+ rspec-support (3.0.4)
31
35
  systemu (2.6.4)
32
36
  uuid (2.3.7)
33
37
  macaddr (~> 1.0)
@@ -18,8 +18,8 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ['lib']
20
20
 
21
- s.add_dependency 'rspec', '~> 2.14.0'
22
- s.add_dependency 'allure-ruby-adaptor-api', '0.6.6'
21
+ s.add_dependency 'rspec', '3.0.0'
22
+ s.add_dependency 'allure-ruby-adaptor-api', '0.6.3'
23
23
 
24
24
  s.add_development_dependency 'bundler'
25
25
  s.add_development_dependency 'rake'
@@ -6,8 +6,6 @@ require 'allure-rspec/dsl'
6
6
  require 'allure-rspec/hooks'
7
7
 
8
8
  module AllureRSpec
9
- include AllureRSpec::DSL
10
-
11
9
  module Config
12
10
  class << self
13
11
  attr_accessor :output_dir
@@ -42,7 +40,7 @@ module AllureRSpec
42
40
  class << self
43
41
  def configure(&block)
44
42
  yield Config
45
- AllureRubyAdaptorApi.configure {|c|
43
+ AllureRubyAdaptorApi.configure { |c|
46
44
  c.output_dir = Config.output_dir
47
45
  }
48
46
  end
@@ -3,10 +3,12 @@ module AllureRSpec
3
3
  def self.included(base)
4
4
  AllureRSpec.context.rspec = base
5
5
  base.send :include, AllureRSpec::DSL
6
- if RSpec.configuration.formatters.find_all { |f| f.is_a?(AllureRSpec::Formatter) }.empty?
6
+ if RSpec::Core::Formatters::Loader.formatters.keys.find_all { |f| f == AllureRSpec::Formatter }.empty?
7
+ RSpec::Core::Formatters.register AllureRSpec::Formatter, *AllureRSpec::Formatter::NOTIFICATIONS
7
8
  RSpec.configuration.add_formatter(AllureRSpec::Formatter)
8
9
  end
9
10
  RSpec::Core::ExampleGroup.send :include, AllureRSpec::Hooks
11
+ RSpec::Core::Example.send :include, AllureRSpec::DSL::Example
10
12
  end
11
13
  end
12
14
  end
@@ -2,44 +2,47 @@ require 'digest'
2
2
  require 'mimemagic'
3
3
  module AllureRSpec
4
4
  module DSL
5
- def current_step
6
- if defined? @@__current_step
7
- @@__current_step
8
- else
9
- nil
5
+ module Example
6
+
7
+ def current_step
8
+ if defined? @@__current_step
9
+ @@__current_step
10
+ else
11
+ nil
12
+ end
10
13
  end
11
- end
12
14
 
13
- def step(step, &block)
14
- suite = self.example.metadata[:example_group][:description_args].first
15
- test = self.example.metadata[:description]
16
- AllureRubyAdaptorApi::Builder.start_step(suite, test, step)
17
- __with_step step, &block
18
- AllureRubyAdaptorApi::Builder.stop_step(suite, test, step)
19
- end
15
+ def step(step, &block)
16
+ suite = metadata[:example_group][:description_args].first.to_s
17
+ test = metadata[:description].to_s
18
+ AllureRubyAdaptorApi::Builder.start_step(suite, test, step)
19
+ __with_step step, &block
20
+ AllureRubyAdaptorApi::Builder.stop_step(suite, test, step)
21
+ end
20
22
 
21
- def attach_file(title, file, opts = {})
22
- suite = self.example.metadata[:example_group][:description_args].first
23
- test = self.example.metadata[:description]
24
- step = current_step
25
- AllureRubyAdaptorApi::Builder.add_attachment suite, test, opts.merge(:file => file, :title => title, :step => step)
26
- end
23
+ def attach_file(title, file, opts = {})
24
+ suite = metadata[:example_group][:description_args].first.to_s
25
+ test = metadata[:description].to_s
26
+ step = current_step
27
+ AllureRubyAdaptorApi::Builder.add_attachment suite, test, opts.merge(:title => title, :file => file, :step => step)
28
+ end
27
29
 
28
- private
30
+ private
29
31
 
30
- def __mutex
31
- @@__mutex ||= Mutex.new
32
- end
32
+ def __mutex
33
+ @@__mutex ||= Mutex.new
34
+ end
33
35
 
34
- def __with_step(step, &block)
35
- __mutex.synchronize do
36
- begin
37
- @@__current_step = step
38
- AllureRSpec.context.rspec.send :run_hook, :before, :step, example
39
- yield
40
- ensure
41
- AllureRSpec.context.rspec.send :run_hook, :after, :step, example
42
- @@__current_step = nil
36
+ def __with_step(step, &block)
37
+ __mutex.synchronize do
38
+ begin
39
+ @@__current_step = step
40
+ AllureRSpec.context.rspec.hooks.send :run, :before, :step, self
41
+ yield self
42
+ ensure
43
+ AllureRSpec.context.rspec.hooks.send :run, :after, :step, self
44
+ @@__current_step = nil
45
+ end
43
46
  end
44
47
  end
45
48
  end
@@ -5,53 +5,52 @@ module AllureRSpec
5
5
 
6
6
  class Formatter < RSpec::Core::Formatters::BaseFormatter
7
7
 
8
+ NOTIFICATIONS = [:example_group_started, :example_group_finished, :example_started,
9
+ :example_failed, :example_passed, :example_pending, :start, :stop]
8
10
  ALLOWED_LABELS = [:feature, :story, :severity, :language, :framework]
9
11
 
10
12
  def example_failed(example)
13
+ res = example.example.execution_result
11
14
  AllureRubyAdaptorApi::Builder.stop_test(
12
- example.metadata[:example_group][:description_args].first,
13
- example.metadata[:description],
14
- example.metadata[:execution_result].merge(
15
- :caller => example.metadata[:caller],
16
- :exception => example.metadata[:execution_result][:exception]
17
- )
15
+ example.example.example_group.description,
16
+ example.example.description.to_s,
17
+ {
18
+ :exception => res.exception,
19
+ :status => res.status,
20
+ :finished_at => res.finished_at,
21
+ :started_at => res.started_at
22
+ }
18
23
  )
19
- super
20
24
  end
21
25
 
22
26
  def example_group_finished(group)
23
- AllureRubyAdaptorApi::Builder.stop_suite(group.metadata[:example_group][:description_args].first)
24
- super
27
+ AllureRubyAdaptorApi::Builder.stop_suite(group.group.description.to_s)
25
28
  end
26
29
 
27
30
  def example_group_started(group)
28
- AllureRubyAdaptorApi::Builder.start_suite(group.metadata[:example_group][:description_args].first, labels(group))
29
- super
31
+ AllureRubyAdaptorApi::Builder.start_suite(group.group.description.to_s, labels(group))
30
32
  end
31
33
 
32
34
  def example_passed(example)
35
+ res = example.example.execution_result
33
36
  AllureRubyAdaptorApi::Builder.stop_test(
34
- example.metadata[:example_group][:description_args].first,
35
- example.metadata[:description],
36
- example.metadata[:execution_result].merge(:caller => example.metadata[:caller])
37
+ example.example_group.description,
38
+ example.description.to_s,
39
+ {
40
+ :status => res.status,
41
+ :finished_at => res.finished_at,
42
+ :started_at => res.started_at
43
+ }
37
44
  )
38
- super
39
45
  end
40
46
 
41
47
  def example_pending(example)
42
- AllureRubyAdaptorApi::Builder.stop_test(
43
- example.metadata[:example_group][:description_args].first,
44
- example.metadata[:description],
45
- :status => :pending
46
- )
47
- super
48
48
  end
49
49
 
50
50
  def example_started(example)
51
- suite = example.metadata[:example_group][:description_args].first
52
- test = example.metadata[:description]
51
+ suite = example.example.example_group.description
52
+ test = example.example.description.to_s
53
53
  AllureRubyAdaptorApi::Builder.start_test(suite, test, labels(example))
54
- super
55
54
  end
56
55
 
57
56
  def start(example_count)
@@ -61,19 +60,23 @@ module AllureRSpec
61
60
  FileUtils.rm_rf(dir)
62
61
  end
63
62
  FileUtils.mkdir_p(dir)
64
- super
65
63
  end
66
64
 
67
- def stop
65
+ def stop(notify)
68
66
  AllureRubyAdaptorApi::Builder.build!
69
- super
70
67
  end
71
68
 
72
69
  private
73
70
 
71
+ def metadata(example_or_group)
72
+ (example_or_group.respond_to? :group) ?
73
+ example_or_group.group.metadata :
74
+ example_or_group.example.metadata
75
+ end
76
+
74
77
  def labels(example_or_group)
75
78
  ALLOWED_LABELS.
76
- map { |label| [label, example_or_group.metadata[label]] }.
79
+ map { |label| [label, metadata(example_or_group)[label]] }.
77
80
  find_all { |value| !value[1].nil? }.
78
81
  inject({}) { |res, value| res.merge(value[0] => value[1]) }
79
82
  end
@@ -7,47 +7,53 @@ module AllureRSpec
7
7
 
8
8
  module OverrideHooksMethods
9
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
10
 
14
- SCOPES = [:each, :all, :suite, :step]
11
+ alias_method :old_hooks, :hooks
15
12
 
16
13
  def hooks
17
14
  if @__hooks.nil?
18
- @__hooks ||= old_hooks
15
+ old = old_hooks
16
+ @__hooks ||= OverridenHookCollections.new(old.instance_variable_get(:@owner), old.instance_variable_get(:@data))
19
17
  [:before, :after].each { |scope|
20
18
  @__hooks[scope][:step] = HookCollection.new
21
19
  }
22
20
  end
23
21
  @__hooks
24
22
  end
23
+ private
25
24
 
26
- def before_step_hooks_for(example)
27
- HookCollection.new(parent_groups.reverse.map { |a| a.hooks[:before][:step] }.flatten).for(example)
28
- end
25
+ class OverridenHookCollections < RSpec::Core::Hooks::HookCollections
26
+ private
29
27
 
30
- def after_step_hooks_for(example)
31
- HookCollection.new(parent_groups.map { |a| a.hooks[:after][:step] }.flatten).for(example)
32
- end
28
+ SCOPES = [:each, :all, :suite, :step]
33
29
 
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)
30
+ def before_step_hooks_for(example)
31
+ RSpec::Core::Hooks::HookCollection.new(RSpec::Core::FlatMap.flat_map(@owner.parent_groups.reverse) do |a|
32
+ a.hooks[:before][:step]
33
+ end).for(example)
42
34
  end
43
- end
44
35
 
45
- def extract_scope_from(args)
46
- if SCOPES.include?(args.first)
47
- args.shift
48
- else
49
- old_extract_scope_from(args)
36
+ def after_step_hooks_for(example)
37
+ RSpec::Core::Hooks::HookCollection.new(RSpec::Core::FlatMap.flat_map(@owner.parent_groups) do |a|
38
+ a.hooks[:after][:step]
39
+ end).for(example)
50
40
  end
41
+
42
+ def find_hook(hook, scope, example_or_group, initial_procsy)
43
+ case [hook, scope]
44
+ when [:before, :step]
45
+ before_step_hooks_for(example_or_group)
46
+ when [:after, :step]
47
+ after_step_hooks_for(example_or_group)
48
+ else
49
+ super(hook, scope, example_or_group, initial_procsy)
50
+ end
51
+ end
52
+
53
+ def known_scope?(scope)
54
+ SCOPES.include?(scope) || super(scope)
55
+ end
56
+
51
57
  end
52
58
  end
53
59
  end
@@ -1,5 +1,5 @@
1
1
  module AllureRSpec # :nodoc:
2
2
  module Version # :nodoc:
3
- STRING = '0.5.4'
3
+ STRING = '0.6.1'
4
4
  end
5
5
  end
@@ -12,12 +12,10 @@ describe "Some another spec", :feature => ["Some Feature"], :severity => :normal
12
12
  end
13
13
 
14
14
  it "10 cannot be greater than 19", :story => ["Some story"] do
15
- 10.should > 19
15
+ expect(10).to be > 19
16
16
  end
17
17
 
18
18
  it "4 must not be equal to 5" do
19
- 5.should == 4
19
+ expect(5).to be eql(4)
20
20
  end
21
-
22
- it "must be pending"
23
21
  end
@@ -35,20 +35,19 @@ describe AllureRSpec, :feature => "Basics" do
35
35
  puts "after all"
36
36
  end
37
37
 
38
- it "should build", :story => "Main story" do
39
- attach_file "test-file1", Tempfile.new("test")
40
- step "step1" do
41
- attach_file "test-file2", Tempfile.new("test")
38
+ it "should build", :story => "Main story" do |ex|
39
+ ex.attach_file "test-file1", Tempfile.new("test")
40
+ ex.step "step1" do |step|
41
+ step.attach_file "test-file2", Tempfile.new("test")
42
42
  end
43
43
 
44
- step "step2" do
45
- attach_file "logo", File.new("logo.png")
46
- 5.should be > 1
44
+ ex.step "step2" do |step|
45
+ step.attach_file "logo", File.new("logo.png")
46
+ expect(5).to be > 1
47
47
  end
48
48
 
49
- step "step3" do
50
-
51
- 0.should == 1
49
+ ex.step "step3" do
50
+ expect(0).to be eql(1)
52
51
  end
53
52
  end
54
53
  end
metadata CHANGED
@@ -1,69 +1,78 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.6.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Ilya Sadykov
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-04-08 00:00:00.000000000 Z
12
+ date: 2014-08-22 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rspec
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - ~>
19
+ - - '='
18
20
  - !ruby/object:Gem::Version
19
- version: 2.14.0
21
+ version: 3.0.0
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - ~>
27
+ - - '='
25
28
  - !ruby/object:Gem::Version
26
- version: 2.14.0
29
+ version: 3.0.0
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: allure-ruby-adaptor-api
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - '='
32
36
  - !ruby/object:Gem::Version
33
- version: 0.6.6
37
+ version: 0.6.3
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - '='
39
44
  - !ruby/object:Gem::Version
40
- version: 0.6.6
45
+ version: 0.6.3
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: bundler
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rake
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - '>='
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: '0'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - '>='
75
+ - - ! '>='
67
76
  - !ruby/object:Gem::Version
68
77
  version: '0'
69
78
  description: Adaptor to use Allure framework along with the RSpec 2
@@ -91,26 +100,26 @@ files:
91
100
  homepage: http://allure.qatools.ru
92
101
  licenses:
93
102
  - Apache2
94
- metadata: {}
95
103
  post_install_message:
96
104
  rdoc_options: []
97
105
  require_paths:
98
106
  - lib
99
107
  required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
100
109
  requirements:
101
- - - '>='
110
+ - - ! '>='
102
111
  - !ruby/object:Gem::Version
103
112
  version: '0'
104
113
  required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
105
115
  requirements:
106
- - - '>='
116
+ - - ! '>='
107
117
  - !ruby/object:Gem::Version
108
118
  version: '0'
109
119
  requirements: []
110
120
  rubyforge_project:
111
- rubygems_version: 2.0.3
121
+ rubygems_version: 1.8.25
112
122
  signing_key:
113
- specification_version: 4
114
- summary: allure-rspec-0.5.4
123
+ specification_version: 3
124
+ summary: allure-rspec-0.6.1
115
125
  test_files: []
116
- has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 5a3d449b806a2d0770c852e75d40f29a44e1786c
4
- data.tar.gz: 447f526780571ed70fb9d1a78b59762bd406b933
5
- SHA512:
6
- metadata.gz: 3b9c08a1ce890a68f26b54bc3412e82231672338007425752b895bccdb68fe2958de70c07e0c40532d329d14228a4a35ebace6134413ebc0910d20e21ca02c19
7
- data.tar.gz: a6ac9a4afd1b20443c33f625a1b3f4a1e8f9faa789064dce6123c50252c06a52d4addf13e57ba4813485619b6516f4868a0e4a211823b96c18db8869ea126268