Sha256: 8c1767f9327ab22bf43a27dd8b68fa2fc8929130b4826d3d5529f1468e350a0f

Contents?: true

Size: 1.11 KB

Versions: 14

Compression:

Stored size: 1.11 KB

Contents

#encoding: utf-8
require File.join(File.dirname(__FILE__), "../../spec_helper")
include Nudge

describe CodeFromNameInstruction do
  
  it_should_behave_like "every Nudge Instruction"
  
  before(:each) do
    @context = Interpreter.new
    @i1 = CodeFromNameInstruction.new(@context)
    @context.clear_stacks
  end
  
  it "should check that there are enough parameters" do
    @context.stacks[:name].push(ReferencePoint.new("foo"))
    @i1.preconditions?.should == true
  end
  
  it "should raise an error if the preconditions aren't met" do
    @context.clear_stacks # there are no params at all
    lambda{@i1.preconditions?}.should raise_error(Instruction::NotEnoughStackItems)
  end
  
  it "should successfully run #go only if all preconditions are met" do
    @context.stacks[:name].push(ReferencePoint.new("foo"))
    @i1.should_receive(:cleanup)
    @i1.go
  end
  
  it "should create and push the new (expected) value to the right place" do
    @context.stacks[:name].push(ReferencePoint.new("foo"))
    @i1.go
    @context.stacks[:name].depth.should == 0
    @context.stacks[:code].peek.value.should == "ref foo"
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
nudge-0.2.9 spec/instructions/code/code_from_name_spec.rb
nudge-0.2.8 spec/instructions/code/code_from_name_spec.rb
nudge-0.2.7 spec/instructions/code/code_from_name_spec.rb
nudge-0.2.6 spec/instructions/code/code_from_name_spec.rb
nudge-0.2.5 spec/instructions/code/code_from_name_spec.rb
nudge-0.2.4 spec/instructions/code/code_from_name_spec.rb
nudge-0.2.3 spec/instructions/code/code_from_name_spec.rb
nudge-0.2.2 spec/instructions/code/code_from_name_spec.rb
nudge-0.2.1 spec/instructions/code/code_fromname_spec.rb
nudge-0.2.0 spec/instructions/code/code_fromname_spec.rb
nudge-0.1.3 spec/instructions/code/code_fromname_spec.rb
nudge-0.1.2 spec/instructions/code/code_fromname_spec.rb
nudge-0.1.1 spec/instructions/code/code_fromname_spec.rb
nudge-0.1.0 spec/instructions/code/code_fromname_spec.rb