-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separated testing of adapters 4 and 5 so that they are like all of the other adapters.
- Loading branch information
Showing
2 changed files
with
166 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
testing/rspec/spec/integration/adapters/gherkin_4_adapter_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 165 additions & 0 deletions
165
testing/rspec/spec/integration/adapters/gherkin_5_adapter_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |