From 1b1fd094dc28410b332dd5dcd5927de39e6740c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Bo=CC=88ning?= Date: Fri, 8 Oct 2021 11:05:29 +0200 Subject: [PATCH] add rspec --- nftmaker_api.gemspec | 2 ++ spec/client_spec.rb | 36 ++++++++++++++++++++++++++++++++++++ spec/spec_helper.rb | 8 ++++++++ 3 files changed, 46 insertions(+) create mode 100644 spec/client_spec.rb create mode 100644 spec/spec_helper.rb diff --git a/nftmaker_api.gemspec b/nftmaker_api.gemspec index 37218e3..172bab7 100644 --- a/nftmaker_api.gemspec +++ b/nftmaker_api.gemspec @@ -21,4 +21,6 @@ Gem::Specification.new do |gem| gem.add_dependency "oj", "~> 3.1" gem.add_dependency "faraday", ">= 1", "< 2" + + gem.add_development_dependency "rspec", "~> 3.10" end diff --git a/spec/client_spec.rb b/spec/client_spec.rb new file mode 100644 index 0000000..c8c07f2 --- /dev/null +++ b/spec/client_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe NftmakerApi do + subject { described_class.new } + + describe "configuration" do + it "has default settings" do + expect(subject.configuration.api_key).to eq nil + expect(subject.configuration.host).to eq "https://api.nft-maker.io" + expect(subject.configuration.http_adapter).to eq :net_http + end + + it "allows to change settings" do + described_class.configure do |c| + c.api_key = "12345678" + c.host = "foobar.com" + c.http_adapter = :typhoeus + end + + expect(subject.configuration.api_key).to eq "12345678" + expect(subject.configuration.host).to eq "foobar.com" + expect(subject.configuration.http_adapter).to eq :typhoeus + expect(subject.http_client.adapter).to eq Faraday::Adapter::Typhoeus + end + + it "allows settings per instance" do + client_1 = described_class.new(host: "foo.com", api_key: "foo123") + expect(client_1.api_key).to eq "foo123" + expect(client_1.host).to eq "foo.com" + + client_2 = described_class.new(host: "bar.com", api_key: "bar123") + expect(client_2.api_key).to eq "bar123" + expect(client_2.host).to eq "bar.com" + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..4c2c90f --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,8 @@ +require 'bundler/setup' +Bundler.setup + +require 'nftmaker_api' + +RSpec.configure do |config| + # some (optional) config here +end