Skip to content

Commit

Permalink
Merge 838a1ae into 3286fae
Browse files Browse the repository at this point in the history
  • Loading branch information
ninoseki committed Sep 19, 2018
2 parents 3286fae + 838a1ae commit 5c09748
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 6 deletions.
6 changes: 4 additions & 2 deletions Gemfile
@@ -1,17 +1,19 @@
# frozen_string_literal: true

source "https://rubygems.org"

ruby "~> 2.5.0"

gem "dotenv"
gem "require_all"
gem "puma"
gem "require_all"
gem "sinatra"
gem "sinatra-contrib"

group :test, :development do
gem 'coveralls', require: false
gem "foreman"
gem "rake"
gem "rack-test"
gem "rake"
gem "rspec"
end
2 changes: 2 additions & 0 deletions Rakefile
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)
Expand Down
5 changes: 4 additions & 1 deletion app/digger.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "resolv"
require "ipaddr"

Expand Down Expand Up @@ -30,7 +32,7 @@ def get_resource
end

def valid_type?(type)
TYPE_CLASSES.keys.include? type.upcase.to_sym
TYPE_CLASSES.key?(type.upcase.to_sym)
end
end

Expand All @@ -51,6 +53,7 @@ class InvalidResourceError < StandardError; end

def initialize(resource)
raise InvalidResourceError unless valid_resource?(resource)

@resource = resource
end

Expand Down
2 changes: 2 additions & 0 deletions app/main.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "json"
require "sinatra"

Expand Down
2 changes: 2 additions & 0 deletions config.ru
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "bundler/setup"
require "require_all"
require "sinatra"
Expand Down
2 changes: 2 additions & 0 deletions config/puma.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

preload_app!

rackup DefaultRackup
Expand Down
4 changes: 3 additions & 1 deletion spec/converter_spec.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true

describe Converter do
let(:dns) { Resolv::DNS::new }
let(:dns) { Resolv::DNS.new }
describe "#to_hash" do
context "when given an in valid resouce" do
it "should raise InvalidResourceError" do
Expand Down
2 changes: 2 additions & 0 deletions spec/digger_spec.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Digger do
describe "#get_resource" do
it "should return a Resolv::DNS::Resource::IN::A object" do
Expand Down
6 changes: 4 additions & 2 deletions spec/main_spec.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rack/test'

describe "MainApp" do
Expand All @@ -9,15 +11,15 @@ def app

context "POST /" do
it "should return JSON" do
post "/", { name: "google.com", type: "A" }
post "/", name: "google.com", type: "A"
expect(last_response).to be_ok
json = JSON.parse(last_response.body)
expect(json).to be_a Hash
end
end
context "POST / with JSON" do
it "should return JSON" do
post "/", { name: "google.com", type: "A" }.to_json, { 'CONTENT_TYPE' => 'application/json' }
post "/", { name: "google.com", type: "A" }.to_json, 'CONTENT_TYPE' => 'application/json'

expect(last_response).to be_ok
json = JSON.parse(last_response.body)
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "rspec"
require "require_all"

Expand Down

0 comments on commit 5c09748

Please sign in to comment.