Sha256: 0f797fc7204797567826be14f0c8e0ba838c12e85e35796fb289990824052420
Contents?: true
Size: 1.77 KB
Versions: 2
Compression:
Stored size: 1.77 KB
Contents
require 'logirel/q_model' describe Logirel::StrQ, "in its default mode of operation, when reading props" do before(:each) { @q = StrQ.new "Q??", "def" } subject { @q } it { should respond_to :question } it { should respond_to :default } specify { @q.answer.should eql("def") } specify { @q.question.should eql("Q??") } end describe Logirel::StrQ, "when feeding it OK input" do before(:each) do @io = StringIO.new "My Answer" @out = StringIO.new @validator = double('validator') @validator.should_receive(:call).once. with(an_instance_of(String)). and_return(true) end subject { StrQ.new("q?", "def", @io, @validator, @out) } specify { subject.exec.should eql("My Answer") and subject.answer.should eql("My Answer") } end describe Logirel::StrQ, "when feeding it bad input" do before(:each) do @io = StringIO.new "My Bad Answer\nAnother Bad Answer\nOKAnswer!" @out = StringIO.new @validator = double('validator') @validator.should_receive(:call).exactly(3).times. with(an_instance_of(String)). and_return(false, false, true) end subject { StrQ.new("q?", "def", @io, @validator, @out) } specify { subject.exec.should == "OKAnswer!" } end describe Logirel::StrQ, "when accepting the defaults" do before(:each) do @io = StringIO.new "\n" @out = StringIO.new @validator = double('validator') @validator.should_receive(:call).never. with(an_instance_of(String)). # the validator should never be called for empty input if we have a default and_return(false) end subject { StrQ.new("q?", "def", @io, @validator, @out) } specify { subject.exec.should eql("def") and subject.answer.should eql("def") } end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
logirel-0.0.14 | spec/queries/string_query_spec.rb |
logirel-0.0.8 | spec/queries/string_query_spec.rb |