spec/str_spec.rb in raabro-0.9.0 vs spec/str_spec.rb in raabro-1.0.0
- old
+ new
@@ -8,66 +8,70 @@
require 'spec_helper'
describe Raabro do
- before :each do
-
- @input = Raabro::Input.new('toto')
- end
-
describe '.str' do
it 'returns a tree with result == 0 in case of failure' do
- t = Raabro.str(nil, @input, 'nada')
+ i = Raabro::Input.new('toto')
+ t = Raabro.str(nil, i, 'nada')
+
expect(t.to_a).to eq(
[ nil, 0, 0, 0, nil, :str, [] ]
)
- expect(@input.offset).to eq(0)
+ expect(i.offset).to eq(0)
end
it "returns a tree with result == 1 in case of success" do
- t = Raabro.str(nil, @input, 'toto')
+ i = Raabro::Input.new('toto')
+ t = Raabro.str(nil, i, 'toto')
+
expect(t.to_a).to eq(
[ nil, 1, 0, 4, nil, :str, [] ]
)
- expect(@input.offset).to eq(4)
+ expect(i.offset).to eq(4)
end
it "names the result if there is a name" do
- t = Raabro.str(:x, @input, 'toto')
+ i = Raabro::Input.new('toto')
+ t = Raabro.str(:x, i, 'toto')
+
expect(t.to_a).to eq(
[ :x, 1, 0, 4, nil, :str, [] ]
)
- expect(@input.offset).to eq(4)
+ expect(i.offset).to eq(4)
end
it "names in case of failure as well" do
- t = Raabro.str(:y, @input, 'nada')
+ i = Raabro::Input.new('toto')
+ t = Raabro.str(:y, i, 'nada')
+
expect(t.to_a).to eq(
[ :y, 0, 0, 0, nil, :str, [] ]
)
- expect(@input.offset).to eq(0)
+ expect(i.offset).to eq(0)
end
it "accepts an empty input" do
- @input.offset = 4
+ i = Raabro::Input.new('toto')
+ i.offset = 4
- t = Raabro.str(nil, @input, 'nada')
+ t = Raabro.str(nil, i, 'nada')
expect(t.to_a).to eq(
[ nil, 0, 4, 0, nil, :str, [] ]
)
- expect(@input.offset).to eq(4)
+ expect(i.offset).to eq(4)
end
end
end