andyw8-seeing_is_believing 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/test.yml +60 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/Gemfile +2 -0
- data/README.md +70 -0
- data/Rakefile +88 -0
- data/appveyor.yml +32 -0
- data/bin/seeing_is_believing +7 -0
- data/docs/example.gif +0 -0
- data/docs/frog-brown.png +0 -0
- data/docs/sib-streaming.gif +0 -0
- data/features/deprecated-flags.feature +91 -0
- data/features/errors.feature +155 -0
- data/features/examples.feature +423 -0
- data/features/flags.feature +852 -0
- data/features/regression.feature +898 -0
- data/features/support/env.rb +102 -0
- data/features/xmpfilter-style.feature +471 -0
- data/lib/seeing_is_believing/binary/align_chunk.rb +47 -0
- data/lib/seeing_is_believing/binary/align_file.rb +24 -0
- data/lib/seeing_is_believing/binary/align_line.rb +25 -0
- data/lib/seeing_is_believing/binary/annotate_end_of_file.rb +56 -0
- data/lib/seeing_is_believing/binary/annotate_every_line.rb +52 -0
- data/lib/seeing_is_believing/binary/annotate_marked_lines.rb +179 -0
- data/lib/seeing_is_believing/binary/comment_lines.rb +36 -0
- data/lib/seeing_is_believing/binary/commentable_lines.rb +126 -0
- data/lib/seeing_is_believing/binary/config.rb +455 -0
- data/lib/seeing_is_believing/binary/data_structures.rb +58 -0
- data/lib/seeing_is_believing/binary/engine.rb +161 -0
- data/lib/seeing_is_believing/binary/format_comment.rb +79 -0
- data/lib/seeing_is_believing/binary/interline_align.rb +57 -0
- data/lib/seeing_is_believing/binary/remove_annotations.rb +113 -0
- data/lib/seeing_is_believing/binary/rewrite_comments.rb +62 -0
- data/lib/seeing_is_believing/binary.rb +73 -0
- data/lib/seeing_is_believing/code.rb +139 -0
- data/lib/seeing_is_believing/compatibility.rb +28 -0
- data/lib/seeing_is_believing/debugger.rb +32 -0
- data/lib/seeing_is_believing/error.rb +17 -0
- data/lib/seeing_is_believing/evaluate_by_moving_files.rb +195 -0
- data/lib/seeing_is_believing/event_stream/consumer.rb +221 -0
- data/lib/seeing_is_believing/event_stream/events.rb +193 -0
- data/lib/seeing_is_believing/event_stream/handlers/debug.rb +61 -0
- data/lib/seeing_is_believing/event_stream/handlers/record_exit_events.rb +26 -0
- data/lib/seeing_is_believing/event_stream/handlers/stream_json_events.rb +23 -0
- data/lib/seeing_is_believing/event_stream/handlers/update_result.rb +41 -0
- data/lib/seeing_is_believing/event_stream/producer.rb +178 -0
- data/lib/seeing_is_believing/hard_core_ensure.rb +58 -0
- data/lib/seeing_is_believing/hash_struct.rb +206 -0
- data/lib/seeing_is_believing/result.rb +89 -0
- data/lib/seeing_is_believing/safe.rb +112 -0
- data/lib/seeing_is_believing/swap_files.rb +90 -0
- data/lib/seeing_is_believing/the_matrix.rb +97 -0
- data/lib/seeing_is_believing/version.rb +3 -0
- data/lib/seeing_is_believing/wrap_expressions.rb +265 -0
- data/lib/seeing_is_believing/wrap_expressions_with_inspect.rb +19 -0
- data/lib/seeing_is_believing.rb +69 -0
- data/seeing_is_believing.gemspec +84 -0
- data/spec/binary/alignment_specs.rb +27 -0
- data/spec/binary/comment_lines_spec.rb +852 -0
- data/spec/binary/config_spec.rb +831 -0
- data/spec/binary/engine_spec.rb +114 -0
- data/spec/binary/format_comment_spec.rb +210 -0
- data/spec/binary/marker_spec.rb +71 -0
- data/spec/binary/remove_annotations_spec.rb +342 -0
- data/spec/binary/rewrite_comments_spec.rb +106 -0
- data/spec/code_spec.rb +233 -0
- data/spec/debugger_spec.rb +45 -0
- data/spec/evaluate_by_moving_files_spec.rb +204 -0
- data/spec/event_stream_spec.rb +762 -0
- data/spec/hard_core_ensure_spec.rb +120 -0
- data/spec/hash_struct_spec.rb +514 -0
- data/spec/seeing_is_believing_spec.rb +1094 -0
- data/spec/sib_spec_helpers/version.rb +17 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/spec_helper_spec.rb +16 -0
- data/spec/wrap_expressions_spec.rb +1013 -0
- metadata +340 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 04dfa621b8e9f0c3665c40b6d34aa79c44eccda6149d7cf5515b25addbb01cc5
|
4
|
+
data.tar.gz: f22fc3fa9ae8086a8da413a3018745743299b7bbbb6063b6e040f26673024def
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 93c3630f95d6aecb4c7295f734e2cf204ed69ea2a8052c87903138f990495bb3930abd5affcdd4ebcde4c196b5aa5f231f0e55ee6f622877e4fcad1864b23bee
|
7
|
+
data.tar.gz: b286233f3834792d3d1ef41a406e960711f7eb436a5e6b5887e5bd61756e746e7bc9169d5126de0317e2aae00cfb18ccd69eb598c73976adcf8646e2b90356fa
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
#
|
8
|
+
# This file is heavily based on this example:
|
9
|
+
# https://github.com/ruby/setup-ruby/blob/477b21f02be01bcb8030d50f37cfec92bfa615b6/.github/workflows/test.yml
|
10
|
+
|
11
|
+
name: Test
|
12
|
+
|
13
|
+
# quoting because https://twitter.com/josh_cheek/status/1406699258649190403
|
14
|
+
"on":
|
15
|
+
push:
|
16
|
+
branches: [ master ]
|
17
|
+
pull_request:
|
18
|
+
branches: [ master ]
|
19
|
+
|
20
|
+
jobs:
|
21
|
+
test:
|
22
|
+
strategy:
|
23
|
+
fail-fast: false # Just to see where we're at outside of Windows
|
24
|
+
matrix:
|
25
|
+
os:
|
26
|
+
- 'ubuntu-20.04'
|
27
|
+
- 'windows-2016'
|
28
|
+
- 'windows-2019'
|
29
|
+
- 'macos-10.15'
|
30
|
+
# This is currently unavailable: https://github.com/actions/virtual-environments/issues/2486
|
31
|
+
# - 'macos-11.0'
|
32
|
+
ruby: [ '2.5', '2.6', '2.7', '3.0' ]
|
33
|
+
|
34
|
+
name: MRI ${{ matrix.ruby }} / ${{ matrix.os }}
|
35
|
+
runs-on: ${{ matrix.os }}
|
36
|
+
|
37
|
+
steps:
|
38
|
+
- uses: actions/checkout@v2
|
39
|
+
- name: Set up Ruby
|
40
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
41
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
42
|
+
# uses: ruby/setup-ruby@v1
|
43
|
+
uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
|
44
|
+
with:
|
45
|
+
ruby-version: ${{ matrix.ruby }}
|
46
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
47
|
+
|
48
|
+
# This is honestly super confusing for me.
|
49
|
+
# https://github.com/JoshCheek/seeing_is_believing/runs/2870747499?check_suite_focus=true
|
50
|
+
- name: Fuckit, try installing bundler explicitly
|
51
|
+
run: gem install bundler
|
52
|
+
|
53
|
+
- name: Install binstubs (no rubygems / bundler at runtime, makes tests much much faster)
|
54
|
+
run: rake install
|
55
|
+
|
56
|
+
- name: Run rspec tests
|
57
|
+
run: bundle/bin/rake spec
|
58
|
+
|
59
|
+
- name: Run cucumber features
|
60
|
+
run: bundle/bin/rake cuke
|
data/.gitignore
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Transient test files
|
2
|
+
proving_grounds/*
|
3
|
+
|
4
|
+
# Don't accidentally commit gems generated from the source code
|
5
|
+
*.gem
|
6
|
+
|
7
|
+
# Since it's a gem, don't lock it down to specific versions
|
8
|
+
Gemfile.lock
|
9
|
+
|
10
|
+
# local notes about what I'm working on
|
11
|
+
todo
|
12
|
+
|
13
|
+
# Bundler stores its configuration information here
|
14
|
+
.bundle
|
15
|
+
|
16
|
+
# Where I'm vendoring gems for the standalone environment
|
17
|
+
# Going with this location b/c Bundler winds up creating this dir anyway
|
18
|
+
# to make `require "bundler/setup"` work
|
19
|
+
bundle
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
Unix/Mac: [![Unix Build Status](https://github.com/JoshCheek/seeing_is_believing/workflows/Test/badge.svg)](https://github.com/JoshCheek/seeing_is_believing/actions?query=workflow%3ATest)
|
2
|
+
|
3
|
+
Appveyor: [![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/JoshCheek/seeing_is_believing?branch=master&svg=true)](https://ci.appveyor.com/project/JoshCheek/seeing-is-believing)
|
4
|
+
|
5
|
+
Seeing Is Believing
|
6
|
+
===================
|
7
|
+
|
8
|
+
Evaluates Ruby code, recording the results of each line.
|
9
|
+
Integrates with any extensible editor (I've integrated it with many already, see [the list](https://github.com/JoshCheek/seeing_is_believing/wiki/Editor-Integration)).
|
10
|
+
If you like Swift Playgrounds, you'll like SiB.
|
11
|
+
|
12
|
+
![example](docs/example.gif)
|
13
|
+
|
14
|
+
|
15
|
+
Helpful links
|
16
|
+
-------------
|
17
|
+
|
18
|
+
* [Install](https://github.com/JoshCheek/seeing_is_believing/wiki/Installation)
|
19
|
+
* [Integrate with your editor](https://github.com/JoshCheek/seeing_is_believing/wiki/Editor-Integration)
|
20
|
+
* [Use as a library](https://github.com/JoshCheek/seeing_is_believing/wiki/Library-example)
|
21
|
+
* [Use on the command line](https://github.com/JoshCheek/seeing_is_believing/wiki/Command-Line-Usage)
|
22
|
+
* [Pro Tips (useful patterns)](https://github.com/JoshCheek/seeing_is_believing/wiki/Pro-Tips)
|
23
|
+
* [Features](https://github.com/JoshCheek/seeing_is_believing/tree/master/features)
|
24
|
+
* [Potential Future Features](https://github.com/JoshCheek/seeing_is_believing/wiki/Potential-future-features)
|
25
|
+
* [Set up it up for development work](https://github.com/JoshCheek/seeing_is_believing/wiki/Setting-it-up-for-Development)
|
26
|
+
|
27
|
+
|
28
|
+
Examples
|
29
|
+
--------
|
30
|
+
|
31
|
+
* Watch a [longer video](http://vimeo.com/73866851).
|
32
|
+
* Watch John Cinnamond use it in a [presentation](http://brightonruby.com/2016/the-point-of-objects-john-cinnamond/)
|
33
|
+
at the 10:22 minute mark.
|
34
|
+
* [Avdi](https://github.com/avdi) uses it in [Ruby Tapas](https://www.rubytapas.com/),
|
35
|
+
an amazing resource for developers in general and Ruby Developers in particular!
|
36
|
+
|
37
|
+
|
38
|
+
Known Issues
|
39
|
+
------------
|
40
|
+
|
41
|
+
* Assumes utf-8 everywhere. If this is an issue, please see the [encodings](https://github.com/JoshCheek/seeing_is_believing/wiki/Encodings) section of the wiki.
|
42
|
+
|
43
|
+
|
44
|
+
Inspiration
|
45
|
+
-----------
|
46
|
+
|
47
|
+
* [Xmpfilter](http://www.rubydoc.info/gems/rcodetools/0.8.5.0/Rcodetools/XMPFilter), which is a part of the [rcodetools gem](https://rubygems.org/gems/rcodetools).
|
48
|
+
* Bret Victor's completely inspiring talk [Inventing on Principle](https://www.youtube.com/watch?v=PUv66718DII).
|
49
|
+
* My 8th Light mentor, [Doug Bradbury](http://blog.8thlight.com/doug-bradbury/archive.html) who asked me to make it for his Kids Ruby sessions (I don't think we ever finished integrating it, though >.<)
|
50
|
+
|
51
|
+
|
52
|
+
Shout outs
|
53
|
+
-----------
|
54
|
+
|
55
|
+
* Whitequark for all the work on [Parser](http://github.com/whitequark/parser/)
|
56
|
+
|
57
|
+
|
58
|
+
License
|
59
|
+
-------
|
60
|
+
|
61
|
+
<a href="http://www.wtfpl.net/"><img src="http://www.wtfpl.net/wp-content/uploads/2012/12/wtfpl.svg" height="20" alt="WTFPL" /></a>
|
62
|
+
|
63
|
+
Copyright (C) 2014 Josh Cheek <josh.cheek@gmail.com>
|
64
|
+
|
65
|
+
This program is free software. It comes without any warranty,
|
66
|
+
to the extent permitted by applicable law.
|
67
|
+
You can redistribute it and/or modify it under the terms of the
|
68
|
+
Do What The Fuck You Want To Public License,
|
69
|
+
Version 2, as published by Sam Hocevar.
|
70
|
+
See http://www.wtfpl.net/ for more details.
|
data/Rakefile
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
Bundler::GemHelper.install_tasks
|
2
|
+
|
3
|
+
desc 'Have Bundler setup a standalone environment -- run tests in this, b/c its much faster'
|
4
|
+
task :install do
|
5
|
+
# Running without rubygems http://myronmars.to/n/dev-blog/2012/03/faster-test-boot-times-with-bundler-standalone
|
6
|
+
which("bundle") or sh 'gem', 'install', 'bundler', '--no-ri', '--no-rdoc'
|
7
|
+
|
8
|
+
next if Dir.exist? 'bundle'
|
9
|
+
|
10
|
+
# Install gems locally, into the directory "bundle" so that we can run without rubygems
|
11
|
+
sh 'bundle', 'install', '--standalone'
|
12
|
+
|
13
|
+
# Generate "binstubs" (wrappers around the gems executable files) that are configured to understand the standalone location
|
14
|
+
sh 'bundle', 'binstubs', '--all', '--path', 'bundle/bin'
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
desc 'Remove generated and irrelevant files'
|
19
|
+
task :clean do
|
20
|
+
rm_rf %w[bundle .bundle Gemfile.lock proving_grounds tags] + Dir['*.gem']
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
directory 'bundle' do
|
25
|
+
$stderr.puts "\e[31mLooks like the gems aren\'t installed, run `rake install` to install them\e[39m"
|
26
|
+
exit 1
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def require_paths
|
31
|
+
require 'bundler'
|
32
|
+
Bundler.load.specs.flat_map do |spec|
|
33
|
+
spec.require_paths
|
34
|
+
.map { |path| File.join spec.full_gem_path, path }
|
35
|
+
.flat_map { |p| ['-I', p] }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'Print the require paths for arbitrary binary execution'
|
40
|
+
task :require_paths, [:delimiter] => :bundle do |*, options|
|
41
|
+
puts require_paths.join(options.fetch(:delimiter, ' '))
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Run specs'
|
45
|
+
task spec: :bundle do
|
46
|
+
sh 'ruby', '--disable-gem', *require_paths, '-S', 'bundle/bin/rspec', '--fail-fast'
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'Run cukes'
|
50
|
+
task cuke: :bundle do
|
51
|
+
require 'bundler'
|
52
|
+
platform_filter = Gem.win_platform? ? %W[--tags ~@not-windows] : []
|
53
|
+
ruby_version_without_patchlevel = RUBY_VERSION[/^\d+\.\d+/]
|
54
|
+
sh 'ruby', '--disable-gem',
|
55
|
+
*require_paths,
|
56
|
+
'-S', 'bundle/bin/cucumber',
|
57
|
+
'--quiet', # omit stepdefs, which are usually spammy for me https://twitter.com/josh_cheek/status/1082767053071765504
|
58
|
+
'--fail-fast', # stop as soon as we see an error (don't waste CI time, don't make it hard to find error info later)
|
59
|
+
'--tags', '~@not-implemented',
|
60
|
+
'--tags', "~@not-#{RUBY_VERSION}",
|
61
|
+
'--tags', "~@not-#{ruby_version_without_patchlevel}",
|
62
|
+
*platform_filter
|
63
|
+
end
|
64
|
+
|
65
|
+
desc 'Generate tags for quick navigation'
|
66
|
+
task tags: :bundle do
|
67
|
+
excludes = %w[tmp tmpgem bundle proving_grounds].map { |dir| "--exclude=#{dir}" }
|
68
|
+
sh 'ruby', '--disable-gem',
|
69
|
+
*require_paths,
|
70
|
+
'-S', 'bundle/bin/ripper-tags',
|
71
|
+
'-R', *excludes
|
72
|
+
end
|
73
|
+
task ctags: :tags # an alias
|
74
|
+
|
75
|
+
|
76
|
+
desc 'Run all specs and cukes'
|
77
|
+
task default: [:spec, :cuke]
|
78
|
+
|
79
|
+
desc 'Install dependencies and run tests (mainly for Travis CI)'
|
80
|
+
task ci: [:spec, :cuke]
|
81
|
+
|
82
|
+
def self.which(exe)
|
83
|
+
dirs = ENV["PATH"].split(File::PATH_SEPARATOR)
|
84
|
+
exts = [""]
|
85
|
+
exts.concat(ENV["PathExt"].to_s.split(File::PATH_SEPARATOR))
|
86
|
+
candidates = dirs.product(exts) { |dir, ext| File.join(dir, exe + ext) }
|
87
|
+
exe_path = candidates.find { |c| File.executable?(c) }
|
88
|
+
end
|
data/appveyor.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Based this off of https://github.com/rspec/rspec-core/blob/22ed96bb3dbb0214dc48d6b8490ade04cdf8eedd/appveyor.yml
|
2
|
+
# Docs are at https://www.appveyor.com/docs
|
3
|
+
|
4
|
+
# I don't really understand what this is for
|
5
|
+
version: "{build}"
|
6
|
+
|
7
|
+
# This will build all PRs targetting matching branches.
|
8
|
+
# Without this, each PR builds twice -- once for the PR branch HEAD,
|
9
|
+
# and once for the merge commit that github creates for each mergable PR.
|
10
|
+
branches:
|
11
|
+
only:
|
12
|
+
- master
|
13
|
+
- /.*-maintenance$/
|
14
|
+
|
15
|
+
# Disable normal Windows builds in favor of our test script.
|
16
|
+
build: off
|
17
|
+
|
18
|
+
install:
|
19
|
+
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
20
|
+
- ruby --version
|
21
|
+
- gem --version
|
22
|
+
- rake install
|
23
|
+
|
24
|
+
test_script:
|
25
|
+
- bundle exec rake ci
|
26
|
+
|
27
|
+
environment:
|
28
|
+
matrix:
|
29
|
+
- ruby_version: '25'
|
30
|
+
- ruby_version: '26'
|
31
|
+
- ruby_version: '27'
|
32
|
+
- ruby_version: '30'
|
data/docs/example.gif
ADDED
Binary file
|
data/docs/frog-brown.png
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,91 @@
|
|
1
|
+
Feature: Flags that are deprecated
|
2
|
+
|
3
|
+
Features get added, features get removed.
|
4
|
+
Don't want to blow up just b/c of removal of some feature.
|
5
|
+
As such, these flags will continue to not blow up,
|
6
|
+
even though they won't work anymore
|
7
|
+
|
8
|
+
Scenario: --shebang with errors
|
9
|
+
When I run "seeing_is_believing -e 123 --shebang path/to/bin"
|
10
|
+
Then stderr is empty
|
11
|
+
And stdout is "123 # => 123"
|
12
|
+
And the exit status is 0
|
13
|
+
|
14
|
+
Scenario: --shebang with errors
|
15
|
+
When I run "seeing_is_believing not_a_file.rb --shebang path/to/bin"
|
16
|
+
Then stdout is empty
|
17
|
+
And stderr is:
|
18
|
+
"""
|
19
|
+
Error: not_a_file.rb does not exist!
|
20
|
+
Deprecated: `--shebang path/to/bin` SiB now uses the Ruby it was invoked with
|
21
|
+
"""
|
22
|
+
|
23
|
+
Scenario: --number-of-captures without errors
|
24
|
+
Given the file "number_of_captures.rb":
|
25
|
+
"""
|
26
|
+
5.times do |i|
|
27
|
+
i
|
28
|
+
end
|
29
|
+
"""
|
30
|
+
When I run "seeing_is_believing --number-of-captures 2 number_of_captures.rb"
|
31
|
+
Then stderr is empty
|
32
|
+
And stdout is:
|
33
|
+
"""
|
34
|
+
5.times do |i| # => 5
|
35
|
+
i # => 0, 1, ...
|
36
|
+
end # => 5
|
37
|
+
"""
|
38
|
+
And the exit status is 0
|
39
|
+
|
40
|
+
Scenario: --shebang with errors
|
41
|
+
When I run "seeing_is_believing --shebang not/a/thing not_a_file.rb"
|
42
|
+
Then stdout is empty
|
43
|
+
And stderr is:
|
44
|
+
"""
|
45
|
+
Error: not_a_file.rb does not exist!
|
46
|
+
Deprecated: `--shebang not/a/thing` SiB now uses the Ruby it was invoked with
|
47
|
+
"""
|
48
|
+
|
49
|
+
Scenario: --number-of-captures with errors
|
50
|
+
When I run "seeing_is_believing not_a_file.rb --number-of-captures 2"
|
51
|
+
Then stdout is empty
|
52
|
+
And stderr is:
|
53
|
+
"""
|
54
|
+
Error: not_a_file.rb does not exist!
|
55
|
+
Deprecated: `--number-of-captures 2` use --max-line-captures instead
|
56
|
+
"""
|
57
|
+
|
58
|
+
Scenario: --inherit-exit-status without errors
|
59
|
+
Given the file "deprecated_inherit_exit_status.rb" "exit 123"
|
60
|
+
When I run "seeing_is_believing deprecated_inherit_exit_status.rb --inherit-exit-status"
|
61
|
+
Then stdout is "exit 123"
|
62
|
+
And stderr is empty
|
63
|
+
And the exit status is 123
|
64
|
+
|
65
|
+
Scenario: --inherit-exit-status with errors
|
66
|
+
When I run "seeing_is_believing not_a_file.rb --inherit-exit-status"
|
67
|
+
Then stdout is empty
|
68
|
+
And stderr is:
|
69
|
+
"""
|
70
|
+
Error: not_a_file.rb does not exist!
|
71
|
+
Deprecated: `--inherit-exit-status` Dash has been removed for consistency, use --inherit-exitstatus
|
72
|
+
"""
|
73
|
+
|
74
|
+
Scenario: -K without errors
|
75
|
+
Given the file "deprecated_K.rb" "__ENCODING__"
|
76
|
+
When I run "seeing_is_believing -Ke deprecated_K.rb"
|
77
|
+
Then stdout is '__ENCODING__ # => #<Encoding:EUC-JP>'
|
78
|
+
And stderr is empty
|
79
|
+
When I run "seeing_is_believing -Ku deprecated_K.rb"
|
80
|
+
Then stdout is '__ENCODING__ # => #<Encoding:UTF-8>'
|
81
|
+
And stderr is empty
|
82
|
+
|
83
|
+
Scenario: -K with errors
|
84
|
+
Given the file "deprecated_K.rb" "__ENCODING__"
|
85
|
+
When I run "seeing_is_believing -Ke not_a_file.rb"
|
86
|
+
Then stdout is empty
|
87
|
+
And stderr is:
|
88
|
+
"""
|
89
|
+
Error: not_a_file.rb does not exist!
|
90
|
+
Deprecated: `-Ke` The ability to set encodings is deprecated. If you need this, details are at https://github.com/JoshCheek/seeing_is_believing/wiki/Encodings
|
91
|
+
"""
|
@@ -0,0 +1,155 @@
|
|
1
|
+
Feature: Running the binary unsuccessfully
|
2
|
+
|
3
|
+
Sometimes I mess up and use the program in a way that doesn't work.
|
4
|
+
I'd like it to be helpful in these situations so I can fix my use.
|
5
|
+
|
6
|
+
# show that it displays next to the first place in the file
|
7
|
+
# and should maybe print the stacktrace at the bottom
|
8
|
+
Scenario: Raising exceptions
|
9
|
+
Given the file "raises_exception.rb":
|
10
|
+
"""
|
11
|
+
raise "ZOMG\n!!!!"
|
12
|
+
"""
|
13
|
+
And the file "requires_exception_raising_code.rb":
|
14
|
+
"""
|
15
|
+
def first_defined
|
16
|
+
second_defined
|
17
|
+
end
|
18
|
+
|
19
|
+
def second_defined
|
20
|
+
require_relative 'raises_exception'
|
21
|
+
end
|
22
|
+
|
23
|
+
first_defined
|
24
|
+
"""
|
25
|
+
When I run "seeing_is_believing requires_exception_raising_code.rb"
|
26
|
+
Then stderr is empty
|
27
|
+
And the exit status is 1
|
28
|
+
And stdout is:
|
29
|
+
"""
|
30
|
+
def first_defined
|
31
|
+
second_defined
|
32
|
+
end # => {{method_result :first_defined}}
|
33
|
+
|
34
|
+
def second_defined
|
35
|
+
require_relative 'raises_exception' # ~> RuntimeError: ZOMG\n!!!!
|
36
|
+
end # => {{method_result :second_defined}}
|
37
|
+
|
38
|
+
first_defined
|
39
|
+
|
40
|
+
# ~> RuntimeError
|
41
|
+
# ~> ZOMG
|
42
|
+
# ~> !!!!
|
43
|
+
# ~>
|
44
|
+
# ~> {{Haiti.config.proving_grounds_dir}}/raises_exception.rb:1:in `<top (required)>'
|
45
|
+
# ~> requires_exception_raising_code.rb:6:in `require_relative'
|
46
|
+
# ~> requires_exception_raising_code.rb:6:in `second_defined'
|
47
|
+
# ~> requires_exception_raising_code.rb:2:in `first_defined'
|
48
|
+
# ~> requires_exception_raising_code.rb:9:in `<main>'
|
49
|
+
"""
|
50
|
+
|
51
|
+
@not-windows
|
52
|
+
Scenario: Raising multiple exceptions
|
53
|
+
Given the file "multiple_exceptions.rb":
|
54
|
+
"""
|
55
|
+
if pid = fork #
|
56
|
+
Process.wait pid #
|
57
|
+
raise "parent"
|
58
|
+
else
|
59
|
+
raise "child"
|
60
|
+
end
|
61
|
+
|
62
|
+
"""
|
63
|
+
When I run "seeing_is_believing multiple_exceptions.rb"
|
64
|
+
Then stderr is empty
|
65
|
+
And the exit status is 1
|
66
|
+
And stdout is:
|
67
|
+
"""
|
68
|
+
if pid = fork #
|
69
|
+
Process.wait pid #
|
70
|
+
raise "parent" # ~> RuntimeError: parent
|
71
|
+
else
|
72
|
+
raise "child" # ~> RuntimeError: child
|
73
|
+
end
|
74
|
+
|
75
|
+
# ~> RuntimeError
|
76
|
+
# ~> child
|
77
|
+
# ~>
|
78
|
+
# ~> multiple_exceptions.rb:5:in `<main>'
|
79
|
+
|
80
|
+
# ~> RuntimeError
|
81
|
+
# ~> parent
|
82
|
+
# ~>
|
83
|
+
# ~> multiple_exceptions.rb:3:in `<main>'
|
84
|
+
"""
|
85
|
+
When I run "seeing_is_believing multiple_exceptions.rb -x"
|
86
|
+
Then stderr is empty
|
87
|
+
And the exit status is 1
|
88
|
+
And stdout is:
|
89
|
+
"""
|
90
|
+
if pid = fork #
|
91
|
+
Process.wait pid #
|
92
|
+
raise "parent" # ~> RuntimeError: parent
|
93
|
+
else
|
94
|
+
raise "child" # ~> RuntimeError: child
|
95
|
+
end
|
96
|
+
|
97
|
+
# ~> RuntimeError
|
98
|
+
# ~> child
|
99
|
+
# ~>
|
100
|
+
# ~> multiple_exceptions.rb:5:in `<main>'
|
101
|
+
|
102
|
+
# ~> RuntimeError
|
103
|
+
# ~> parent
|
104
|
+
# ~>
|
105
|
+
# ~> multiple_exceptions.rb:3:in `<main>'
|
106
|
+
"""
|
107
|
+
|
108
|
+
Scenario: Syntactically invalid file
|
109
|
+
Given the file "invalid_syntax.rb":
|
110
|
+
"""
|
111
|
+
'this is valid'
|
112
|
+
'this is not
|
113
|
+
"""
|
114
|
+
When I run "seeing_is_believing invalid_syntax.rb"
|
115
|
+
Then stderr is:
|
116
|
+
"""
|
117
|
+
Syntax Error: invalid_syntax.rb:2
|
118
|
+
unterminated string meets end of file
|
119
|
+
"""
|
120
|
+
And the exit status is 2
|
121
|
+
And stdout is empty
|
122
|
+
|
123
|
+
Scenario: Passing a nonexistent file
|
124
|
+
When I run "seeing_is_believing this_file_does_not_exist.rb"
|
125
|
+
Then stderr is "Error: this_file_does_not_exist.rb does not exist!"
|
126
|
+
And the exit status is 2
|
127
|
+
And stdout is empty
|
128
|
+
|
129
|
+
Scenario: Passing unknown flags
|
130
|
+
Given the file "some_file" "1"
|
131
|
+
When I run "seeing_is_believing --unknown-flag"
|
132
|
+
Then stderr is 'Error: --unknown-flag is not a flag, see the help screen (-h) for a list of options'
|
133
|
+
And the exit status is 2
|
134
|
+
And stdout is empty
|
135
|
+
|
136
|
+
Scenario: Reports deprecations with errors
|
137
|
+
When I run "seeing_is_believing this_file_does_not_exist.rb --number-of-captures 10"
|
138
|
+
Then stderr includes "--number-of-captures 10"
|
139
|
+
And the exit status is 2
|
140
|
+
And stdout is empty
|
141
|
+
|
142
|
+
Scenario: Stack overflow
|
143
|
+
Given the file "stack_overflow.rb":
|
144
|
+
"""
|
145
|
+
def m() m end
|
146
|
+
m
|
147
|
+
"""
|
148
|
+
When I run "seeing_is_believing stack_overflow.rb"
|
149
|
+
Then stderr is empty
|
150
|
+
And the exit status is 1
|
151
|
+
And stdout includes:
|
152
|
+
"""
|
153
|
+
def m() m end # ~> SystemStackError: stack level too deep
|
154
|
+
m
|
155
|
+
"""
|