Commit ccf88b98 by John Doe

set up VCR for mocking HTTP requests, working on dbadapter class

parent b6ee8455
......@@ -20,4 +20,5 @@ vendor/bundle
# Ignore e-macs backup files
*~
.byebug_history
\ No newline at end of file
.byebug_history
spec/cassettes
......@@ -32,6 +32,8 @@ gem 'sdoc', '~> 0.4.0', group: :doc
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'httparty'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
......@@ -39,6 +41,9 @@ group :development, :test do
gem 'rubocop', require: false
gem 'factory_girl_rails'
gem 'faker'
gem 'vcr'
gem 'webmock'
gem 'rspec-json_expectations'
end
group :development, :test do
......
......@@ -36,6 +36,7 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
arel (6.0.3)
ast (2.2.0)
binding_of_caller (0.7.2)
......@@ -51,6 +52,8 @@ GEM
execjs
coffee-script-source (1.10.0)
concurrent-ruby (1.0.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
debug_inspector (0.0.2)
diff-lcs (1.2.5)
erubis (2.7.0)
......@@ -83,6 +86,10 @@ GEM
guard-rubocop (1.2.0)
guard (~> 2.0)
rubocop (~> 0.20)
hashdiff (0.3.0)
httparty (0.13.7)
json (~> 1.8)
multi_xml (>= 0.5.2)
i18n (0.7.0)
jbuilder (2.4.1)
activesupport (>= 3.0.0, < 5.1)
......@@ -108,6 +115,7 @@ GEM
mini_portile2 (2.0.0)
minitest (5.8.4)
multi_json (1.12.0)
multi_xml (0.5.5)
nenv (0.3.0)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
......@@ -164,6 +172,7 @@ GEM
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-json_expectations (1.3.0)
rspec-mocks (3.4.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
......@@ -184,6 +193,7 @@ GEM
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.0)
ruby_dep (1.3.1)
safe_yaml (1.0.4)
sass (3.4.22)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
......@@ -219,11 +229,16 @@ GEM
uglifier (3.0.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.0.5)
vcr (3.0.1)
web-console (2.3.0)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
webmock (2.0.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
PLATFORMS
ruby
......@@ -236,9 +251,11 @@ DEPENDENCIES
guard
guard-rspec
guard-rubocop
httparty
jbuilder (~> 2.0)
jquery-rails
rails (= 4.2.6)
rspec-json_expectations
rspec-rails (~> 3.1)
rubocop
sass-rails (~> 5.0)
......@@ -250,7 +267,9 @@ DEPENDENCIES
terminal-notifier-guard
turbolinks
uglifier (>= 1.3.0)
vcr
web-console (~> 2.0)
webmock
BUNDLED WITH
1.12.3
# frozen_string_literal: true
# Wrapper around NilmDB HTTP service
class DbAdapter
include HTTParty
def initialize(url)
@url = url
end
def schema
x = self.class.get("#{@url}/stream/list")
byebug
end
end
# frozen_string_literal: true
require 'rails_helper'
describe DbAdapter do
it 'retrieves basic schema', :vcr do
db = double(url: 'http://archive.wattsworth.net/nilmdb')
adapter = DbAdapter.new(db.url)
expect(adapter.schema).to include_json(error: true)
end
end
......@@ -55,3 +55,10 @@ RSpec.configure do |config|
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")
end
VCR.configure do |c|
c.cassette_library_dir = 'spec/cassettes'
c.hook_into :webmock
c.configure_rspec_metadata!
end
......@@ -13,7 +13,7 @@ RSpec.describe 'DbFolderAgent' do
it 'adds the given file to the folder' do
db_folder_agent = DbFolderAgent.new(db_service: db_service,
db_builder: db_builder)
db_builder: db_builder)
db_folder_agent.insert_file(folder: parent_folder, file: new_file)
expect(new_file.db_folder).to eq(parent_folder)
end
......
......@@ -16,6 +16,9 @@
# users commonly want.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
require 'webmock/rspec'
RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment