Skip to content

Commit

Permalink
Standardize some tests
Browse files Browse the repository at this point in the history
Separated testing of adapters 4 and 5 so that they are like all of the
other adapters.
  • Loading branch information
enkessler committed May 26, 2020
1 parent d3813f4 commit aa0a9d6
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "#{File.dirname(__FILE__)}/../../spec_helper"


describe 'Gherkin4Adapter, Integration', :if => gherkin?(4, 5) do
describe 'Gherkin4Adapter, Integration', :if => gherkin?(4) do

let(:clazz) { CukeModeler::Gherkin4Adapter }
let(:adapter) { clazz.new }
Expand Down
165 changes: 165 additions & 0 deletions testing/rspec/spec/integration/adapters/gherkin_5_adapter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
require "#{File.dirname(__FILE__)}/../../spec_helper"


describe 'Gherkin4Adapter, Integration', :if => gherkin?(5) do

let(:clazz) { CukeModeler::Gherkin5Adapter }
let(:adapter) { clazz.new }
let(:source_text) { "# feature comment
@tag1 @tag2 @tag3
#{FEATURE_KEYWORD}: A feature with everything it could have
Including a description
and then some.
# background comment
#{BACKGROUND_KEYWORD}:
Background
description
#{STEP_KEYWORD} a step
# table comment
| value1 |
# table row comment
| value2 |
#{STEP_KEYWORD} another step
# scenario comment
@scenario_tag
#{SCENARIO_KEYWORD}:
Scenario
description
#{STEP_KEYWORD} a step
#{STEP_KEYWORD} another step
\"\"\"
some text
\"\"\"
# outline comment
@outline_tag
#{OUTLINE_KEYWORD}:
Outline
description
# step comment
#{STEP_KEYWORD} a step
# table comment
| value2 |
# step comment
#{STEP_KEYWORD} another step
# doc string comment
\"\"\"
some text
\"\"\"
# example comment
@example_tag
#{EXAMPLE_KEYWORD}:
Example
description
# row comment
| param |
| value |
# final comment" }
let(:feature_file_model) { test_file_path = CukeModeler::FileHelper.create_feature_file(:text => source_text, :name => 'adapter_test_file')
CukeModeler::FeatureFile.new(test_file_path) }
let(:feature_model) { feature_file_model.feature }


it "does not store parsing data for a feature file's children" do
model = feature_file_model

expect(model.parsing_data[:comments]).to be_nil
expect(model.parsing_data[:feature]).to be_nil
end

it "does not store parsing data for a feature's children" do
model = feature_model

expect(model.parsing_data[:tags]).to be_nil
expect(model.parsing_data[:children]).to be_nil
end

it "does not store parsing data for a background's children" do
model = feature_model.background

expect(model.parsing_data[:steps]).to be_nil
end

it "does not store parsing data for a scenario's children" do
model = feature_model.scenarios.first

expect(model.parsing_data[:tags]).to be_nil
expect(model.parsing_data[:steps]).to be_nil
end

it "does not store parsing data for an outline's children" do
model = feature_model.outlines.first

expect(model.parsing_data[:tags]).to be_nil
expect(model.parsing_data[:steps]).to be_nil
expect(model.parsing_data[:examples]).to be_nil
end

it "does not store parsing data for an example's children" do
model = feature_model.outlines.first.examples.first

expect(model.parsing_data[:tags]).to be_nil
expect(model.parsing_data[:tableHeader]).to be_nil
expect(model.parsing_data[:tableBody]).to be_nil
end

it "does not store parsing data for an example row's children" do
model = feature_model.outlines.first.examples.first.rows.first

expect(model.parsing_data[:cells]).to be_nil
end

it "does not store parsing data for a step's children, table" do
model = feature_model.outlines.first.steps.first

expect(model.parsing_data[:argument]).to be_nil
end

it "does not store parsing data for a step's children, doc string" do
model = feature_model.outlines.first.steps.last

expect(model.parsing_data[:argument]).to be_nil
end

it "does not store parsing data for a table's children" do
model = feature_model.outlines.first.steps.first.block

expect(model.parsing_data[:rows]).to be_nil
end

it "does not store parsing data for a table row's children" do
model = feature_model.outlines.first.steps.first.block.rows.first

expect(model.parsing_data[:cells]).to be_nil
end


describe 'stuff that is in no way part of the public API and entirely subject to change' do

it 'provides a useful explosion message if it encounters an entirely new type of test' do
partial_feature_ast = { :type => :Feature, :location => { :line => 1, :column => 1 }, :children => [{ :type => :some_unknown_type }] }

expect { adapter.adapt_feature!(partial_feature_ast) }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
end

it 'provides a useful explosion message if it encounters an entirely new type of step block' do
partial_feature_ast = { :type => :Feature, :location => { :line => 1, :column => 1 }, :children => [{ :type => :Scenario, :tags => [], :location => { :line => 1, :column => 1 }, :steps => [{ :type => :Step, :location => { :line => 1, :column => 1 }, :argument => { :type => :some_unknown_type, :location => { :line => 1, :column => 1 }, :content => "" } }] }] }

expect { adapter.adapt_feature!(partial_feature_ast) }.to raise_error(ArgumentError, /Unknown.*some_unknown_type/)
end

end

end

0 comments on commit aa0a9d6

Please sign in to comment.