seeing_is_believing 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  desc 'run specs'
2
2
  task :spec do
3
- sh 'rspec -cf d --fail-fast'
3
+ sh 'rspec -t ~not_implemented -cf d --fail-fast'
4
4
  end
5
5
 
6
6
  desc 'run cukes'
data/Readme.md CHANGED
@@ -136,16 +136,12 @@ Known Issues
136
136
 
137
137
  * `BEGIN/END` breaks things and I probably won't take the time to fix it, becuase it's nontrivial and its really meant for command-line scripts, but there is currently a cuke for it
138
138
  * Heredocs aren't recorded. It might actually be possible if the ExpressionList were to get smarter
139
- * errors come out really shitty if you're calling them from another program like TextMate, would be better to put a line in that shows where the error is.
140
- * "1\\\n.even?" just fucks everything
141
139
 
142
140
  Todo
143
141
  ====
144
- * Don't blow up on "a\\\n.b"
145
- * Record results with "a\n.b.\nc"
146
- * Record results with "a + \n b"
147
- * a\n.b(\n.c\n) will blow up, need to make sure that joining it with the next line is valid ruby
142
+
148
143
  * Refactor ExpressionList/SeeingIsBelieving to store lines in an array instead of as a string, so everyone doesn't magically need to know when to chomp
144
+ * Make friends who actually know how to parse Ruby syntax (omg, teach me Ripper, pls, it will make this lib so much better, you have no idea O.o)
149
145
 
150
146
  License
151
147
  =======
@@ -94,8 +94,8 @@ Feature: Running the binary successfully
94
94
  HERE
95
95
 
96
96
  # method invocation that occurs entirely on the next line
97
- [*1..10] # => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
98
- .select(&:even?) # => [2, 4, 6, 8, 10]
97
+ [*1..10]
98
+ .select(&:even?)
99
99
  .map { |n| n * 2 } # => [4, 8, 12, 16, 20]
100
100
 
101
101
  # mutliple levels of nesting
@@ -10,7 +10,7 @@ Feature:
10
10
  And the exit status is 0
11
11
  And stdout is "# single comment"
12
12
 
13
- Scenario: No method error just fucks everything
13
+ Scenario: Name error just fucks everything
14
14
  Given the file "no_method_error.rb":
15
15
  """
16
16
  a
@@ -22,3 +22,17 @@ Feature:
22
22
  """
23
23
  a # ~> NameError: undefined local variable or method `a' for main:Object
24
24
  """
25
+
26
+ Scenario:
27
+ Given the file "raising_custom_errors.rb":
28
+ """
29
+ MyError = Class.new StandardError
30
+ begin
31
+ raise "a"
32
+ rescue
33
+ raise MyError.new("c")
34
+ end
35
+ """
36
+ When I run "seeing_is_believing raising_custom_errors.rb"
37
+ Then stderr is empty
38
+ And the exit status is 1
@@ -101,7 +101,7 @@ class SeeingIsBelieving
101
101
  def format_line(line, line_number, line_results)
102
102
  options = options().merge pad_to: alignment_strategy.line_length_for(line_number)
103
103
  formatted_line = if line_results.has_exception?
104
- result = sprintf "%s: %s", line_results.exception.class, line_results.exception.message
104
+ result = sprintf "%s: %s", line_results.exception.class_name, line_results.exception.message
105
105
  LineFormatter.new(line, "#{EXCEPTION_PREFIX} ", result, options).call
106
106
  elsif line_results.any?
107
107
  LineFormatter.new(line, "#{RESULT_PREFIX} ", line_results.join(', '), options).call
@@ -11,6 +11,7 @@
11
11
  # I did look at Ripper, and it will invoke on_kw("__FILE__")
12
12
  # when it sees this.
13
13
 
14
+ require 'yaml'
14
15
  require 'open3'
15
16
  require 'stringio'
16
17
  require 'fileutils'
@@ -131,7 +132,7 @@ class SeeingIsBelieving
131
132
  end
132
133
 
133
134
  def deserialize_result
134
- Marshal.load stdout
135
+ YAML.load stdout
135
136
  end
136
137
 
137
138
  def notify_user_of_error
@@ -30,11 +30,7 @@ class SeeingIsBelieving
30
30
  debug { "GENERATED: #{pending_expression.expression.inspect}, ADDING IT TO #{inspected_expressions expressions}" }
31
31
  expressions << pending_expression
32
32
 
33
- expression = reduce expressions, offset
34
-
35
- if next_line_modifies_current?
36
- expressions << PendingExpression.new(expression.chomp, []) # chomp b/c on_complete callback prob adds newline, but we do to when joining
37
- end
33
+ expression = reduce expressions, offset unless next_line_modifies_current?
38
34
 
39
35
  offset += 1
40
36
  end until expressions.empty?
@@ -1,4 +1,9 @@
1
1
  class SeeingIsBelieving
2
+
3
+ # We cannot serialize the actual exception because we do not have any guarantee that its class is defined on the SIB side,
4
+ # so we must use simpler data structures (Strings and arrays)
5
+ RecordedException = Struct.new :class_name, :message, :backtrace
6
+
2
7
  module HasException
3
8
  attr_accessor :exception
4
9
  alias has_exception? exception
@@ -29,9 +29,12 @@ class SeeingIsBelieving
29
29
  end
30
30
 
31
31
  def record_exception(line_number, exception)
32
- self.exception = exception
32
+ recorded_exception = RecordedException.new exception.class.name,
33
+ exception.message,
34
+ exception.backtrace
35
+ self.exception = recorded_exception
33
36
  track_line_number line_number
34
- results(line_number).exception = exception
37
+ results(line_number).exception = recorded_exception
35
38
  end
36
39
 
37
40
  def [](line_number)
@@ -1,6 +1,7 @@
1
1
  # WARNING: DO NOT REQUIRE THIS FILE, IT WILL FUCK YOU UP!!!!!!
2
2
 
3
3
 
4
+ require 'yaml'
4
5
  require 'stringio'
5
6
  real_stdout = STDOUT
6
7
  real_stderr = STDERR
@@ -14,5 +15,5 @@ at_exit do
14
15
  $seeing_is_believing_current_result.stdout = fake_stdout.string
15
16
  $seeing_is_believing_current_result.stderr = fake_stderr.string
16
17
 
17
- real_stdout.write Marshal.dump $seeing_is_believing_current_result
18
+ real_stdout.write YAML.dump $seeing_is_believing_current_result
18
19
  end
@@ -1,3 +1,3 @@
1
1
  class SeeingIsBelieving
2
- VERSION = '0.0.22'
2
+ VERSION = '0.0.23'
3
3
  end
@@ -178,7 +178,8 @@ describe SeeingIsBelieving::ExpressionList do
178
178
  end
179
179
  end
180
180
 
181
- example "example: method invocations on next line" do
181
+ example "example: method invocations on next line", not_implemented: true do
182
+ pending 'I need to *actually* parse the Ruby in order to be able to identify where to split the expressions :('
182
183
  # example 1: consume the expression with lines after
183
184
  list = list_for ['a', '.b', ' .c', 'irrelevant'] do |*expressions, offset|
184
185
  flat_expressions = expressions.flatten.join('')
@@ -215,6 +216,45 @@ describe SeeingIsBelieving::ExpressionList do
215
216
  list.call.should == ['A.B', 2]
216
217
  end
217
218
 
219
+ example "example: method invocations on next line with the first line not being its own expression", not_implemented: true do
220
+ pending 'I need to *actually* parse the Ruby in order to be able to identify where to split the expressions :('
221
+ list = list_for ['x = a', '.b', ' .c', 'irrelevant'] do |*expressions, offset|
222
+ flat_expressions = expressions.flatten.join('')
223
+ case offset
224
+ when 0
225
+ flat_expressions.should == 'a'
226
+ 'A'
227
+ when 1
228
+ flat_expressions.should == 'A.b'
229
+ 'A.B'
230
+ when 2
231
+ flat_expressions.should == 'x = A.B .c'
232
+ 'X=A.B.C'
233
+ else
234
+ raise "O.o"
235
+ end
236
+ end
237
+ list.call.should == ['X=A.B.C', 3]
238
+
239
+ list = list_for ['puts a', '.b', ' .c', 'irrelevant'] do |*expressions, offset|
240
+ flat_expressions = expressions.flatten.join('')
241
+ case offset
242
+ when 0
243
+ flat_expressions.should == 'a'
244
+ 'A'
245
+ when 1
246
+ flat_expressions.should == 'A.b'
247
+ 'A.B'
248
+ when 2
249
+ flat_expressions.should == 'puts A.B .c'
250
+ 'PUTS A.B.C'
251
+ else
252
+ raise "O.o"
253
+ end
254
+ end
255
+ list.call.should == ['PUTS A.B.C', 3]
256
+ end
257
+
218
258
  example "example: smoke test debug option" do
219
259
  stream = StringIO.new
220
260
  call(%w[a+ b], debug: true, debug_stream: stream) { |*expressions, _| expressions.join("\n") }
@@ -269,8 +269,8 @@ describe SeeingIsBelieving do
269
269
  end
270
270
 
271
271
  it 'can deal with methods that are invoked entirely on the next line' do
272
- values_for("1\n.even?").should == [['1'], ['false']]
273
- values_for("1\n.even?\n__END__").should == [['1'], ['false']]
272
+ values_for("a = 1\n.even?\na").should == [[], ['false'], ['false']]
273
+ values_for("1\n.even?\n__END__").should == [[], ['false']]
274
274
  end
275
275
 
276
276
  it 'does not record leading comments' do
@@ -284,7 +284,7 @@ describe SeeingIsBelieving do
284
284
  expect { invoke "sleep 0.2", timeout: 0.1 }.to raise_error Timeout::Error
285
285
  end
286
286
 
287
- it 'can record the middle of a chain of calls', t:true do
287
+ it 'can record the middle of a chain of calls', not_implemented: true do
288
288
  values_for("[*1..5]
289
289
  .select(&:even?)
290
290
  .map { |n| n * 3 }").should == [['[1, 2, 3, 4, 5]'],
metadata CHANGED
@@ -1,71 +1,80 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seeing_is_believing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ prerelease:
5
+ version: 0.0.23
5
6
  platform: ruby
6
7
  authors:
7
8
  - Josh Cheek
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-04-30 00:00:00.000000000 Z
12
+ date: 2013-05-11 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
- name: rake
15
- requirement: !ruby/object:Gem::Requirement
15
+ version_requirements: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: 10.0.3
20
+ none: false
21
+ name: rake
20
22
  type: :development
21
23
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
24
+ requirement: !ruby/object:Gem::Requirement
23
25
  requirements:
24
26
  - - ~>
25
27
  - !ruby/object:Gem::Version
26
28
  version: 10.0.3
29
+ none: false
27
30
  - !ruby/object:Gem::Dependency
28
- name: rspec
29
- requirement: !ruby/object:Gem::Requirement
31
+ version_requirements: !ruby/object:Gem::Requirement
30
32
  requirements:
31
33
  - - ~>
32
34
  - !ruby/object:Gem::Version
33
35
  version: 2.12.0
36
+ none: false
37
+ name: rspec
34
38
  type: :development
35
39
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
40
+ requirement: !ruby/object:Gem::Requirement
37
41
  requirements:
38
42
  - - ~>
39
43
  - !ruby/object:Gem::Version
40
44
  version: 2.12.0
45
+ none: false
41
46
  - !ruby/object:Gem::Dependency
42
- name: cucumber
43
- requirement: !ruby/object:Gem::Requirement
47
+ version_requirements: !ruby/object:Gem::Requirement
44
48
  requirements:
45
49
  - - ~>
46
50
  - !ruby/object:Gem::Version
47
51
  version: 1.2.1
52
+ none: false
53
+ name: cucumber
48
54
  type: :development
49
55
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
56
+ requirement: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - ~>
53
59
  - !ruby/object:Gem::Version
54
60
  version: 1.2.1
61
+ none: false
55
62
  - !ruby/object:Gem::Dependency
56
- name: ichannel
57
- requirement: !ruby/object:Gem::Requirement
63
+ version_requirements: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - ~>
60
66
  - !ruby/object:Gem::Version
61
67
  version: 5.1.1
68
+ none: false
69
+ name: ichannel
62
70
  type: :development
63
71
  prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
72
+ requirement: !ruby/object:Gem::Requirement
65
73
  requirements:
66
74
  - - ~>
67
75
  - !ruby/object:Gem::Version
68
76
  version: 5.1.1
77
+ none: false
69
78
  description: Records the results of every line of code in your file (intended to be
70
79
  like xmpfilter), inspired by Bret Victor's JavaScript example in his talk "Inventing
71
80
  on Principle"
@@ -122,26 +131,27 @@ files:
122
131
  homepage: https://github.com/JoshCheek/seeing_is_believing
123
132
  licenses:
124
133
  - WTFPL
125
- metadata: {}
126
134
  post_install_message:
127
135
  rdoc_options: []
128
136
  require_paths:
129
137
  - lib
130
138
  required_ruby_version: !ruby/object:Gem::Requirement
131
139
  requirements:
132
- - - '>='
140
+ - - ! '>='
133
141
  - !ruby/object:Gem::Version
134
142
  version: '0'
143
+ none: false
135
144
  required_rubygems_version: !ruby/object:Gem::Requirement
136
145
  requirements:
137
- - - '>='
146
+ - - ! '>='
138
147
  - !ruby/object:Gem::Version
139
148
  version: '0'
149
+ none: false
140
150
  requirements: []
141
151
  rubyforge_project: seeing_is_believing
142
- rubygems_version: 2.0.0
152
+ rubygems_version: 1.8.23
143
153
  signing_key:
144
- specification_version: 4
154
+ specification_version: 3
145
155
  summary: Records results of every line of code in your file
146
156
  test_files:
147
157
  - features/errors.feature
@@ -159,3 +169,4 @@ test_files:
159
169
  - spec/queue_spec.rb
160
170
  - spec/seeing_is_believing_spec.rb
161
171
  - spec/syntax_analyzer_spec.rb
172
+ has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 4b8af587001dcce44e111c4611d49e476e6d0248
4
- data.tar.gz: 969a7c9d9fdb9dc658c7c8c18a9805da7a2baedd
5
- SHA512:
6
- metadata.gz: cb909d18af0d797c8236c53015a430f5bf7bf45b7c625a4986488b89bb8df8500220fc0208270ce9e44bb556f38f6b79356e71c8f4c2445a0126cf4697a67501
7
- data.tar.gz: b72db4437845c50df7d5c948b2fa73d0397e7cbcf493600eeb953c612ec93cc6d0f759a6503504e89f642e619c21a231df8ca51c11fbc7e68d28aeab7c7f320f