Exspec 1.0.1 → 1.0.2
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/lib/exspec/context_manager.rb +1 -1
- data/lib/exspec/executor.rb +11 -9
- data/lib/exspec/extensions/extension.rb +2 -2
- data/lib/exspec/extensions/mocking.rb +4 -0
- data/lib/exspec/irb/irb_exspec.rb +12 -7
- data/lib/exspec/irb/irb_patch.rb +13 -5
- data/lib/exspec.rb +1 -1
- metadata +2 -2
@@ -64,7 +64,7 @@ module Exspec
|
|
64
64
|
global_instance.instance_variable_set :@exspec, @exspec
|
65
65
|
global_instance.class.send :attr_reader, :exspec
|
66
66
|
global_eval "_ = nil"
|
67
|
-
Extension.setup_global_context self
|
67
|
+
Extension.setup_global_context self, global_instance
|
68
68
|
end
|
69
69
|
|
70
70
|
def setup_exspec_context
|
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, :to => :@exspec
|
9
|
+
delegate :puts, :print, :return_spec, :context, :commit, :to => :@exspec
|
10
10
|
attr_reader :exspec
|
11
11
|
|
12
12
|
def eval(instruction, &callback_block)
|
@@ -32,10 +32,6 @@ module Exspec
|
|
32
32
|
execute(command, parameters(param_string), callbacks) do
|
33
33
|
exspec.last_exspec_value
|
34
34
|
end
|
35
|
-
when "inspect"
|
36
|
-
execute(command, callbacks) do
|
37
|
-
exspec.inspect_last_value
|
38
|
-
end
|
39
35
|
when "redo"
|
40
36
|
execute(command, callbacks) do
|
41
37
|
exspec.redo
|
@@ -81,8 +77,14 @@ module Exspec
|
|
81
77
|
exspec.expect_inspect *params
|
82
78
|
end
|
83
79
|
when "skip"
|
80
|
+
raise SkipSignal
|
81
|
+
when "spec", "current_spec"
|
82
|
+
execute(command, callbacks) do
|
83
|
+
exspec.current_spec.full_name
|
84
|
+
end
|
85
|
+
when "description"
|
84
86
|
execute(command, callbacks) do
|
85
|
-
|
87
|
+
exspec.current_spec.full_description
|
86
88
|
end
|
87
89
|
when "load_current", "reload_current", "discard"
|
88
90
|
execute(command, callbacks) do
|
@@ -146,16 +148,16 @@ module Exspec
|
|
146
148
|
menu(spec.children) { |spec| spec.name }
|
147
149
|
end
|
148
150
|
end
|
149
|
-
when "no_log", "without_logging", "silent"
|
151
|
+
when "no_log", "without_logging", "silent", "no_history"
|
150
152
|
val = exspec.without_logging { exspec.execute param_string }
|
151
153
|
return_spec exspec.logger.last_value
|
152
154
|
val
|
153
|
-
when "log_off", "disable_log"
|
155
|
+
when "log_off", "disable_log", "history_off", "disable_history"
|
154
156
|
execute(command, callbacks) do
|
155
157
|
exspec.logger.enabled = false
|
156
158
|
exspec.last_value
|
157
159
|
end
|
158
|
-
when "log_on", "enable_log"
|
160
|
+
when "log_on", "enable_log", "history_on", "enable_history"
|
159
161
|
execute(command, callbacks) do
|
160
162
|
exspec.logger.enabled = true
|
161
163
|
return_spec exspec.logger.last_value
|
@@ -30,8 +30,8 @@ module Exspec::Extension
|
|
30
30
|
apply :setup_context, context_manager
|
31
31
|
end
|
32
32
|
|
33
|
-
def self.setup_global_context(context_manager)
|
34
|
-
apply :setup_global_context, context_manager
|
33
|
+
def self.setup_global_context(context_manager, global_instance)
|
34
|
+
apply :setup_global_context, context_manager, false, global_instance
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.setup_exspec_context(context_manager)
|
@@ -20,13 +20,18 @@ module Exspec
|
|
20
20
|
|
21
21
|
def expect_inspect(expect=nil, comment=nil)
|
22
22
|
if expect.nil? && @irb_context.io.is_a?(IRB::ReadlineInputMethod)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
begin
|
24
|
+
history = @irb_context.io.history
|
25
|
+
@irb_context.io.history = [inspect_last_value]
|
26
|
+
@irb_context.io.prompt = "fuzzy expectation: "
|
27
|
+
puts "What inspect value do you expect (only the static content, press up to get the last one):"
|
28
|
+
input = @irb_context.io.gets.strip
|
29
|
+
rescue Exception => e
|
30
|
+
puts "Error: #{e}"
|
31
|
+
ensure
|
32
|
+
@irb_context.io.history = history
|
33
|
+
expect = input.empty? ? expect : input
|
34
|
+
end
|
30
35
|
end
|
31
36
|
super expect, comment
|
32
37
|
end
|
data/lib/exspec/irb/irb_patch.rb
CHANGED
@@ -40,11 +40,19 @@ class RubyLex
|
|
40
40
|
alias_method :_lex, :lex
|
41
41
|
|
42
42
|
def lex
|
43
|
-
if
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
if @lex_state == EXPR_BEG
|
44
|
+
i = 0
|
45
|
+
while peek(i) and (line = @rests.join("").strip).length < Exspec::COMMAND_PREFIX.length
|
46
|
+
i += 1
|
47
|
+
end
|
48
|
+
if line.start_with? Exspec::COMMAND_PREFIX
|
49
|
+
skip = true
|
50
|
+
while c = getc
|
51
|
+
next if skip &&= (c =~ /[\s]/)
|
52
|
+
break if c =~ /[\n\r]/
|
53
|
+
end
|
54
|
+
return get_readed
|
55
|
+
end
|
48
56
|
end
|
49
57
|
_lex
|
50
58
|
end
|
data/lib/exspec.rb
CHANGED
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.2
|
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-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|