rspec-steps 0.1.2 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd88aff3ac30447e633effb2d644bed299036f5f
4
- data.tar.gz: e0a510a46640f6db0c5a6e51046c4c69f9200f51
3
+ metadata.gz: 2451717974825a8eab74d5b9a002726efd4127b7
4
+ data.tar.gz: 490cb5c8fd0f0b88e58ed008dedb3c5a9fc6eca2
5
5
  SHA512:
6
- metadata.gz: 38a571f6c14a47374d4106b90dca48d239654f529e9fb604d84192fcb196975793058e50bf5f8a1d45ec030cfa29cab5923828549bd81ec15141681cc2129e4e
7
- data.tar.gz: 96f0c95060630dae694322a0b1b55666bfd2853abcbb77ab6b1364292523b1ed64edb80a2d5cd3ea423bb6ae88f9d2407db5e8917ebd432b78aacdeccd534141
6
+ metadata.gz: 369538e14411083cf60e446f4b06b5545229dfde90d24da27bd0a5d276db3af746a8ad64da92767c7f778bd8a384a421f257a7e8cbe77e4389373236c49db374
7
+ data.tar.gz: 9c7a7f84771a2f68cdc9ccff0c5a813c4d5b65e70902d756fd304560f26dc5e861855be9e94a7bfa455d7031aa0f8e1a63e01fa0a86a5c6a59237b667eb5492d
@@ -44,9 +44,11 @@ module RSpecStepwise
44
44
 
45
45
  module StepExample
46
46
  def run_before_each
47
+ @example_group_class.run_before_step(self)
47
48
  end
48
49
 
49
50
  def run_after_each
51
+ @example_group_class.run_after_step(self)
50
52
  end
51
53
 
52
54
  def with_around_hooks
@@ -73,6 +75,12 @@ module RSpecStepwise
73
75
  end
74
76
 
75
77
  def before(*args, &block)
78
+ if args.first == :step
79
+ args.shift
80
+ options = build_metadata_hash_from(args)
81
+ return ((hooks[:before][:step] ||= []) <<
82
+ block.extend(RSpec::Core::Hooks::BeforeHookExtension).with(options))
83
+ end
76
84
  if args.first == :each
77
85
  puts "before blocks declared for steps are always treated as :all scope"
78
86
  end
@@ -80,6 +88,12 @@ module RSpecStepwise
80
88
  end
81
89
 
82
90
  def after(*args, &block)
91
+ if args.first == :step
92
+ args.shift
93
+ options = build_metadata_hash_from(args)
94
+ hooks[:after][:step] ||= []
95
+ return (hooks[:after][:step].unshift block.extend(RSpec::Core::Hooks::AfterHookExtension).with(options))
96
+ end
83
97
  if args.first == :each
84
98
  puts "after blocks declared for steps are always treated as :all scope"
85
99
  end
@@ -93,9 +107,29 @@ module RSpecStepwise
93
107
  super
94
108
  end
95
109
 
110
+ def example_synonym(named, desc=nil, *args, &block)
111
+ unless desc.nil?
112
+ desc = [named, desc].join(" ")
113
+ end
114
+ it(desc, *args, &block)
115
+ end
116
+
117
+ def when(*args, &block); example_synonym("when", *args, &block); end
118
+ def then(*args, &block); example_synonym("then", *args, &block); end
119
+ def next(*args, &block); example_synonym("next", *args, &block); end
120
+ def step(*args, &block); example_synonym("step", *args, &block); end
121
+
122
+ def run_before_step(example)
123
+ RSpec::Core::Hooks::HookCollection.new(ancestors.reverse.map {|a| a.hooks[:before][:step]}.flatten.compact).for(example).run
124
+ end
125
+
126
+ def run_after_step(example)
127
+ RSpec::Core::Hooks::HookCollection.new(ancestors.map {|a| a.hooks[:after][:step]}.flatten.compact).for(example).run
128
+ end
129
+
96
130
  def perform_steps(name, *args, &customization_block)
97
131
  shared_block = world.shared_example_groups[name]
98
- raise "Could not find shared example group named \#{name.inspect}" unless shared_block
132
+ raise "Could not find shared example group named #{name.inspect}" unless shared_block
99
133
 
100
134
  module_eval_with_args(*args, &shared_block)
101
135
  module_eval(&customization_block) if customization_block
@@ -29,6 +29,55 @@ describe RSpec::Core::ExampleGroup, "defined as stepwise" do
29
29
  end
30
30
  end
31
31
 
32
+ it "should run each_step hooks" do
33
+ group = nil
34
+ afters = []
35
+ befores = []
36
+
37
+ sandboxed do
38
+ group = steps "Test Each Step" do
39
+ before :each do
40
+ befores << :each
41
+ end
42
+ after :each do
43
+ afters << :each
44
+ end
45
+
46
+ before :all do
47
+ befores << :all
48
+ end
49
+ after :all do
50
+ afters << :all
51
+ end
52
+
53
+ before :step do
54
+ befores << :step
55
+ end
56
+ after :step do
57
+ afters << :step
58
+ end
59
+
60
+ it "should 1" do
61
+ 1.should == 1
62
+ end
63
+ it "should 2" do
64
+ 2.should == 2
65
+ end
66
+ it "should 3" do
67
+ 3.should == 3
68
+ end
69
+ end
70
+ group.run
71
+ end
72
+
73
+ befores.find_all{|item| item == :all}.length.should == 1
74
+ befores.find_all{|item| item == :each}.length.should == 1
75
+ befores.find_all{|item| item == :step}.length.should == 3
76
+ afters.find_all{|item| item == :all}.length.should == 1
77
+ afters.find_all{|item| item == :each}.length.should == 1
78
+ afters.find_all{|item| item == :step}.length.should == 3
79
+ end
80
+
32
81
  it "should mark later examples as failed if a before hook fails" do
33
82
  group = nil
34
83
  exception = Exception.new "Testing Error"
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.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Judson Lester
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-31 00:00:00.000000000 Z
12
+ date: 2014-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: corundum
@@ -315,7 +315,7 @@ rdoc_options:
315
315
  - --main
316
316
  - doc/README
317
317
  - --title
318
- - rspec-steps-0.1.2 RDoc
318
+ - rspec-steps-0.2.0 RDoc
319
319
  require_paths:
320
320
  - lib/
321
321
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -330,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
330
330
  version: '0'
331
331
  requirements: []
332
332
  rubyforge_project: rspec-steps
333
- rubygems_version: 2.0.3
333
+ rubygems_version: 2.0.14
334
334
  signing_key:
335
335
  specification_version: 3
336
336
  summary: I want steps in RSpec