Skip to content
This repository was archived by the owner on Oct 16, 2019. It is now read-only.

Commit c9ccc3d

Browse files
committed
Fix hooks execution order (refs #49)
1 parent 6784dd4 commit c9ccc3d

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

Gemfile.lock

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
allure-rspec (0.6.9)
4+
allure-rspec (0.7.1)
55
allure-ruby-adaptor-api (= 0.6.6)
66
rspec (~> 3.2)
77

@@ -15,7 +15,7 @@ GEM
1515
diff-lcs (1.2.5)
1616
macaddr (1.7.1)
1717
systemu (~> 2.6.2)
18-
mimemagic (0.2.1)
18+
mimemagic (0.3.0)
1919
mini_portile (0.6.2)
2020
nokogiri (1.6.6.2)
2121
mini_portile (~> 0.6.0)
@@ -24,16 +24,16 @@ GEM
2424
rspec-core (~> 3.2.0)
2525
rspec-expectations (~> 3.2.0)
2626
rspec-mocks (~> 3.2.0)
27-
rspec-core (3.2.0)
27+
rspec-core (3.2.3)
2828
rspec-support (~> 3.2.0)
29-
rspec-expectations (3.2.0)
29+
rspec-expectations (3.2.1)
3030
diff-lcs (>= 1.2.0, < 2.0)
3131
rspec-support (~> 3.2.0)
32-
rspec-mocks (3.2.0)
32+
rspec-mocks (3.2.1)
3333
diff-lcs (>= 1.2.0, < 2.0)
3434
rspec-support (~> 3.2.0)
35-
rspec-support (3.2.1)
36-
systemu (2.6.4)
35+
rspec-support (3.2.2)
36+
systemu (2.6.5)
3737
uuid (2.3.7)
3838
macaddr (~> 1.0)
3939

lib/allure-rspec/hooks.rb

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@ module OverrideHooksMethods
1111
alias_method :old_hooks, :hooks
1212

1313
def hooks
14-
@__hooks ||= OverridenHookCollections.new(self, RSpec::Core::FilterableItemRepository::UpdateOptimized)
14+
@__hooks ||= OverridenHookCollections.new(old_hooks)
1515
end
1616

1717
private
1818

1919
class OverridenHookCollections < RSpec::Core::Hooks::HookCollections
20-
def initialize(*args)
21-
super
20+
def initialize(original)
21+
super(original.instance_eval("@owner"), original.instance_eval("@filterable_item_repo_class"))
22+
[:@before_example_hooks, :@after_example_hooks, :@before_context_hooks, :@after_context_hooks, :@around_example_hooks].each { |var|
23+
instance_variable_set(var, original.instance_eval("#{var}"))
24+
}
2225
@before_step_hooks = nil
2326
@after_step_hooks = nil
2427
end
2528

26-
2729
def run(position, scope, example_or_group)
2830
if scope == :step
2931
run_owned_hooks_for(position, scope, example_or_group)

lib/allure-rspec/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module AllureRSpec # :nodoc:
22
module Version # :nodoc:
3-
STRING = '0.7.0'
3+
STRING = '0.7.1'
44
end
55
end

spec/hooks_spec.rb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require 'spec_helper'
2+
3+
describe 'When I test allure rspec' do
4+
before(:all) do
5+
puts 'Before all in foo spec'
6+
end
7+
8+
it 'should do something' do
9+
puts 'In the test'
10+
expect(true).not_to be_nil
11+
end
12+
end

spec/spec_helper.rb

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
RSpec.configure do |c|
66
c.include AllureRSpec::Adaptor
7+
8+
c.before(:suite) do
9+
puts 'Before Suite Spec helper'
10+
end
11+
12+
c.before(:all) do
13+
puts 'Before all Spec helper'
14+
end
715
end
816

917
AllureRSpec.configure do |c|

0 commit comments

Comments
 (0)