Skip to content

Commit

Permalink
fix all spec that breaks when i rushing for demo
Browse files Browse the repository at this point in the history
  • Loading branch information
siuying committed Apr 18, 2012
1 parent 66de75d commit eede2ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
8 changes: 4 additions & 4 deletions spec/instant/context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
describe Instant::Context do
it "should log assignment" do
subject.log_assign(:a, "10")
subject.to_s.strip.should == "a = 10"
subject.to_s.strip.should == "a = 10"
end

it "should log assignment inside loop" do
Expand All @@ -24,7 +24,7 @@

subject.loop_end

subject.to_s.strip.should == "a = 10 | 11 | 12"
subject.to_s.strip.should == "a = 10 | 11 | 12"
end

it "should log multiple assignment inside loop" do
Expand All @@ -47,7 +47,7 @@
subject.loop_end

outputs = subject.to_s.split("\n").collect{|l| l.strip}
outputs.should be_include("a = 10 | 11 | 12")
outputs.should be_include("b = A | | C")
outputs.should be_include("a = 10 | 11 | 12")
outputs.should be_include("b = A | | C")
end
end
21 changes: 11 additions & 10 deletions spec/instant/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

context_stub = stub(:context)
context_stub.should_receive(:instance_eval).with(processed_source)

context_stub.should_receive(:close)

Instant::Context.stub(:new => context_stub)
runner = Instant::Runner.new(processor)
runner.run(source)
Expand All @@ -32,10 +33,10 @@
result[:status].should == :error
result[:cause].should == :loop_too_deep
results = result[:result].split("\n")
results[0].strip.should =~ /k = 1/
results[1].strip.should =~ /i = 2/
results[2].strip.should =~ /k = 0 | -1 | -2 | -3 | -4/
results[3].strip.should =~ /i = 0 | 1 | 2 | 3 | 4/
results[0].strip.should =~ /k = 1/
results[1].strip.should =~ /i = 2/
results[2].strip.should =~ /k = 0 | -1 | -2 | -3 | -4/
results[3].strip.should =~ /i = 0 | 1 | 2 | 3 | 4/
end

it "should print output in the while loop" do
Expand All @@ -46,7 +47,7 @@
k = (k - 1)
i = (i + 1)
if k < 10
if k < -10
return k
end
end
Expand All @@ -60,10 +61,10 @@

results.length.should == 4

results[0].strip.should =~ /k = 1/
results[1].strip.should =~ /i = 2/
results[2].strip.should =~ /k = 0 | -1 | -2 | -3 | -4/
results[3].strip.should =~ /i = 0 | 1 | 2 | 3 | 4/
results[0].strip.should =~ /k = 1/
results[1].strip.should =~ /i = 2/
results[2].strip.should =~ /k = 0 | -1 | -2 | -3 | -4/
results[3].strip.should =~ /i = 0 | 1 | 2 | 3 | 4/
end
end
end

0 comments on commit eede2ff

Please sign in to comment.