diff --git a/.gitignore b/.gitignore index 9ac6dfa..7f29dc7 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ # rspec failure tracking .rspec_status -Gemfile.lock .idea/ .DS_Store .byebug_history diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..bc76b85 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,49 @@ +PATH + remote: . + specs: + client-api (0.4.1) + json-schema (~> 2.8) + logger (~> 1.0) + +GEM + remote: https://rubygems.org/ + specs: + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + byebug (11.0.1) + diff-lcs (1.3) + dogapi (1.39.0) + multi_json + json-schema (2.8.1) + addressable (>= 2.4) + logger (1.4.1) + multi_json (1.14.1) + public_suffix (4.0.1) + rake (13.0.0) + rspec (3.9.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-core (3.9.0) + rspec-support (~> 3.9.0) + rspec-expectations (3.9.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-support (3.9.0) + +PLATFORMS + ruby + +DEPENDENCIES + bundler + byebug (~> 11.0) + client-api! + dogapi + rake + rspec (~> 3.0) + +BUNDLED WITH + 2.0.2 diff --git a/client-api.gemspec b/client-api.gemspec index 67ccc88..7173b74 100644 --- a/client-api.gemspec +++ b/client-api.gemspec @@ -28,6 +28,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rake" spec.add_development_dependency "rspec", "~> 3.0" spec.add_development_dependency "byebug", "~> 11.0" + spec.add_development_dependency "dogapi" spec.add_runtime_dependency "json-schema", '~> 2.8' spec.add_runtime_dependency "logger", "~> 1.0" diff --git a/spec/client/dd_spec.rb b/spec/client/dd_spec.rb new file mode 100644 index 0000000..4e4f957 --- /dev/null +++ b/spec/client/dd_spec.rb @@ -0,0 +1,32 @@ +describe 'http(s) validation', :focus do + + it "http scheme validator", :get do + api = ClientApi::Api.new + api.get('http://jservice.io/api/categories', {"Accept"=>"*/*"}) + end + + it "http scheme validator x2", :get do + api = ClientApi::Api.new + api.get('http://jservice.io/api/categories', {"Accept"=>"*/*"}) + expect(api.status).to eq(200) + end + + it "http scheme validator x3", :get do + api = ClientApi::Api.new + api.get('http://jservice.io/api/categories', {"Accept"=>"*/*"}) + expect(api.status).to eq(201) + end + + it "http scheme validator x4", :get do + api = ClientApi::Api.new + api.get('http://jservice.io/api/categories', {"Accept"=>"*/*"}) + expect(api.status).to eq(202) + end + + it "http scheme validator x5", :get do + api = ClientApi::Api.new + api.get('http://jservice.io/api/categories', {"Accept"=>"*/*"}) + expect(api.status).to eq(200) + end + +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 146521c..b03bcbb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,6 +3,8 @@ require "rspec" require "rspec/expectations" require "json" +require "dogapi" +require "byebug" RSpec.configure do |config| # Enable flags like --only-failures and --next-failure @@ -17,6 +19,9 @@ config.filter_run_when_matching :focus config.expose_dsl_globally = true + + $data ||= [] + $passed = $failed = $pending = 0 end ClientApi.configure do |config| @@ -30,4 +35,34 @@ config.before(:each) do |scenario| ClientApi::Request.new(scenario) end + + config.after(:each) do |scenario| + if (scenario.exception) && (!scenario.exception.message.include? 'pending') + status_id = 0 + elsif scenario.skipped? + status_id = 2 + elsif scenario.pending? + status_id = 2 + else + status_id = 1 + end + + $data << {'status_id' => status_id, 'scenario' => scenario.description} + end + + config.after(:all) do + $data.map do |value| + $failed += 1 if value['status_id'] == 0 + $passed += 1 if value['status_id'] == 1 + $pending += 1 if value['status_id'] == 2 + end + + dog = Dogapi::Client.new(ENV['API_KEY'], ENV['APP_KEY']) + dog.batch_metrics do + dog.emit_point('qa.baseline.website.passed',$passed) + dog.emit_point('qa.baseline.website.failed', $failed) + dog.emit_point('qa.baseline.website.pending', $pending) + end + end + end \ No newline at end of file