rspec-steps 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2451717974825a8eab74d5b9a002726efd4127b7
4
- data.tar.gz: 490cb5c8fd0f0b88e58ed008dedb3c5a9fc6eca2
5
- SHA512:
6
- metadata.gz: 369538e14411083cf60e446f4b06b5545229dfde90d24da27bd0a5d276db3af746a8ad64da92767c7f778bd8a384a421f257a7e8cbe77e4389373236c49db374
7
- data.tar.gz: 9c7a7f84771a2f68cdc9ccff0c5a813c4d5b65e70902d756fd304560f26dc5e861855be9e94a7bfa455d7031aa0f8e1a63e01fa0a86a5c6a59237b667eb5492d
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MmRjMzBjYzJhZjg1M2Q3OTJiMWNjZTk1ZTk1ZGZmZGFmZTAyOGRiNQ==
5
+ data.tar.gz: !binary |-
6
+ ZTU5OTM2Y2M0MDI5YmMyOWZiMDM0NzY3NTEyNTNhNWI5NDlhOGMyMA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ N2M0ODJiYzE4ZDdjNmE4MjcwMTNmNDU5MGE4MTZjODE0MWRhYTIwYmI5MjI4
10
+ ZjU3ZGU3NjZhZmQ0NTdiZjQyMWIyYmViMjg5ZDA1NWE4NTk0NWJjZmI2NDJh
11
+ YjQ2MDRiMjNkODlmMDk1OTMzZjQyZWU2MzQzMDY3YjczMjViOGQ=
12
+ data.tar.gz: !binary |-
13
+ OWU3MmZmNzAxZjQyOWQ5OWJhOTY1MzI1NTNjMzJhZmI5NjAyY2Q0NTk3NjJk
14
+ NmM0YzMyNTUxMWQwMmU3ZDNiMDg0ZGFhZjQxMzE4NDdmN2U1NTdhNzg2Y2U5
15
+ OWM0MzZlMzFkY2U5YTMzZDc1MjllMmI3M2U1YjVhNDMzMDFlM2Q=
@@ -2,7 +2,7 @@ require 'rspec/core'
2
2
  require 'rspec-steps/stepwise'
3
3
 
4
4
  module RSpec::Steps
5
- module ClassMethods
5
+ module DSL
6
6
  def steps(*args, &block)
7
7
  options =
8
8
  if args.last.is_a?(Hash)
@@ -19,7 +19,9 @@ module RSpec::Steps
19
19
  end
20
20
  end
21
21
 
22
- RSpec::Core::ExampleGroup.extend RSpec::Steps::ClassMethods
23
- include RSpec::Steps::ClassMethods
22
+ RSpec::Core::ExampleGroup.extend RSpec::Steps::DSL
23
+
24
+ extend RSpec::Steps::DSL
25
+ Module::send(:include, RSpec::Steps::DSL)
24
26
 
25
27
  RSpec::configuration.include(RSpecStepwise, :stepwise => true)
@@ -6,4 +6,3 @@ module RSpec::Core::SharedExampleGroup
6
6
  alias :shared_steps :share_examples_for
7
7
  alias :steps_shared_as :share_as
8
8
  end
9
- extend RSpec::Steps::ClassMethods
@@ -45,6 +45,8 @@ module RSpecStepwise
45
45
  module StepExample
46
46
  def run_before_each
47
47
  @example_group_class.run_before_step(self)
48
+ rescue Object => ex
49
+ puts "\n#{__FILE__}:#{__LINE__} => #{[ex, ex.backtrace].pretty_inspect}"
48
50
  end
49
51
 
50
52
  def run_after_each
@@ -74,12 +76,27 @@ module RSpecStepwise
74
76
  end
75
77
  end
76
78
 
79
+ def build_before_hook(options, &block)
80
+ if defined? RSpec::Core::Hooks::BeforeHookExtension
81
+ block.extend(RSpec::Core::Hooks::BeforeHookExtension).with(options)
82
+ else
83
+ RSpec::Core::Hooks::BeforeHook.new(block, options)
84
+ end
85
+ end
86
+
87
+ def build_after_hook(options, &block)
88
+ if defined? RSpec::Core::Hooks::AfterHookExtension
89
+ block.extend(RSpec::Core::Hooks::AfterHookExtension).with(options)
90
+ else
91
+ RSpec::Core::Hooks::AfterHook.new(block, options)
92
+ end
93
+ end
94
+
77
95
  def before(*args, &block)
78
96
  if args.first == :step
79
97
  args.shift
80
98
  options = build_metadata_hash_from(args)
81
- return ((hooks[:before][:step] ||= []) <<
82
- block.extend(RSpec::Core::Hooks::BeforeHookExtension).with(options))
99
+ return ((hooks[:before][:step] ||= []) << build_before_hook(options, &block))
83
100
  end
84
101
  if args.first == :each
85
102
  puts "before blocks declared for steps are always treated as :all scope"
@@ -92,7 +109,7 @@ module RSpecStepwise
92
109
  args.shift
93
110
  options = build_metadata_hash_from(args)
94
111
  hooks[:after][:step] ||= []
95
- return (hooks[:after][:step].unshift block.extend(RSpec::Core::Hooks::AfterHookExtension).with(options))
112
+ return (hooks[:after][:step].unshift build_after_hook(options, &block))
96
113
  end
97
114
  if args.first == :each
98
115
  puts "after blocks declared for steps are always treated as :all scope"
@@ -119,12 +136,28 @@ module RSpecStepwise
119
136
  def next(*args, &block); example_synonym("next", *args, &block); end
120
137
  def step(*args, &block); example_synonym("step", *args, &block); end
121
138
 
139
+ def run_step(example, hook, &sorting)
140
+ groups = if respond_to?(:parent_groups)
141
+ parent_groups
142
+ else
143
+ ancestors
144
+ end
145
+
146
+ if block_given?
147
+ groups = yield groups
148
+ end
149
+
150
+ RSpec::Core::Hooks::HookCollection.new(groups.map {|a| a.hooks[hook][:step]}.flatten.compact).for(example).run
151
+ end
152
+
122
153
  def run_before_step(example)
123
- RSpec::Core::Hooks::HookCollection.new(ancestors.reverse.map {|a| a.hooks[:before][:step]}.flatten.compact).for(example).run
154
+ run_step(example, :before)
124
155
  end
125
156
 
126
157
  def run_after_step(example)
127
- RSpec::Core::Hooks::HookCollection.new(ancestors.map {|a| a.hooks[:after][:step]}.flatten.compact).for(example).run
158
+ run_step(example, :after) do |groups|
159
+ groups.reverse
160
+ end
128
161
  end
129
162
 
130
163
  def perform_steps(name, *args, &customization_block)
@@ -19,6 +19,8 @@ def sandboxed(&block)
19
19
 
20
20
  object = Object.new
21
21
  object.extend(RSpec::Core::SharedExampleGroup)
22
+ object.extend(RSpec::Steps::DSL)
23
+ object.extend(RSpec::Core::DSL)
22
24
 
23
25
  (class << RSpec::Core::ExampleGroup; self; end).class_eval do
24
26
  alias_method :orig_run, :run
@@ -42,47 +44,3 @@ ensure
42
44
  RSpec.instance_variable_set(:@configuration, @orig_config)
43
45
  RSpec.instance_variable_set(:@world, @orig_world)
44
46
  end
45
-
46
- #Original from rspec-core
47
- =begin
48
- class << RSpec
49
- alias_method :original_warn_about_deprecated_configure, :warn_about_deprecated_configure
50
-
51
- def warn_about_deprecated_configure
52
- # no-op: in our specs we don't want to see the warning.
53
- end
54
-
55
- alias_method :null_warn_about_deprecated_configure, :warn_about_deprecated_configure
56
-
57
- def allowing_configure_warning
58
- (class << self; self; end).class_eval do
59
- alias_method :warn_about_deprecated_configure, :original_warn_about_deprecated_configure
60
- begin
61
- yield
62
- ensure
63
- alias_method :warn_about_deprecated_configure, :null_warn_about_deprecated_configure
64
- end
65
- end
66
- end
67
- end
68
-
69
- RSpec.configure do |c|
70
- c.color_enabled = !in_editor?
71
- c.filter_run :focus => true
72
- c.run_all_when_everything_filtered = true
73
- c.filter_run_excluding :ruby => lambda {|version|
74
- case version.to_s
75
- when "!jruby"
76
- RUBY_ENGINE == "jruby"
77
- when /^> (.*)/
78
- !(RUBY_VERSION.to_s > $1)
79
- else
80
- !(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
81
- end
82
- }
83
- c.around do |example|
84
- sandboxed { example.run }
85
- end
86
- end
87
- =begin
88
- =end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-steps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Judson Lester
@@ -9,47 +9,46 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-28 00:00:00.000000000 Z
12
+ date: 2014-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: corundum
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ! '>='
19
19
  - !ruby/object:Gem::Version
20
20
  version: 0.0.25
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ! '>='
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.0.25
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rspec
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ! '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: '2.6'
35
35
  - - <
36
36
  - !ruby/object:Gem::Version
37
- version: 2.14.0
37
+ version: '2.99'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - '>='
42
+ - - ! '>='
43
43
  - !ruby/object:Gem::Version
44
44
  version: '2.6'
45
45
  - - <
46
46
  - !ruby/object:Gem::Version
47
- version: 2.14.0
48
- description: |2
49
- I don't like Cucumber. I don't need plain text stories. My clients either
50
- read code or don't read any test documents, so Cucumber is mostly useless to me.
51
- But often, especially in full integration tests, it would be nice to have
52
- steps in a test.
47
+ version: '2.99'
48
+ description: ! " I don't like Cucumber. I don't need plain text stories. My clients
49
+ either\n read code or don't read any test documents, so Cucumber is mostly useless
50
+ to me.\n But often, especially in full integration tests, it would be nice to have\n
51
+ \ steps in a test.\n"
53
52
  email:
54
53
  - judson@lrdesign.com
55
54
  - evan@lrdesign.com
@@ -315,17 +314,17 @@ rdoc_options:
315
314
  - --main
316
315
  - doc/README
317
316
  - --title
318
- - rspec-steps-0.2.0 RDoc
317
+ - rspec-steps-0.3.0 RDoc
319
318
  require_paths:
320
319
  - lib/
321
320
  required_ruby_version: !ruby/object:Gem::Requirement
322
321
  requirements:
323
- - - '>='
322
+ - - ! '>='
324
323
  - !ruby/object:Gem::Version
325
324
  version: '0'
326
325
  required_rubygems_version: !ruby/object:Gem::Requirement
327
326
  requirements:
328
- - - '>='
327
+ - - ! '>='
329
328
  - !ruby/object:Gem::Version
330
329
  version: '0'
331
330
  requirements: []