Skip to content

Commit

Permalink
Merge pull request #1 from jchuerva/add_reverse_geo
Browse files Browse the repository at this point in the history
Add reverse geo
  • Loading branch information
jchuerva authored Oct 22, 2017
2 parents 2e8b3e9 + 644b0be commit 5b97c88
Show file tree
Hide file tree
Showing 25 changed files with 904 additions and 3,723 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ Gemfile.lock
.bundle
.ruby-version
=.vendor/*
.idea/
.idea/
tmp_reports/*
reports/*
report.html
28 changes: 15 additions & 13 deletions .idea/testingGoogleGeocodingAPI.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3,774 changes: 333 additions & 3,441 deletions .idea/workspace.xml

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This is the configuration used to check the rubocop source code.

AllCops:
Exclude:
# Currently excluded for future investigation
- '**/hooks.rb'
- '**/env.rb'
- '**/http_util.rb'
- 'features/step_definitions/helpers/table_transform.rb'

################## Customized rules ##################

Metrics/LineLength:
Max: 150
Exclude:
- '**/long-text.rb'

Metrics/AbcSize:
Max: 30

Metrics/MethodLength:
Max: 15

Metrics/BlockLength:
Max: 30

Style/RegexpLiteral:
EnforcedStyle: slashes
AllowInnerSlashes: true

# Waiting for answer regarding snake_case or kebab-case use in FileNames
Style/FileName:
Enabled: false

# Investigate Carriage error
EndOfLine:
Enabled: false
10 changes: 2 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ gem 'httparty'
gem 'rspec', '>=3.4'
gem 'rspec-expectations', '=3.4.0'
gem 'rake', '10.4.0'
gem 'cukeforker', '=1.1.0'
gem 'faraday'
#gem 'typhoeus'


gem 'parallel_tests'
gem 'jsonpath'

gem 'report_builder','=0.1.4'
#gem 'cuke_sniffer', '=0.0.8'
gem 'report_builder', '=0.1.4'
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ GEM
cucumber (>= 2.0.0)
vnctools (>= 0.0.5)
diff-lcs (1.3)
faraday (0.13.1)
multipart-post (>= 1.2, < 3)
ffi (1.9.18)
gherkin (4.1.3)
httparty (0.15.6)
Expand All @@ -31,7 +29,9 @@ GEM
multi_json (1.12.2)
multi_test (0.1.2)
multi_xml (0.6.0)
multipart-post (2.0.0)
parallel (1.12.0)
parallel_tests (2.17.0)
parallel
rake (10.4.0)
report_builder (0.1.4)
builder (~> 3.2, >= 3.2.2)
Expand All @@ -58,9 +58,9 @@ PLATFORMS
DEPENDENCIES
cucumber (= 2.4.0)
cukeforker (= 1.1.0)
faraday
httparty
jsonpath
parallel_tests
rake (= 10.4.0)
report_builder (= 0.1.4)
rspec (>= 3.4)
Expand Down
64 changes: 27 additions & 37 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,55 +1,45 @@
# encoding: utf-8

#require 'rubygems'
require 'cucumber'
require 'cucumber/rake/task'

require 'cukeforker'
require 'cukeforker/rake_task'
require 'jsonpath'

#require 'cuke_sniffer'

require 'report_builder'

task "move_to_test_directory" do
Dir.chdir('features')
end
processes = ENV['processes'] || 10

Cucumber::Rake::Task.new("running_geo_api_tests") do |t|
# t.cucumber_opts = ["--tags", "@carlos", "--tags", "~@pend", "--format", "html", "--out", "report.html", "--format", "junit", "--out", "testoutput", "--format", "pretty", "--format", "rerun", "--out", "rerun.txt"]
Cucumber::Rake::Task.new('running_geo_api_tests') do |t|
#t.cucumber_opts = ["--tags", "@carlos", "--tags", "~@pend", "--format", "report/report.html", "--out", "report.html", "--format", "junit", "--out", "testoutput", "--format", "pretty", "--format", "rerun", "--out", "rerun.txt"]
t.cucumber_opts = ["--tags", "@carlos"]
end

# Cucumber::Rake::Task.new("running_parallel_geo_api_tests") do
# CukeForker::Runner.run CukeForker::Scenarios.all
# #extra_args: %W[-f CukeForker::Formatters::JunitScenarioFormatter --out results/junit]
# end
Cucumber::Rake::Task.new('running_all_tests') do |t|
t.cucumber_opts = ["--tags", "~@pend", "--format", "html", "--out", "report.html", "--format", "junit", "--out", "testoutput", "--format", "pretty"]
end

task :cleanup_cuke_forker do
puts " ========Deleting old reports and logs========="
#FileUtils.rm_rf('reports/test_report')
Dir.mkdir("features/reports/test_report")
task 'prepare_parallel_report' do
FileUtils.rm_rf('reports')
Dir.mkdir('reports')

puts "configure reportbuilder"
ReportBuilder.configure do |config|
config.json_path = 'reports/test_report'
config.report_path = 'reports/test_report'
config.report_tabs = [:overview, :features, :scenarios, :errors]
config.json_path = 'tmp_reports'
config.report_path = 'reports/reports'
config.report_types = [:json, :html]
config.report_tabs = [:overview, :features, :scenarios, :errors]
config.report_title = 'Test Results'
config.report
end
end

task :all do
Rake::Task['cleanup_cuke_forker'].invoke
puts "===== Executing Tests in parallel"
task 'create_report' do
ReportBuilder.build_report
FileUtils.rm_rf('tmp_reports')
end

Dir.chdir('features/')
task 'parallel_all_tests' do
Rake.application.invoke_task('prepare_parallel_report')

CukeForker::Runner.run CukeForker::Scenarios.tagged('@carlos'), {:max => 10,
:log => true, :format => :json, :out => 'reports/test_report'}
puts "===== End Executing Tests in parallel"
puts "===== Executing report"
ReportBuilder.build_report
puts "===== End Executing report"
FileUtils.rm_rf('tmp_reports')
Dir.mkdir('tmp_reports')

end
system "bundle exec parallel_cucumber -n #{processes} features/ -o \'-p parallel -f json -o tmp_reports/feature$TEST_ENV_NUMBER.json \'"
#system "bundle exec parallel_cucumber features/ -o \"-r features -p parallel \" -n #{processes} " or exit!($?.exitstatus)
Rake.application.invoke_task('create_report')
end
4 changes: 4 additions & 0 deletions config/cucumber.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# cucumber.yml
##YAML Template

parallel: -f progress -f ParallelTests::Cucumber::FailuresLogger --out tmp_reports/cucumber_failures.log
20 changes: 0 additions & 20 deletions features/aditional_parameters.feature

This file was deleted.

34 changes: 34 additions & 0 deletions features/geocoding/geocoding_components_params.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@ok
Feature: Cover the happy path case

Scenario Outline: valid components
When I successfully browse to the url
| parameter | value |
| components | <components_value> |
Then I see response with status 'OK'
And I see <num_results> result in the response
And I see first response formatted_address '<formatted_address>'
And I see first response contains '<location_type>' geographic coordinates

Examples:
| components_value | formatted_address | location_type | num_results |
| route:Annegatan | Annankatu, 00101 Helsinki, Finland | GEOMETRIC_CENTER | 1 |
| locality:La Palma | La Palma, CA, USA | APPROXIMATE | 1 |
| administrative_area:Huelva | Huelva, Spain | APPROXIMATE | 1 |
| postal_code:94107 | San Francisco, CA 94107, USA | APPROXIMATE | 1 |
| country:Spain | Spain | APPROXIMATE | 1 |
| locality:La Palma \|country:Spain | 30593 La Palma, Murcia, Spain | APPROXIMATE | 2 |
| locality:La Palma \|administrative_area:Huelva | 21700 La Palma del Condado, Huelva, Spain | APPROXIMATE | 1 |
| locality:La Palma \|administrative_area:Huelva \|country:Spain | 21700 La Palma del Condado, Huelva, Spain | APPROXIMATE | 1 |

Scenario: valid Address and components
When I successfully browse to the url
| parameter | value |
| address | 6 Mozarabes |
| components | administrative_area:Huelva\|postal_code:21002 |
Then I see response with status 'OK'
And I see 1 result in the response
And I see first response contains an address_component
| type | attribute | value |
| administrative_area_level_2 | short_name | Huelva |
And I see first response contains 'ROOFTOP' geographic coordinates
76 changes: 76 additions & 0 deletions features/geocoding/geocoding_mandatory_params.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
@ok
Feature: Cover the happy path case

Scenario Outline: valid Address
When I successfully browse to the url
| parameter | value |
| address | <address_value> |
Then I see response with status 'OK'
And I see <num_results> result in the response
And I see first response formatted_address '<formatted_address>'
And I see first response contains '<location_type>' geographic coordinates

Examples:
| address_value | formatted_address | location_type | num_results |
| 88+Colin+P+Kelly+Jr+St,+San+Francisco | 88 Colin P Kelly Jr St, San Francisco, CA 94107, USA | ROOFTOP | 1 |
| 88 Colin P Kelly Jr St,+San Francisco | 88 Colin P Kelly Jr St, San Francisco, CA 94107, USA | ROOFTOP | 1 |
| 94107 | San Francisco, CA 94107, USA | APPROXIMATE | 1 |
| San Francisco | San Francisco, CA, USA | APPROXIMATE | 1 |
| 94107, San Francisco | San Francisco, CA 94107, USA | APPROXIMATE | 1 |
| 94107, California | San Francisco, CA 94107, USA | APPROXIMATE | 1 |
| Co Road 182 | Co Rd 182, Bennett, CO 80102, USA | GEOMETRIC_CENTER | 9 |
| Andalucia | Andalusia, Spain | APPROXIMATE | 1 |
| Spain A42 | A-42, Spain | GEOMETRIC_CENTER | 1 |
| Interstate 280 | I-280, California, USA | GEOMETRIC_CENTER | 1 |

Scenario: several responses
When I successfully browse to the url
| parameter | value |
| address | Calle Real |
| components | country:Spain |
And I see 'GEOMETRIC_CENTER' response contains a formatted_address 'Calle Real, San Sebastián de los Reyes, Madrid, Spain'
And I see all results contains an address_component
| type | attribute | value |
| country | short_name | ES |

Scenario Outline: several address
When I successfully browse to the url
| parameter | value |
| address | <address> |
| components | administrative_area:Huelva\|country:Spain |
Then I see response with status 'OK'
And I see 1 result in the response
And I see first response formatted_address '<formatted_address>'
And I see first response contains an address_component
| type | attribute | value |
| administrative_area_level_2 | short_name | Huelva |
And I see first response contains 'GEOMETRIC_CENTER' geographic coordinates

Examples:
| address | formatted_address |
| calle 6 Mozarabes \| calle puerto | Calle Puerto, Huelva, Spain |
| calle puerto \| calle los mozarabes | Calle los Mozárabes, 21002 Huelva, Spain |

Scenario: several address
When I successfully browse to the url
| parameter | value |
| address | calle 6 Mozarabes |
| address | calle puerto |
| components | administrative_area:Huelva\|country:Spain |
Then I see response with status 'OK'
And I see 1 result in the response
And I see first response formatted_address 'Huelva, Spain'
And I see first response contains an address_component
| type | attribute | value |
| administrative_area_level_2 | short_name | Huelva |
And I see first response contains 'APPROXIMATE' geographic coordinates

Scenario: region additional parameters
When I successfully browse to the url
| parameter | value |
| address | 1025 Los Mozarabes |
| components | administrative_area:Huelva\|country:Spain |
Then I see response with status 'OK'
And I see 1 result in the response
And I see first results is partial_match
And I see first response formatted_address 'Calle los Mozárabes, 21002 Huelva, Spain'
Loading

0 comments on commit 5b97c88

Please sign in to comment.