Sha256: 4457981769e2f3f819cba811b64263c103348730ba058b39c396de3f7b226dc5
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
require 'spec_helper' describe 'misc examples' do include FixturesHelper include ProcessHelper # http://stackoverflow.com/questions/450799/shell-command-to-sum-integers-one-per-line context "summing integers" do it "sums" do lines = (1..10).to_a.map(&:to_s) out = run(lines, 'map(:to_i).sum') out.should == '55' end end # http://stackoverflow.com/questions/6022384/bash-tool-to-get-nth-line-from-a-file context "printing the nth line" do it "prints" do lines = (1..10).to_a.map(&:to_s) out = run(lines, '[4]') out.should == '5' end end # https://coderwall.com/p/ueazhw context "sorting an Apache access log by response time" do it "sorts" do file = fixture_path('files', 'access.log') out = run('', 'map { |line| [line[/(\d+)( ".+"){2}$/, 1].to_i, line] }.sort.reverse.map(:join, " ")', file) out.should == <<-EOF.strip 584912 66.249.64.14 - - [18/Sep/2004:11:07:48 +1000] "GET /file.txt HTTP/1.0" 200 584912 "-" "Googlebot/2.1" 6433 66.249.64.14 - - [18/Sep/2004:11:07:48 +1000] "GET / HTTP/1.0" 200 6433 "-" "Googlebot/2.1" 6433 66.249.64.13 - - [18/Sep/2004:11:07:48 +1000] "GET / HTTP/1.0" 200 6433 "-" "Googlebot/2.1" 468 66.249.64.14 - - [18/Sep/2004:11:07:48 +1000] "GET /robots.txt HTTP/1.0" 200 468 "-" "Googlebot/2.1" 468 66.249.64.13 - - [18/Sep/2004:11:07:48 +1000] "GET /robots.txt HTTP/1.0" 200 468 "-" "Googlebot/2.1" EOF end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
ru-0.0.3 | spec/examples/misc_examples_spec.rb |
ru-0.0.2 | spec/examples/misc_examples_spec.rb |
rushed-0.0.2 | spec/examples/misc_examples_spec.rb |