diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-02-21 15:38:37 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-02-21 15:38:37 +0300 |
commit | 2c4aa50463ed411b14003f9d929c1e03518953bf (patch) | |
tree | df950739c517127280aa1b301bb884470fe511de /spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb | |
parent | 91a42a1a8f0d4bfc63e41b2f7b29a2b0fee1a60c (diff) |
Implement pipeline expressions parser
Diffstat (limited to 'spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb index 76d0163e44b..7f5f55660be 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb @@ -1,4 +1,40 @@ require 'spec_helper' describe Gitlab::Ci::Pipeline::Expression::Statement do + let(:pipeline) { build(:ci_pipeline) } + let(:text) { '$VAR "text"' } + + subject do + described_class.new(text, pipeline) + end + + describe '#tokens' do + it 'returns raw tokens' do + expect(subject.tokens.size).to eq 2 + end + end + + describe '#lexemes' do + it 'returns an array of syntax lexemes' do + expect(subject.lexemes).to eq %w[variable string] + end + end + + describe '#parse_tree' do + context 'when expression grammar is incorrect' do + it 'raises an error' do + expect { subject.parse_tree } + .to raise_error described_class::ParserError + end + end + + context 'when expression grammar is correct' do + let(:text) { '$VAR == "value"' } + + it 'returns a reverse descent parse tree when using operator' do + expect(subject.parse_tree) + .to be_a Gitlab::Ci::Pipeline::Expression::Equals + end + end + end end |