Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 40 lines (31 sloc) 1.243 kb
957c2c9 @brixen Standardize require lines.
brixen authored
1 require File.expand_path('../../spec_helper', __FILE__)
a0f35ab @jredville First pass at command line specs for:
jredville authored
2
3 describe "The -e command line option" do
4 it "evaluates the given string" do
5 ruby_exe("puts 'foo'").chomp.should == "foo"
6 end
7
8 it "joins multiple strings with newlines" do
5c0e696 @vvs Tweak -e spec a bit to execute it always via shell
vvs authored
9 ruby_exe(nil, :args => %Q{-e "puts 'hello" -e "world'" 2>&1}).chomp.should == "hello\nworld"
a0f35ab @jredville First pass at command line specs for:
jredville authored
10 end
11
12 it "uses 'main' as self" do
13 ruby_exe("puts self").chomp.should == "main"
14 end
15
16 it "uses '-e' as file" do
17 ruby_exe("puts __FILE__").chomp.should == "-e"
18 end
19
20 #needs to test return => LocalJumpError
1c946dd @mrkn Adding some specs for describing the conditional range notation.
mrkn authored
21
f834b15 @brixen Simplify -e conditional range specs.
brixen authored
22 ruby_version_is "1.8.7.248" do
23 describe "with -n and a Fixnum range" do
24 before :each do
25 @script = "-ne 'print if %s' #{fixture(__FILE__, "conditional_range.txt")}"
26 end
27
28 it "mimics an awk conditional by comparing an inclusive-end range with $." do
29 ruby_exe(nil, :args => (@script % "2..3")).should == "2\n3\n"
30 ruby_exe(nil, :args => (@script % "2..2")).should == "2\n"
31 end
32
33 it "mimics a sed conditional by comparing an exclusive-end range with $." do
34 ruby_exe(nil, :args => (@script % "2...3")).should == "2\n3\n"
35 ruby_exe(nil, :args => (@script % "2...2")).should == "2\n3\n4\n5\n"
36 end
37 end
1c946dd @mrkn Adding some specs for describing the conditional range notation.
mrkn authored
38 end
39 end
Something went wrong with that request. Please try again.