Exspec 1.0.2 → 1.0.3
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.
- data/bin/exspec +19 -6
- data/lib/exspec.rb +47 -13
- data/lib/exspec/context_manager.rb +5 -1
- data/lib/exspec/executor.rb +11 -5
- data/lib/exspec/extensions/capybara.rb +76 -0
- data/lib/exspec/extensions/extension.rb +65 -53
- data/lib/exspec/helpers/context_delegator.rb +38 -0
- data/lib/exspec/helpers/helpers.rb +12 -0
- data/lib/exspec/regression_test_reporter.rb +2 -4
- data/lib/exspec/reporter.rb +4 -1
- data/lib/exspec/spec.rb +1 -1
- data/lib/exspec/spec_manager.rb +3 -3
- data/lib/exspec/spec_runner.rb +10 -2
- metadata +37 -2
data/bin/exspec
CHANGED
@@ -1,14 +1,29 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
ARG_PREFIX = "--"
|
4
|
+
DEBUG_ARG = "debug"
|
4
5
|
|
5
|
-
|
6
|
+
spec_args = ARGV.take_while { |arg| !arg.start_with?(ARG_PREFIX) }
|
7
|
+
ARGV.shift spec_args.length
|
8
|
+
debug = ARGV.delete ARG_PREFIX + DEBUG_ARG
|
9
|
+
|
10
|
+
if debug
|
11
|
+
require_relative "../lib/exspec"
|
12
|
+
else
|
13
|
+
require "exspec"
|
14
|
+
end
|
15
|
+
|
16
|
+
if spec_args.empty?
|
17
|
+
Exspec::Extension.test_hook(:before_stack, nil)
|
18
|
+
Exspec::Extension.test_hook(:before, nil)
|
6
19
|
started = Exspec::Extension.start_exspec
|
7
20
|
Exspec::IrbExspec.start_irb unless started
|
21
|
+
Exspec::Extension.test_hook(:after, nil)
|
22
|
+
Exspec::Extension.test_hook(:after_stack, nil)
|
8
23
|
else
|
9
24
|
exspec = Exspec::Exspec.new
|
10
25
|
|
11
|
-
spec_arg =
|
26
|
+
spec_arg = spec_args.join " "
|
12
27
|
spec = exspec.spec spec_arg
|
13
28
|
|
14
29
|
reporter = Exspec::REGRESSION_TEST_REPORTER.new
|
@@ -18,9 +33,7 @@ else
|
|
18
33
|
specs = exspec.specs spec_arg, true
|
19
34
|
specs.each do |spec|
|
20
35
|
spec.stack.each do |parent|
|
21
|
-
if parent != spec
|
22
|
-
specs.delete(parent)
|
23
|
-
end
|
36
|
+
specs.delete(parent) if parent != spec
|
24
37
|
end
|
25
38
|
end
|
26
39
|
exspec.report_to(reporter) { exspec.run_specs specs }
|
data/lib/exspec.rb
CHANGED
@@ -7,10 +7,11 @@ require_relative "exspec/logger"
|
|
7
7
|
require_relative "exspec/spec_runner"
|
8
8
|
require_relative "exspec/reporter"
|
9
9
|
require_relative "exspec/regression_test_reporter"
|
10
|
-
require_relative "exspec/helpers"
|
10
|
+
require_relative "exspec/helpers/helpers"
|
11
11
|
require_relative "exspec/extensions/extension"
|
12
12
|
require_relative "exspec/extensions/mocking"
|
13
13
|
require_relative "exspec/extensions/rails"
|
14
|
+
require_relative "exspec/extensions/capybara"
|
14
15
|
parent_dirs do |parent_dir|
|
15
16
|
configured = false
|
16
17
|
["exspec.rb", "config/exspec.rb", "exspec/config.rb", "exspec/exspec.rb"].each do |file|
|
@@ -31,7 +32,7 @@ module Exspec
|
|
31
32
|
:regression_test_reporter => RegressionTestReporter
|
32
33
|
}
|
33
34
|
Extension.config config
|
34
|
-
config
|
35
|
+
@@config = config
|
35
36
|
end
|
36
37
|
|
37
38
|
TEST_DIR = File.expand_path(config[:test_dir])
|
@@ -52,6 +53,8 @@ module Exspec
|
|
52
53
|
@logger = components[:logger] || Logger.new
|
53
54
|
@runner = components[:runner] || SpecRunner.new(self)
|
54
55
|
@reporter = components[:reporter] || Reporter.new
|
56
|
+
@execute_stack = []
|
57
|
+
Extension.initialized_exspec self
|
55
58
|
end
|
56
59
|
|
57
60
|
delegate :without_logging, :last_instruction, :erase_last_instruction, :log, :to => :@logger
|
@@ -68,17 +71,19 @@ module Exspec
|
|
68
71
|
end
|
69
72
|
|
70
73
|
def execute(instruction)
|
74
|
+
@execute_stack << false
|
71
75
|
executor.eval instruction do |callbacks|
|
72
76
|
callbacks.after do |command, params, value|
|
73
77
|
context.last_exspec_value = value
|
74
78
|
if command.nil?
|
75
79
|
commit instruction, value
|
76
80
|
end
|
77
|
-
if last_exspec_value != last_value || command == "_" || command == ""
|
81
|
+
if @execute_stack.length == 1 && (last_exspec_value != last_value || command == "_" || command == "")
|
78
82
|
puts "#{COMMAND_PREFIX}_: #{last_exspec_value.inspect}"
|
79
83
|
end
|
80
84
|
end
|
81
85
|
end
|
86
|
+
@execute_stack.pop
|
82
87
|
end
|
83
88
|
|
84
89
|
def report_to(reporter=reporter)
|
@@ -96,15 +101,24 @@ module Exspec
|
|
96
101
|
|
97
102
|
def save(description, comment=nil)
|
98
103
|
comment(comment) unless comment.nil?
|
99
|
-
spec_manager.save logger, description
|
104
|
+
spec = spec_manager.save logger, description
|
105
|
+
Extension.test_hook(:after, spec)
|
106
|
+
Extension.test_hook(:before, nil)
|
107
|
+
spec
|
100
108
|
end
|
101
109
|
|
102
110
|
def load(description)
|
111
|
+
Extension.test_hook(:after, nil)
|
112
|
+
Extension.test_hook(:after_stack, nil)
|
103
113
|
reset
|
104
114
|
spec = spec(description)
|
105
|
-
|
106
|
-
|
107
|
-
|
115
|
+
Extension.test_hook(:before_stack, nil)
|
116
|
+
unless spec.nil?
|
117
|
+
without_logging { runner.run_stack spec }
|
118
|
+
spec_manager.current_spec = spec
|
119
|
+
end
|
120
|
+
Extension.test_hook(:before, nil)
|
121
|
+
spec
|
108
122
|
end
|
109
123
|
|
110
124
|
def include(description)
|
@@ -118,6 +132,7 @@ module Exspec
|
|
118
132
|
def retry
|
119
133
|
instructions = logger.instructions
|
120
134
|
load current_spec
|
135
|
+
Extension.test_hook(:before, nil)
|
121
136
|
instructions.each do |instruction|
|
122
137
|
execute instruction rescue nil
|
123
138
|
end
|
@@ -143,11 +158,16 @@ module Exspec
|
|
143
158
|
end
|
144
159
|
|
145
160
|
def assert(statement=nil, comment=nil)
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
161
|
+
begin
|
162
|
+
val = without_logging { raw_eval statement }
|
163
|
+
if val
|
164
|
+
spec_succeeded "Successful: #{comment || statement}"
|
165
|
+
else
|
166
|
+
spec_failed "Failed: #{comment || statement}"
|
167
|
+
end
|
168
|
+
rescue Exception => e
|
169
|
+
val = e
|
170
|
+
spec_failed "Failed due to an exception: #{comment || statement} (#{e})"
|
151
171
|
end
|
152
172
|
commit "#{COMMAND_PREFIX}assert #{statement.strip}" + (comment ? " #{COMMENT_SIGN}#{comment}" : "")
|
153
173
|
val
|
@@ -156,7 +176,7 @@ module Exspec
|
|
156
176
|
def expect(statement=nil, comment=nil)
|
157
177
|
return expect_inspect nil, comment if statement.nil?
|
158
178
|
actual = last_value
|
159
|
-
expect = without_logging { raw_eval statement }
|
179
|
+
expect = value_or_exception { without_logging { raw_eval statement } }
|
160
180
|
if expect == actual
|
161
181
|
spec_succeeded "Successful: #{comment || "value is #{prepare_output(expect)}"}"
|
162
182
|
else
|
@@ -195,7 +215,12 @@ module Exspec
|
|
195
215
|
last_value.is_a?(String) ? last_value : last_value.inspect
|
196
216
|
end
|
197
217
|
|
218
|
+
def commited?
|
219
|
+
@execute_stack.last
|
220
|
+
end
|
221
|
+
|
198
222
|
def commit(instruction, value=last_value)
|
223
|
+
@execute_stack[@execute_stack.length - 1] = true unless @execute_stack.empty?
|
199
224
|
logger.log instruction, value
|
200
225
|
return_spec value
|
201
226
|
end
|
@@ -209,6 +234,15 @@ module Exspec
|
|
209
234
|
return "\"#{value}\"" if value.is_a? String
|
210
235
|
value
|
211
236
|
end
|
237
|
+
|
238
|
+
def value_or_exception
|
239
|
+
begin
|
240
|
+
val = yield
|
241
|
+
rescue Exception => e
|
242
|
+
val = e
|
243
|
+
end
|
244
|
+
val
|
245
|
+
end
|
212
246
|
end
|
213
247
|
end
|
214
248
|
|
@@ -62,7 +62,11 @@ module Exspec
|
|
62
62
|
def setup_global_context
|
63
63
|
global_instance = global_eval "self"
|
64
64
|
global_instance.instance_variable_set :@exspec, @exspec
|
65
|
-
|
65
|
+
class << global_instance
|
66
|
+
def exspec
|
67
|
+
@exspec
|
68
|
+
end
|
69
|
+
end
|
66
70
|
global_eval "_ = nil"
|
67
71
|
Extension.setup_global_context self, global_instance
|
68
72
|
end
|
data/lib/exspec/executor.rb
CHANGED
@@ -6,7 +6,7 @@ module Exspec
|
|
6
6
|
@exspec = exspec
|
7
7
|
end
|
8
8
|
|
9
|
-
delegate :puts, :print, :return_spec, :context, :commit, :to => :@exspec
|
9
|
+
delegate :puts, :print, :return_spec, :context, :commit, :commited?, :without_logging, :value_or_exception, :to => :@exspec
|
10
10
|
attr_reader :exspec
|
11
11
|
|
12
12
|
def eval(instruction, &callback_block)
|
@@ -22,7 +22,7 @@ module Exspec
|
|
22
22
|
param_string = parts[1..-1].join " "
|
23
23
|
eval = false
|
24
24
|
val = Extension.execute_command self, command, param_string, callbacks
|
25
|
-
if val.nil?
|
25
|
+
if val.nil? && !commited?
|
26
26
|
val = case command
|
27
27
|
when ""
|
28
28
|
execute(command, parameters(param_string), callbacks) do
|
@@ -127,6 +127,10 @@ module Exspec
|
|
127
127
|
when "reset", "clear"
|
128
128
|
execute(command, callbacks) do
|
129
129
|
exspec.reset
|
130
|
+
Extension.test_hook(:after, nil)
|
131
|
+
Extension.test_hook(:after_stack, nil)
|
132
|
+
Extension.test_hook(:before_stack, nil)
|
133
|
+
Extension.test_hook(:before, nil)
|
130
134
|
end
|
131
135
|
when "log", "instructions", "history"
|
132
136
|
execute(command, callbacks) do
|
@@ -149,9 +153,11 @@ module Exspec
|
|
149
153
|
end
|
150
154
|
end
|
151
155
|
when "no_log", "without_logging", "silent", "no_history"
|
152
|
-
|
153
|
-
|
154
|
-
|
156
|
+
execute(command, parameters(param_string), callbacks) do
|
157
|
+
val = without_logging { eval param_string }
|
158
|
+
return_spec exspec.logger.last_value
|
159
|
+
val
|
160
|
+
end
|
155
161
|
when "log_off", "disable_log", "history_off", "disable_history"
|
156
162
|
execute(command, callbacks) do
|
157
163
|
exspec.logger.enabled = false
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'capybara'
|
2
|
+
require 'capybara/dsl'
|
3
|
+
|
4
|
+
module Exspec::Capybara
|
5
|
+
extend Exspec::Extension
|
6
|
+
|
7
|
+
@@capybara = nil
|
8
|
+
|
9
|
+
class CapybaraDSL < ContextDelegator
|
10
|
+
include Capybara::DSL
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.config
|
14
|
+
config = {
|
15
|
+
:driver => :selenium
|
16
|
+
}
|
17
|
+
Exspec::Extension.apply :capybara_config, nil, false, config
|
18
|
+
config
|
19
|
+
end
|
20
|
+
|
21
|
+
initialized_exspec do |exspec|
|
22
|
+
@@capybara = CapybaraDSL.new exspec.context
|
23
|
+
Exspec::Extension.apply :capybara_setup, Capybara, false, config
|
24
|
+
end
|
25
|
+
|
26
|
+
capybara_setup do |config|
|
27
|
+
self.current_driver = config[:driver]
|
28
|
+
end
|
29
|
+
|
30
|
+
setup_global_context do |global_instance|
|
31
|
+
class << global_instance
|
32
|
+
def capybara
|
33
|
+
@@capybara
|
34
|
+
end
|
35
|
+
|
36
|
+
def page
|
37
|
+
@@capybara.page
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# for examples see the comments after the commands below
|
43
|
+
# returned values can be checked with Exspec's assertion commands
|
44
|
+
execute_command do |command, param_string, options|
|
45
|
+
case command
|
46
|
+
when "capybara", "!" # E.g. !! visit "http://www.github.com"
|
47
|
+
execute(command, parameters(param_string), options) do
|
48
|
+
val = value_or_exception do
|
49
|
+
@@capybara.instance_eval param_string
|
50
|
+
end
|
51
|
+
commit "!capybara #{param_string}", val
|
52
|
+
end
|
53
|
+
when "!$", "!find" # E.g. !!$ div.myCssClass
|
54
|
+
execute(command, parameters(param_string), options) do
|
55
|
+
val = value_or_exception do
|
56
|
+
@@capybara.instance_eval { page.find(param_string) }
|
57
|
+
end
|
58
|
+
commit "!capybara page.find(\"#{param_string.inspect[1..-2]}\")", val
|
59
|
+
end
|
60
|
+
when "!<", "!eval" # E.g. !!< $("input").text() (to read values from JavaScript)
|
61
|
+
execute(command, parameters(param_string), options) do
|
62
|
+
val = value_or_exception do
|
63
|
+
@@capybara.instance_eval { page.evaluate_script param_string }
|
64
|
+
end
|
65
|
+
commit "!capybara page.evaluate_script(\"#{param_string.inspect[1..-2]}\")", val
|
66
|
+
end
|
67
|
+
when "!>", "!exec" # E.g. !!> $(".button").click() (to execute JavaScript)
|
68
|
+
execute(command, parameters(param_string), options) do
|
69
|
+
val = value_or_exception do
|
70
|
+
@@capybara.instance_eval { page.execute_script param_string }
|
71
|
+
end
|
72
|
+
commit "!capybara page.execute_script(\"#{param_string.inspect[1..-2]}\")"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -1,70 +1,82 @@
|
|
1
|
-
module Exspec
|
2
|
-
|
3
|
-
|
1
|
+
module Exspec
|
2
|
+
module Extension
|
3
|
+
@@module = self
|
4
|
+
@@extensions = {}
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
def self.loaded
|
7
|
+
apply :loaded
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
def self.config(config)
|
11
|
+
apply :config, nil, false, config
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
def self.start_exspec
|
15
|
+
apply :start_exspec, nil, true
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def self.set_execute_callbacks(options)
|
19
|
+
apply :set_execute_callbacks, nil, false, options
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
def self.initialize_exspec(exspec, components)
|
23
|
+
apply :initialize_exspec, exspec, false, components
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
def self.initialized_exspec(exspec)
|
27
|
+
apply :initialized_exspec, nil, false, exspec
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
def self.execute_command(executor, command, param_string, options)
|
31
|
+
apply :execute_command, executor, true, command, param_string, options
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
def self.setup_context(context_manager)
|
35
|
+
apply :setup_context, context_manager
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
def self.setup_global_context(context_manager, global_instance)
|
39
|
+
apply :setup_global_context, context_manager, false, global_instance
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
val = if extended_instance
|
44
|
-
extended_instance.instance_exec *args, &extension
|
45
|
-
else
|
46
|
-
extension.call *args
|
47
|
-
end
|
48
|
-
return val if return_first && !val.nil?
|
42
|
+
def self.setup_exspec_context(context_manager)
|
43
|
+
apply :setup_exspec_context, context_manager
|
49
44
|
end
|
50
|
-
return nil
|
51
|
-
end
|
52
45
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
extensions
|
57
|
-
end
|
46
|
+
def self.test_hook(hook, spec)
|
47
|
+
apply extension_point(:test_hook, hook), nil, false, spec
|
48
|
+
end
|
58
49
|
|
59
|
-
|
60
|
-
|
61
|
-
|
50
|
+
def self.apply(extension_point, extended_instance=nil, return_first=false, *args)
|
51
|
+
extensions(extension_point).each do |extension|
|
52
|
+
val = if extended_instance
|
53
|
+
extended_instance.instance_exec *args, &extension
|
54
|
+
else
|
55
|
+
extension.call *args
|
56
|
+
end
|
57
|
+
return val if return_first && !val.nil?
|
58
|
+
end
|
59
|
+
return nil
|
60
|
+
end
|
62
61
|
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
def self.extension_point(name, *args)
|
63
|
+
args.unshift(name).map(&:to_s).join(":").to_sym
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.extensions(extension_point)
|
67
|
+
@@extensions[extension_point.to_sym] ||= []
|
68
|
+
end
|
69
|
+
|
70
|
+
def method_missing(method, *args, &block)
|
71
|
+
def_extension @@module.extension_point(method, *args), block
|
72
|
+
end
|
73
|
+
|
74
|
+
def extensions(extension_point)
|
75
|
+
@@module.extensions extension_point
|
76
|
+
end
|
66
77
|
|
67
|
-
|
68
|
-
|
78
|
+
def def_extension(extension_point, block)
|
79
|
+
extensions(extension_point.to_sym) << block
|
80
|
+
end
|
69
81
|
end
|
70
82
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class ContextDelegator
|
2
|
+
def initialize(context_manager)
|
3
|
+
@_context = context_manager
|
4
|
+
@_args = []
|
5
|
+
@_blocks = []
|
6
|
+
end
|
7
|
+
|
8
|
+
def _args(index)
|
9
|
+
@_args[index].call
|
10
|
+
end
|
11
|
+
|
12
|
+
def _block(index)
|
13
|
+
@_blocks[index].call
|
14
|
+
end
|
15
|
+
|
16
|
+
def method_missing(method, *args, &block)
|
17
|
+
args_params = []
|
18
|
+
args.each do |argument|
|
19
|
+
args_index = @_args.length
|
20
|
+
@_args << argument
|
21
|
+
args_params << "capybara._args(#{args_index})"
|
22
|
+
end
|
23
|
+
block_param = ""
|
24
|
+
if block_given?
|
25
|
+
block_index = @_blocks.length
|
26
|
+
@_blocks << block
|
27
|
+
block_param = ", " unless args.empty?
|
28
|
+
block_param << "&capybara._block(#{block_index})"
|
29
|
+
end
|
30
|
+
params = "#{args_params.join ", "}#{block_param}"
|
31
|
+
call = method.to_s
|
32
|
+
call << "(#{params})" unless params.empty?
|
33
|
+
val = @_context.raw_eval call
|
34
|
+
@_args.pop args.length
|
35
|
+
@_blocks.pop if block_given?
|
36
|
+
val
|
37
|
+
end
|
38
|
+
end
|
@@ -64,7 +64,7 @@ module Exspec
|
|
64
64
|
print_indented "."
|
65
65
|
end
|
66
66
|
|
67
|
-
def skip_signal
|
67
|
+
def skip_signal(breaking)
|
68
68
|
raise SkipSignal
|
69
69
|
end
|
70
70
|
|
@@ -81,9 +81,7 @@ module Exspec
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def exception(exception)
|
84
|
-
if exception.is_a?
|
85
|
-
raise exception
|
86
|
-
end
|
84
|
+
raise exception if exception.is_a? SpecFailedError
|
87
85
|
end
|
88
86
|
|
89
87
|
def show_comment(text)
|
data/lib/exspec/reporter.rb
CHANGED
@@ -8,7 +8,10 @@ module Exspec
|
|
8
8
|
def executed_instruction(instruction, index, line); end
|
9
9
|
def exception(exception); end
|
10
10
|
def skip_signal(breaking); end
|
11
|
-
|
11
|
+
|
12
|
+
def show_comment(text)
|
13
|
+
puts text
|
14
|
+
end
|
12
15
|
|
13
16
|
def puts(text)
|
14
17
|
Kernel.puts text
|
data/lib/exspec/spec.rb
CHANGED
@@ -4,7 +4,7 @@ class Spec
|
|
4
4
|
def self.name(description)
|
5
5
|
name = File.basename(description, File.extname(description))
|
6
6
|
name = name.split(".").last.strip
|
7
|
-
name.gsub(/
|
7
|
+
name.underscore.gsub(/[\W_]+/, "_")
|
8
8
|
end
|
9
9
|
|
10
10
|
def initialize(spec_manager, name, file, parent=nil)
|
data/lib/exspec/spec_manager.rb
CHANGED
@@ -51,8 +51,8 @@ module Exspec
|
|
51
51
|
def specs(parent=current_spec, recursive=false)
|
52
52
|
parent = "" if parent.nil?
|
53
53
|
if parent.is_a?(String)
|
54
|
-
parent
|
55
|
-
relative_directory = current_spec.nil? ? TEST_DIR : current_spec.directory
|
54
|
+
parent.strip!
|
55
|
+
relative_directory = parent.start_with?(SPEC_SEPARATOR) || current_spec.nil? ? TEST_DIR : current_spec.directory
|
56
56
|
parent_directory = File.expand_path(parent, relative_directory)
|
57
57
|
return find_specs(parent_directory, recursive) if File.directory?(parent_directory)
|
58
58
|
end
|
@@ -84,7 +84,7 @@ module Exspec
|
|
84
84
|
if File.directory? file
|
85
85
|
specs.push(*find_specs(file, recursively)) if recursively
|
86
86
|
elsif file.end_with? SPEC_EXTENSION
|
87
|
-
specs << create_spec(file)
|
87
|
+
specs << create_spec(file, nil)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
specs
|
data/lib/exspec/spec_runner.rb
CHANGED
@@ -2,9 +2,10 @@ module Exspec
|
|
2
2
|
class SpecRunner
|
3
3
|
def initialize(exspec)
|
4
4
|
@exspec = exspec
|
5
|
+
@break_on_skip_signal = false
|
5
6
|
end
|
6
7
|
|
7
|
-
delegate :reporter, :to => :@exspec
|
8
|
+
delegate :reporter, :commit, :without_logging, :to => :@exspec
|
8
9
|
|
9
10
|
attr_accessor :break_on_skip_signal
|
10
11
|
|
@@ -16,12 +17,14 @@ module Exspec
|
|
16
17
|
spec.for_instructions do |instruction, index, line|
|
17
18
|
reporter.execute_instruction instruction, index, line
|
18
19
|
begin
|
19
|
-
val = @exspec.execute instruction
|
20
|
+
val = without_logging { @exspec.execute instruction }
|
21
|
+
commit instruction, val
|
20
22
|
rescue SkipSignal
|
21
23
|
reporter.skip_signal break_on_skip_signal
|
22
24
|
break if break_on_skip_signal
|
23
25
|
rescue Exception => e
|
24
26
|
reporter.exception e
|
27
|
+
commit instruction, e
|
25
28
|
ensure
|
26
29
|
reporter.executed_instruction instruction, index, line
|
27
30
|
end
|
@@ -36,9 +39,12 @@ module Exspec
|
|
36
39
|
reporter.start_stack spec
|
37
40
|
spec.stack.each do |spec|
|
38
41
|
begin
|
42
|
+
Extension.test_hook(:before, spec)
|
39
43
|
run spec
|
40
44
|
rescue
|
41
45
|
break
|
46
|
+
ensure
|
47
|
+
Extension.test_hook(:after, spec)
|
42
48
|
end
|
43
49
|
end
|
44
50
|
ensure
|
@@ -48,7 +54,9 @@ module Exspec
|
|
48
54
|
def run_specs(specs)
|
49
55
|
specs.each do |spec|
|
50
56
|
@exspec.reset
|
57
|
+
Extension.test_hook(:before_stack, spec)
|
51
58
|
run_stack(spec)
|
59
|
+
Extension.test_hook(:after_stack, spec)
|
52
60
|
end
|
53
61
|
end
|
54
62
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Exspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -27,6 +27,38 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: capybara
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: capybara-webkit
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
30
62
|
description: Don't write specs anymore, just save 'em while testing your code interactively.
|
31
63
|
Specs will become a byproduct.
|
32
64
|
email: helgeho@invelop.de
|
@@ -38,9 +70,12 @@ files:
|
|
38
70
|
- lib/exspec/context_manager.rb
|
39
71
|
- lib/exspec/execute_callbacks.rb
|
40
72
|
- lib/exspec/executor.rb
|
73
|
+
- lib/exspec/extensions/capybara.rb
|
41
74
|
- lib/exspec/extensions/extension.rb
|
42
75
|
- lib/exspec/extensions/mocking.rb
|
43
76
|
- lib/exspec/extensions/rails.rb
|
77
|
+
- lib/exspec/helpers/context_delegator.rb
|
78
|
+
- lib/exspec/helpers/helpers.rb
|
44
79
|
- lib/exspec/helpers.rb
|
45
80
|
- lib/exspec/irb/irb_context_manager.rb
|
46
81
|
- lib/exspec/irb/irb_exspec.rb
|