rundoc 0.0.1 → 0.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.
@@ -0,0 +1,445 @@
1
+ ```
2
+ :::- rundoc
3
+ email = ENV['HEROKU_EMAIL'] || `heroku auth:whoami`
4
+
5
+ Rundoc.configure do |config|
6
+ config.project_root = "myapp"
7
+ config.filter_sensitive(email => "developer@example.com")
8
+ end
9
+ ```
10
+ <!--
11
+ rundoc src:
12
+ https://github.com/schneems/rundoc/blob/master/test/fixtures/rails_5/rundoc.md
13
+ -->
14
+
15
+ Ruby on Rails is a popular web framework written in [Ruby](http://www.ruby-lang.org/). This guide covers using Rails 5 on Heroku. For information about running previous versions of Rails on Heroku, see [Getting Started with Rails 4.x on Heroku](getting-started-with-rails4) or [Getting Started with Rails 3.x on Heroku](getting-started-with-rails3).
16
+
17
+ For this guide you will need:
18
+
19
+ - Basic Ruby/Rails knowledge.
20
+ - A locally installed version of Ruby 2.2.0+, Rubygems, Bundler, and Rails 5+.
21
+ - Basic Git knowledge.
22
+ - A Heroku user account: [Signup is free and instant](https://signup.heroku.com/devcenter).
23
+
24
+ ## Local workstation setup
25
+
26
+ Install the [Heroku Toolbelt](https://toolbelt.heroku.com/) on your local workstation. This ensures that you have access to the [Heroku command-line client](/categories/command-line), Heroku Local, and the Git revision control system. You will also need [Ruby and Rails installed](http://guides.railsgirls.com/install).
27
+
28
+ Once installed, you'll have access to the `$ heroku` command from your command shell. Log in using the email address and password you used when creating your Heroku account:
29
+
30
+
31
+ > callout Note that `$` symbol before commands indicates they should be run on the command line, prompt, or terminal with appropriate permissions. Do not copy the `$` symbol.
32
+
33
+ ```term
34
+ $ heroku login
35
+ Enter your Heroku credentials.
36
+ Email: schneems@example.com
37
+ Password:
38
+ Could not find an existing public key.
39
+ Would you like to generate one? [Yn]
40
+ Generating new SSH public key.
41
+ Uploading ssh public key /Users/adam/.ssh/id_rsa.pub
42
+ ```
43
+
44
+ Press enter at the prompt to upload your existing `ssh` key or create a new one, used for pushing code later on.
45
+
46
+ ## Write your app
47
+
48
+ > callout To run on Heroku, your app must be configured to use the Postgres database, have all dependencies declared in your `Gemfile`.
49
+
50
+
51
+ If you are starting from an existing app, [upgrade to Rails 5](http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-4-2-to-rails-5-0) before continuing. If not, a vanilla Rails 5 app will serve as a suitable sample app. To build a new app make sure that you're using the Rails 5.x using `$ rails -v`. You can get the new version of rails by running,
52
+
53
+ ```
54
+ :::- $ git clone https://github.com/rails/rails.git
55
+ ```
56
+
57
+ ```term
58
+ $ gem install rails --no-ri --no-rdoc
59
+ ```
60
+
61
+ Then create a new app:
62
+
63
+ ```term
64
+ $ rails new myapp --database=postgresql
65
+ :::-> $ ruby rails/railties/exe/rails new myapp --edge --database=postgresql
66
+ ```
67
+
68
+ Then move into your application directory.
69
+
70
+ ```term
71
+ :::> $ cd myapp
72
+ ```
73
+
74
+ > callout If you experience problems or get stuck with this tutorial, your questions may be answered in a later part of this document. If you experience a problem, try reading through the entire document and then go back to your issue. It can also be useful to review your previous steps to ensure they all executed correctly.
75
+
76
+ ## Database
77
+
78
+ If you already have an app that was created without specifying `--database=postgresql` you will need to add the `pg` gem to your Rails project. Edit your `Gemfile` and change this line:
79
+
80
+ ```ruby
81
+ gem 'sqlite3'
82
+ ```
83
+
84
+ To this:
85
+
86
+ ```ruby
87
+ gem 'pg'
88
+ ```
89
+
90
+ > callout We highly recommend using PostgreSQL during development. Maintaining [parity between your development](http://www.12factor.net/dev-prod-parity) and deployment environments prevents subtle bugs from being introduced because of differences between your environments. [Install Postgres locally](https://devcenter.heroku.com/articles/heroku-postgresql#local-setup) now if it is not already on your system.
91
+
92
+ Now re-install your dependencies (to generate a new `Gemfile.lock`):
93
+
94
+ ```ruby
95
+ $ bundle install
96
+ ```
97
+
98
+ To get more information on why this change is needed and how to configure your app to run Postgres locally, see [why you cannot use Sqlite3 on Heroku](https://devcenter.heroku.com/articles/sqlite3).
99
+
100
+ In addition to using the `pg` gem, you'll also need to ensure the `config/database.yml` is using the `postgresql` adapter.
101
+
102
+ The development section of your `config/database.yml` file should look something like this:
103
+
104
+ ```term
105
+ :::>> $ cat config/database.yml
106
+ ```
107
+
108
+ Be careful here. If you omit the `sql` at the end of `postgresql` in the `adapter` section, your application will not work.
109
+
110
+ ## Welcome page
111
+
112
+ Rails 5 no longer has a static index page in production. When you're using a new app, there will not be a root page in production, so we need to create one. We will first create a controller called `welcome` for our home page to live:
113
+
114
+ ```term
115
+ :::> $ rails generate controller welcome
116
+ ```
117
+
118
+ Next we'll add an index page.
119
+
120
+ ```html
121
+ :::>> file.write app/views/welcome/index.html.erb
122
+ <h2>Hello World</h2>
123
+ <p>
124
+ The time is now: <%= Time.now %>
125
+ </p>
126
+ ```
127
+
128
+ Now we need to make Rails route to this action. We'll edit `config/routes.rb` to set the index page to our new method:
129
+
130
+ ```ruby
131
+ :::>> file.append config/routes.rb#4
132
+ root 'welcome#index'
133
+ ```
134
+
135
+ You can verify that the page is there by running your server:
136
+
137
+ ```term
138
+ $ rails server
139
+ ```
140
+
141
+ And visiting [http://localhost:3000](http://localhost:3000) in your browser. If you do not see the page, [use the logs](#view-the-logs) that are output to your server to debug.
142
+
143
+ ## Heroku gems
144
+
145
+ Previous versions of Rails required you to add a gem to your project [rails_12factor](https://github.com/heroku/rails_12factor) to enable static asset serving and logging on Heroku. If you are deploying a new application this gem is not needed. If you are upgrading an existing application you can remove this gem provided you have the apprpriate configuration in your `config/environments/production.rb` file:
146
+
147
+ ```ruby
148
+ # config/environments/production.rb
149
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
150
+
151
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
152
+ logger = ActiveSupport::Logger.new(STDOUT)
153
+ logger.formatter = config.log_formatter
154
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
155
+ end
156
+ ```
157
+
158
+ ## Specify Ruby version in app
159
+
160
+ Rails 5 requires Ruby 2.2.0 or above. Heroku has a recent version of Ruby installed by default, however you can specify an exact version by using the `ruby` DSL in your `Gemfile`.
161
+
162
+ ```ruby
163
+ :::>> file.append Gemfile
164
+ ruby "2.4.1"
165
+ ```
166
+
167
+ You should also be running the same version of Ruby locally. You can check this by running `$ ruby -v`. You can get more information on [specifying your Ruby version on Heroku here](https://devcenter.heroku.com/articles/ruby-versions).
168
+
169
+ ## Store your app in Git
170
+
171
+ Heroku relies on [Git](http://git-scm.com/), a distributed source control management tool, for deploying your project. If your project is not already in Git, first verify that `git` is on your system:
172
+
173
+ ```term
174
+ :::> $ git --help
175
+ :::>> | $ head -n 5
176
+ ```
177
+
178
+ If you don't see any output or get `command not found` you will need to install it on your system. Verify that the [Heroku toolbelt](https://toolbelt.heroku.com/) is installed.
179
+
180
+ Once you've verified that Git works, first make sure you are in your Rails app directory by running `$ ls`:
181
+
182
+ The output should look like this:
183
+
184
+ ```term
185
+ :::>> $ ls
186
+ ```
187
+
188
+ Now run these commands in your Rails app directory to initialize and commit your code to Git:
189
+
190
+ ```term
191
+ :::> $ git init
192
+ :::> $ git add .
193
+ :::> $ git commit -m "init"
194
+ ```
195
+
196
+ You can verify everything was committed correctly by running:
197
+
198
+ ```term
199
+ :::>> $ git status
200
+ ```
201
+
202
+ Now that your application is committed to Git you can deploy to Heroku.
203
+
204
+ ## Deploy your application to Heroku
205
+
206
+ Make sure you are in the directory that contains your Rails app, then create an app on Heroku:
207
+
208
+ ```term
209
+ :::>> $ heroku create
210
+ ```
211
+
212
+ You can verify that the remote was added to your project by running:
213
+
214
+ ```term
215
+ :::>> $ git config --list | grep heroku
216
+ ```
217
+
218
+ If you see `fatal: not in a git directory` then you are likely not in the correct directory. Otherwise you may deploy your code. After you deploy your code, you will need to migrate your database, make sure it is properly scaled, and use logs to debug any issues that come up.
219
+
220
+ Deploy your code:
221
+
222
+ ```term
223
+ :::>> $ git push heroku master
224
+ ```
225
+
226
+ It is always a good idea to check to see if there are any warnings or errors in the output. If everything went well you can migrate your database.
227
+
228
+ ## Migrate your database
229
+
230
+ If you are using the database in your application you need to manually migrate the database by running:
231
+
232
+ ```term
233
+ $ heroku run rake db:migrate
234
+ ```
235
+
236
+ Any commands after the `heroku run` will be executed on a Heroku [dyno](dynos). You can obtain an interactive shell session by running `$ heroku run bash`.
237
+
238
+ ## Visit your application
239
+
240
+ You've deployed your code to Heroku. You can now instruct Heroku to execute a process type. Heroku does this by running the associated command in a [dyno](dynos), which is a lightweight container that is the basic unit of composition on Heroku.
241
+
242
+ Let's ensure we have one dyno running the `web` process type:
243
+
244
+ ```term
245
+ :::> $ heroku ps:scale web=1
246
+ ```
247
+
248
+ You can check the state of the app's dynos. The `heroku ps` command lists the running dynos of your application:
249
+
250
+ ```term
251
+ :::>> $ heroku ps
252
+ ```
253
+
254
+ Here, one dyno is running.
255
+
256
+ We can now visit the app in our browser with `heroku open`.
257
+
258
+ ```term
259
+ :::>> $ heroku open
260
+ ```
261
+
262
+ You should now see the "Hello World" text we inserted above.
263
+
264
+ Heroku gives you a default web URL for simplicity while you are developing. When you are ready to scale up and use Heroku for production you can add your own [custom domain](https://devcenter.heroku.com/articles/custom-domains).
265
+
266
+ ## View the logs
267
+
268
+ If you run into any problems getting your app to perform properly, you will need to check the logs.
269
+
270
+ You can view information about your running app using one of the [logging commands](logging), `heroku logs`:
271
+
272
+ ```term
273
+ :::>> $ heroku logs
274
+ ```
275
+
276
+ You can also get the full stream of logs by running the logs command with the `--tail` flag option like this:
277
+
278
+ ```term
279
+ $ heroku logs --tail
280
+ ```
281
+
282
+ ## Dyno sleeping and scaling
283
+
284
+ By default, new applications are deployed to a free dyno. Free apps will "sleep" to conserve resources. You can find more information about this behavior by reading about [free dyno behavior](https://devcenter.heroku.com/articles/free-dyno-hours).
285
+
286
+ To avoid dyno sleeping, you can upgrade to a hobby or professional dyno type as described in the [Dyno Types](dyno-types) article. For example, if you migrate your app to a professional dyno, you can easily scale it by running a command telling Heroku to execute a specific number of dynos, each running your web process type.
287
+
288
+ ## Rails console
289
+
290
+ Heroku allows you to run commands in a [one-off dyno](one-off-dynos) - scripts and applications that only need to be executed when needed - using the `heroku run` command. Use this to launch a Rails console process attached to your local terminal for experimenting in your app's environment:
291
+
292
+ ```term
293
+ $ heroku run rails console
294
+ irb(main):001:0> puts 1+1
295
+ 2
296
+ ```
297
+
298
+ Another useful command for debugging is `$ heroku run bash` which will spin up a new dyno and give you access to a bash session.
299
+
300
+ ## Rake
301
+
302
+ Rake can be run as an attached process exactly like the console:
303
+
304
+ ```term
305
+ $ heroku run rake db:migrate
306
+ ```
307
+
308
+ ## Webserver
309
+
310
+ By default, your app's web process runs `rails server`, which uses Puma in Rails 5. If you are upgrading an app you'll need to add `puma` to your application `Gemfile`:
311
+
312
+ ```ruby
313
+ gem 'puma'
314
+ ```
315
+
316
+ Then run
317
+
318
+ ```term
319
+ :::> $ bundle install
320
+ ```
321
+
322
+ Now you are ready to configure your app to use Puma. For this tutorial we will use the default `config/puma.rb` of that ships with Rails 5, but we recommend reading more about configuring your application for maximum performance by [reading the Puma documentation](https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server).
323
+
324
+ Finally you will need to tell Heroku how to run your Rails app by creating a `Procfile` in the root of your application directory.
325
+
326
+ ### Procfile
327
+
328
+ Change the command used to launch your web process by creating a file called [Procfile](procfile) and entering this:
329
+
330
+ ```
331
+ :::>> file.write Procfile
332
+ web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}
333
+ ```
334
+
335
+ > Note: The case of `Procfile` matters, the first letter must be uppercase.
336
+
337
+ We recommend generating a Puma config file based on [our Puma documentation](https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server) for maximum performance.
338
+
339
+ To use the Procfile locally you can use `heroku local`.
340
+
341
+ In addition to running commands in your `Procfile` `heroku local` can also help you manage environment variables locally through a `.env` file. Set the local `RACK_ENV` to development in your environment and a `PORT` to connect to. Before pushing to Heroku you'll want to test with the `RACK_ENV` set to production since this is the environment your Heroku app will run in.
342
+
343
+ ```term
344
+ :::>> $ echo "RACK_ENV=development" >>.env
345
+ :::>> $ echo "PORT=3000" >> .env
346
+ ```
347
+
348
+ > Note: Another alternative to using environment variables locally with a `.env` file is the [dotenv](https://github.com/bkeepers/dotenv) gem.
349
+
350
+ You'll also want to add `.env` to your `.gitignore` since this is for local environment setup.
351
+
352
+ ```term
353
+ :::> $ echo ".env" >> .gitignore
354
+ :::> $ git add .gitignore
355
+ :::> $ git commit -m "add .env to .gitignore"
356
+ ```
357
+
358
+ Test your Procfile locally using Foreman. You can now start your web server by running:
359
+
360
+ ```term
361
+ $ heroku local
362
+ [OKAY] Loaded ENV .env File as KEY=VALUE Format
363
+ 11:06:35 AM web.1 | [18878] Puma starting in cluster mode...
364
+ 11:06:35 AM web.1 | [18878] * Version 3.8.2 (ruby 2.4.1-p111), codename: Sassy Salamander
365
+ 11:06:35 AM web.1 | [18878] * Min threads: 5, max threads: 5
366
+ 11:06:35 AM web.1 | [18878] * Environment: development
367
+ 11:06:35 AM web.1 | [18878] * Process workers: 2
368
+ 11:06:35 AM web.1 | [18878] * Preloading application
369
+ ```
370
+
371
+ Looks good, so press `Ctrl+C` to exit and you can deploy your changes to Heroku:
372
+
373
+ ```term
374
+ :::> $ git add .
375
+ :::> $ git commit -m "use puma via procfile"
376
+ :::> $ git push heroku master
377
+ ```
378
+
379
+ Check `ps`. You'll see that the web process uses your new command specifying Puma as the web server.
380
+
381
+ ```term
382
+ :::>> $ heroku ps
383
+ ```
384
+
385
+ The logs also reflect that we are now using Puma.
386
+
387
+ ```term
388
+ $ heroku logs
389
+ ```
390
+
391
+ ## Rails asset pipeline
392
+
393
+ There are several options for invoking the [Rails asset pipeline](http://guides.rubyonrails.org/asset_pipeline.html) when deploying to Heroku. For general information on the asset pipeline please see the [Rails 3.1+ Asset Pipeline on Heroku Cedar](rails-asset-pipeline) article.
394
+
395
+ The `config.assets.initialize_on_precompile` option has been removed is and not needed for Rails 5. Also, any failure in asset compilation will now cause the push to fail. For Rails 5 asset pipeline support see the [Ruby Support](https://devcenter.heroku.com/articles/ruby-support#rails-5-x-applications) page.
396
+
397
+ ## Troubleshooting
398
+
399
+ If you push up your app and it crashes (`heroku ps` shows state `crashed`), check your logs to find out what went wrong. Here are some common problems.
400
+
401
+ ### Runtime dependencies on development/test gems
402
+
403
+ If you're missing a gem when you deploy, check your Bundler groups. Heroku builds your app without the `development` or `test` groups, and if your app depends on a gem from one of these groups to run, you should move it out of the group.
404
+
405
+ One common example is using the RSpec tasks in your `Rakefile`. If you see this in your Heroku deploy:
406
+
407
+ ```term
408
+ $ heroku run rake -T
409
+ Running `bundle exec rake -T` attached to terminal... up, ps.3
410
+ rake aborted!
411
+ no such file to load -- rspec/core/rake_task
412
+ ```
413
+ Then you've hit this problem. First, duplicate the problem locally:
414
+
415
+ ```term
416
+ $ bundle install --without development:test
417
+
418
+ $ bundle exec rake -T
419
+ rake aborted!
420
+ no such file to load -- rspec/core/rake_task
421
+ ```
422
+
423
+ > Note: The `--without` option on bundler is sticky. You can get rid of this option by running `bundle config --delete without`.
424
+
425
+ Now you can fix it by making these Rake tasks conditional on the gem load. For example:
426
+
427
+ ```ruby
428
+ begin
429
+ require "rspec/core/rake_task"
430
+
431
+ desc "Run all examples"
432
+
433
+ RSpec::Core::RakeTask.new(:spec) do |t|
434
+ t.rspec_opts = %w[--color]
435
+ t.pattern = 'spec/**/*_spec.rb'
436
+ end
437
+ rescue LoadError
438
+ end
439
+ ```
440
+
441
+ Confirm it works locally, then push to Heroku.
442
+
443
+ ## Done
444
+
445
+ You have deployed your first application to Heroku. The next step is to deploy your own application. You can read more about Ruby on Heroku at the [Dev Center](https://devcenter.heroku.com/categories/ruby).
@@ -15,8 +15,8 @@ class AppendFileTest < Test::Unit::TestCase
15
15
 
16
16
  result = File.read(file)
17
17
 
18
- assert_match /foo/, result
19
- assert_match /bar/, result
18
+ assert_match(/foo/, result)
19
+ assert_match(/bar/, result)
20
20
 
21
21
  cc = Rundoc::CodeCommand::FileCommand::Append.new(file)
22
22
  cc << "baz"
@@ -29,14 +29,14 @@ class AppendFileTest < Test::Unit::TestCase
29
29
  end
30
30
  end
31
31
 
32
- def test_appends_to_a_file_at_line_number
32
+ def test_appends_to_a_file_at_line_number
33
33
  Dir.mktmpdir do |dir|
34
34
  Dir.chdir(dir) do
35
35
 
36
- contents = <<-CONTENTS
36
+ contents = <<-CONTENTS
37
37
  source 'https://rubygems.org'
38
38
  gem 'rails', '4.0.0'
39
- CONTENTS
39
+ CONTENTS
40
40
 
41
41
  file = "foo.rb"
42
42
  line = 2
@@ -52,4 +52,31 @@ CONTENTS
52
52
  end
53
53
  end
54
54
 
55
+ def test_globs_filenames
56
+ Dir.mktmpdir do |dir|
57
+ Dir.chdir(dir) do
58
+ filename = "file-#{Time.now.utc.strftime("%Y%m%d%H%M%S")}.txt"
59
+ FileUtils.touch(filename)
60
+ cc = Rundoc::CodeCommand::FileCommand::Append.new("file-*.txt")
61
+ cc << "some text"
62
+ cc.call
63
+
64
+ assert_equal "\nsome text\n", File.read(filename)
65
+ end
66
+ end
67
+ end
68
+
69
+ def test_glob_multiple_matches_raises
70
+ Dir.mktmpdir do |dir|
71
+ Dir.chdir(dir) do
72
+ FileUtils.touch("file-1234.txt")
73
+ FileUtils.touch("file-5678.txt")
74
+ assert_raise do
75
+ cc = Rundoc::CodeCommand::FileCommand::Append.new("file-*.txt")
76
+ cc << "some text"
77
+ cc.call
78
+ end
79
+ end
80
+ end
81
+ end
55
82
  end
@@ -21,14 +21,13 @@ class RemoveContentsTest < Test::Unit::TestCase
21
21
  @file = "foo.rb"
22
22
  `echo "#{@gemfile}" >> #{@file}`
23
23
 
24
- assert_match /sqlite3/, File.read(@file)
24
+ assert_match(/sqlite3/, File.read(@file))
25
25
 
26
26
  cc = Rundoc::CodeCommand::FileCommand::Remove.new(@file)
27
27
  cc << "gem 'sqlite3'"
28
28
  cc.call
29
29
 
30
- result = File.read(@file)
31
- refute_match /sqlite3/, File.read(@file)
30
+ refute_match(/sqlite3/, File.read(@file))
32
31
 
33
32
  env = {}
34
33
  env[:commands] = []
@@ -39,4 +39,96 @@ RUBY
39
39
  assert_equal contents, result
40
40
  end
41
41
 
42
+ def test_show_command_hide_render
43
+ contents = <<-RUBY
44
+ ```
45
+ :::> $ echo "foo"
46
+ ```
47
+ RUBY
48
+
49
+ match = contents.match(Rundoc::Parser::CODEBLOCK_REGEX)
50
+ code_section = Rundoc::CodeSection.new(match, keyword: ":::")
51
+ code_section.render
52
+
53
+ code_command = code_section.commands.first
54
+ assert_equal true, code_command.render_command
55
+ assert_equal false, code_command.render_result
56
+
57
+ contents = <<-RUBY
58
+ ```
59
+ :::>- $ echo "foo"
60
+ ```
61
+ RUBY
62
+
63
+ match = contents.match(Rundoc::Parser::CODEBLOCK_REGEX)
64
+ code_section = Rundoc::CodeSection.new(match, keyword: ":::")
65
+ code_section.render
66
+
67
+ code_command = code_section.commands.first
68
+ assert_equal true, code_command.render_command
69
+ assert_equal false, code_command.render_result
70
+ end
71
+
72
+ def test_show_command_show_render
73
+ contents = <<-RUBY
74
+ ```
75
+ :::>> $ echo "foo"
76
+ ```
77
+ RUBY
78
+
79
+ match = contents.match(Rundoc::Parser::CODEBLOCK_REGEX)
80
+ code_section = Rundoc::CodeSection.new(match, keyword: ":::")
81
+ code_section.render
82
+
83
+ code_command = code_section.commands.first
84
+ assert_equal true, code_command.render_command
85
+ assert_equal true, code_command.render_result
86
+ end
87
+
88
+ def test_hide_command_hide_render
89
+ contents = <<-RUBY
90
+ ```
91
+ :::- $ echo "foo"
92
+ ```
93
+ RUBY
94
+
95
+ match = contents.match(Rundoc::Parser::CODEBLOCK_REGEX)
96
+ code_section = Rundoc::CodeSection.new(match, keyword: ":::")
97
+ code_section.render
98
+
99
+ code_command = code_section.commands.first
100
+ assert_equal false, code_command.render_command
101
+ assert_equal false, code_command.render_result
102
+
103
+ contents = <<-RUBY
104
+ ```
105
+ :::-- $ echo "foo"
106
+ ```
107
+ RUBY
108
+
109
+ match = contents.match(Rundoc::Parser::CODEBLOCK_REGEX)
110
+ code_section = Rundoc::CodeSection.new(match, keyword: ":::")
111
+ code_section.render
112
+
113
+ code_command = code_section.commands.first
114
+ assert_equal false, code_command.render_command
115
+ assert_equal false, code_command.render_result
116
+ end
117
+
118
+ def test_hide_command_show_render
119
+ contents = <<-RUBY
120
+ ```
121
+ :::-> $ echo "foo"
122
+ ```
123
+ RUBY
124
+
125
+ match = contents.match(Rundoc::Parser::CODEBLOCK_REGEX)
126
+ code_section = Rundoc::CodeSection.new(match, keyword: ":::")
127
+ code_section.render
128
+
129
+ code_command = code_section.commands.first
130
+ assert_equal false, code_command.render_command
131
+ assert_equal true, code_command.render_result
132
+ end
133
+
42
134
  end
@@ -10,8 +10,8 @@ class ParserTest < Test::Unit::TestCase
10
10
  sup
11
11
 
12
12
  ```
13
- ::: $ mkdir foo
14
- :::= $ ls
13
+ :::> $ mkdir foo
14
+ :::>> $ ls
15
15
  ```
16
16
 
17
17
  yo
@@ -39,7 +39,7 @@ RUBY
39
39
  sup
40
40
 
41
41
  ```
42
- :::= write foo/code.rb
42
+ :::>> write foo/code.rb
43
43
  a = 1 + 1
44
44
  b = a * 2
45
45
  ```
@@ -60,9 +60,9 @@ RUBY
60
60
  contents = <<-RUBY
61
61
 
62
62
  ```
63
- :::= write foo/newb.rb
63
+ :::>> write foo/newb.rb
64
64
  puts 'hello world'
65
- :::= $ cat foo/newb.rb
65
+ :::>> $ cat foo/newb.rb
66
66
  ```
67
67
  RUBY
68
68
 
@@ -81,7 +81,7 @@ RUBY
81
81
 
82
82
  contents = <<-RUBY
83
83
  ```
84
- :::= irb --simple-prompt
84
+ :::>> irb --simple-prompt
85
85
  a = 3
86
86
  b = "foo" * a
87
87
  puts b
@@ -100,13 +100,13 @@ RUBY
100
100
  foo
101
101
 
102
102
  ```
103
- :::$ mkdir
103
+ :::>$ mkdir
104
104
  ```
105
105
 
106
106
  zoo
107
107
 
108
108
  ```
109
- :::$ cd ..
109
+ :::>$ cd ..
110
110
  something
111
111
  ```
112
112
 
@@ -117,8 +117,8 @@ RUBY
117
117
 
118
118
  actual = contents.partition(regex)
119
119
  expected = ["foo\n\n",
120
- "```\n:::$ mkdir\n```\n",
121
- "\nzoo\n\n```\n:::$ cd ..\nsomething\n```\n\nbar\n"]
120
+ "```\n:::>$ mkdir\n```\n",
121
+ "\nzoo\n\n```\n:::>$ cd ..\nsomething\n```\n\nbar\n"]
122
122
 
123
123
  assert_equal expected, actual
124
124
 
@@ -137,7 +137,7 @@ RUBY
137
137
 
138
138
  contents = <<-RUBY
139
139
  ```java
140
- :::= write app/controllers/Application.java
140
+ :::>> write app/controllers/Application.java
141
141
  package controllers;
142
142
 
143
143
  import static java.util.concurrent.TimeUnit.SECONDS;
data/test/test_helper.rb CHANGED
@@ -11,5 +11,3 @@ require 'tmpdir'
11
11
 
12
12
  def assert_tests_run
13
13
  end
14
-
15
-