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.
@@ -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
@@ -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
- SkipSignal
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)
@@ -66,6 +66,10 @@ module Exspec::Mocking
66
66
  end
67
67
  end
68
68
 
69
+ def _clear_calls
70
+ @method_calls.clear
71
+ end
72
+
69
73
  def _have_been_called?(method)
70
74
  @method_calls.any? { |call| call[:method] == method.to_sym }
71
75
  end
@@ -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
- puts "What inspect value do you expect (only the static content, press up to get the last one):"
24
- history = @irb_context.io.history
25
- @irb_context.io.history = [inspect_last_value]
26
- @irb_context.io.prompt = "fuzzy expectation: "
27
- input = @irb_context.io.gets.strip
28
- @irb_context.io.history = history
29
- expect = input.empty? ? expect : input
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
@@ -40,11 +40,19 @@ class RubyLex
40
40
  alias_method :_lex, :lex
41
41
 
42
42
  def lex
43
- if peek_equal?(Exspec::COMMAND_PREFIX)
44
- identify_comment
45
- ungetc
46
- token
47
- return get_readed
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
@@ -112,7 +112,7 @@ module Exspec
112
112
  without_logging do
113
113
  run spec
114
114
  end
115
- commit "#{COMMAND_PREFIX}include #{spec.name}"
115
+ commit "#{COMMAND_PREFIX}include #{spec.full_name}"
116
116
  end
117
117
 
118
118
  def retry
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.1
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-05 00:00:00.000000000 Z
12
+ date: 2013-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport