Skip to content

Commit

Permalink
Share fixtures.
Browse files Browse the repository at this point in the history
  • Loading branch information
merqlove committed Sep 4, 2017
1 parent 9e9c556 commit b6d9f6e
Show file tree
Hide file tree
Showing 29 changed files with 794 additions and 20 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ AllCops:
- '*.gemspec'
- 'tasks/**/*'
- 'Rakefile'
- 'example/**/*'
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.1
2.3.4
4 changes: 0 additions & 4 deletions example/adapter/lib/new_adapter/adapter.rb

This file was deleted.

9 changes: 0 additions & 9 deletions example/adapter/spec/new_adapter_spec.rb

This file was deleted.

29 changes: 29 additions & 0 deletions example/new_adapter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
log/*
!log/.keep
tmp/*
!tmp/.keep
*.bundle
*.so
*.o
*.a
mkmf.log
.idea
.irb_history
.ruby-version
.envrc
File renamed without changes.
20 changes: 20 additions & 0 deletions example/new_adapter/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- encoding : utf-8 -*-
# frozen_string_literal: true
require 'bundler/setup'

PROJECT_ROOT = File.expand_path('..', __FILE__)
PROJECT_ROOT_DIR = File.dirname(__FILE__)
$LOAD_PATH.unshift "#{PROJECT_ROOT}/lib"
require 'new_adapter'

begin
require 'rspec/core/rake_task'

desc 'Run all specs'
RSpec::Core::RakeTask.new(:spec)
rescue LoadError
nil
# The test gem group fails to install on the platform for some reason
end

task default: :spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
require_relative 'new_adapter/version'
require_relative 'new_adapter/adapter'

module NewAdapter
autoload :Adapter, 'new_adapter/adapter'
module NewAdapter
end
8 changes: 8 additions & 0 deletions example/new_adapter/lib/new_adapter/adapter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true
require 'do_snapshot/helpers'
require 'do_snapshot/adapter'

module NewAdapter
class Adapter < ::DoSnapshot::Adapter::DropletKit
end
end
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'new_adapter/version'
Expand Down
11 changes: 11 additions & 0 deletions example/new_adapter/spec/new_adapter/adapter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- encoding : utf-8 -*-
# frozen_string_literal: true
require 'spec_helper'

module NewAdapter
RSpec.describe Adapter do
include DoSnapshot::RSpec::Environment
include DoSnapshot::RSpec::ApiV2Helpers
include DoSnapshot::RSpec::Adapter
end
end
7 changes: 7 additions & 0 deletions example/new_adapter/spec/new_adapter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- encoding : utf-8 -*-
# frozen_string_literal: true
require 'spec_helper'

RSpec.describe NewAdapter do

end
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Bundler.setup

require 'webmock/rspec'
require 'new_adapter'
require 'do_snapshot/cli'
require 'do_snapshot/rspec'

WebMock.disable_net_connect!(allow_localhost: true)
Expand All @@ -21,9 +23,9 @@
end

def project_path
File.expand_path('../..', __FILE__)
DoSnapshot::RSpec.project_path
end

def fixture(fixture_name)
Pathname.new(project_path + '/spec/fixtures/digitalocean/').join("#{fixture_name}.json").read
DoSnapshot::RSpec.fixture(fixture_name)
end
8 changes: 8 additions & 0 deletions lib/do_snapshot/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,13 @@ module RSpec # rubocop:disable Style/Documentation
autoload :ApiV2Helpers, 'do_snapshot/rspec/api_v2_helpers'
autoload :Environment, 'do_snapshot/rspec/environment'
autoload :UriHelpers, 'do_snapshot/rspec/uri_helpers'

def self.project_path
File.expand_path('../../..', __FILE__)
end

def self.fixture(fixture_name)
Pathname.new(project_path + '/lib/do_snapshot/rspec/fixtures/digitalocean/').join("#{fixture_name}.json").read
end
end
end
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"id": "not_found",
"message": "The resource you were accessing could not be found."
}
29 changes: 29 additions & 0 deletions lib/do_snapshot/rspec/fixtures/digitalocean/v2/response_event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"action":{
"id": 7499,
"status": "in-progress",
"type": "snapshot",
"started_at": "2014-11-14T16:34:39Z",
"completed_at": null,
"resource_id": 100823,
"resource_type": "droplet",
"region": {
"name": "Amsterdam 1",
"slug": "ams1",
"sizes": [
"512mb",
"1gb",
"4gb",
"2gb",
"8gb",
"16gb"
],
"features": [
"virtio",
"backups"
],
"available": true
},
"region_slug": "ams1"
}
}
102 changes: 102 additions & 0 deletions lib/do_snapshot/rspec/fixtures/digitalocean/v2/show_droplet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"droplet": {
"id": 100823,
"name": "example.com",
"memory": 512,
"vcpus": 1,
"disk": 20,
"locked": false,
"status": "active",
"kernel": {
"id": 2233,
"name": "CentOS 6.4 x64 vmlinuz-2.6.32-358.6.2.el6.x86_64",
"version": "2.6.32-358.6.2.el6.x86_64"
},
"created_at": "2014-11-14T16:36:31Z",
"features": [
"ipv6",
"virtio"
],
"backup_ids": [
],
"snapshot_ids": [
5019770,
5019903,
5020783,
5030783
],
"image": {
"id": 562354,
"name": "CentOS 6.4 x64",
"distribution": "CentOS",
"slug": "centos-6-4-x64",
"public": false,
"regions": [
"nyc1",
"ams1",
"sfo1",
"nyc2",
"ams2",
"sgp1",
"lon1",
"nyc3",
"ams3",
"nyc3",
"fra1"
],
"created_at": "2014-10-17T20:24:33Z",
"type": "snapshot",
"min_disk_size": 20
},
"size": {
"slug": "512mb",
"memory": 512,
"vcpus": 1,
"disk": 20,
"transfer": 1.0,
"price_monthly": 5.0,
"price_hourly": 0.00744,
"regions": [
"nyc1",
"sgp1",
"ams1",
"sfo1",
"nyc2",
"lon1",
"nyc3",
"ams3",
"ams2",
"fra1"
]
},
"size_slug": "512mb",
"networks": {
"v4": [
{
"ip_address": "104.131.186.241",
"netmask": "255.255.240.0",
"gateway": "104.131.176.1",
"type": "public"
}
],
"v6": []
},
"region": {
"name": "Amsterdam 1",
"slug": "ams1",
"sizes": [
"16gb",
"2gb",
"1gb",
"4gb",
"8gb",
"512mb"
],
"features": [
"virtio",
"backups"
],
"available": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"droplet": {
"id": 100823,
"name": "example.com",
"memory": 512,
"vcpus": 1,
"disk": 20,
"locked": false,
"status": "off",
"kernel": {
"id": 2233,
"name": "CentOS 6.4 x64 vmlinuz-2.6.32-358.6.2.el6.x86_64",
"version": "2.6.32-358.6.2.el6.x86_64"
},
"created_at": "2014-11-14T16:36:31Z",
"features": [
"ipv6",
"virtio"
],
"backup_ids": [
],
"snapshot_ids": [
5019770,
5019903,
5020783,
5030783
],
"image": {
"id": 562354,
"name": "CentOS 6.4 x64",
"distribution": "CentOS",
"slug": "centos-6-4-x64",
"public": false,
"regions": [
"nyc1",
"ams1",
"sfo1",
"nyc2",
"ams2",
"sgp1",
"lon1",
"nyc3",
"ams3",
"nyc3",
"fra1"
],
"created_at": "2014-10-17T20:24:33Z",
"type": "snapshot",
"min_disk_size": 20
},
"size": {
"slug": "512mb",
"memory": 512,
"vcpus": 1,
"disk": 20,
"transfer": 1.0,
"price_monthly": 5.0,
"price_hourly": 0.00744,
"regions": [
"nyc1",
"sgp1",
"ams1",
"sfo1",
"nyc2",
"lon1",
"nyc3",
"ams3",
"ams2",
"fra1"
]
},
"size_slug": "512mb",
"networks": {
"v4": [
{
"ip_address": "104.131.186.241",
"netmask": "255.255.240.0",
"gateway": "104.131.176.1",
"type": "public"
}
],
"v6": []
},
"region": {
"name": "Amsterdam 1",
"slug": "ams1",
"sizes": [
"16gb",
"2gb",
"1gb",
"4gb",
"8gb",
"512mb"
],
"features": [
"virtio",
"backups"
],
"available": true
}
}
}
Loading

0 comments on commit b6d9f6e

Please sign in to comment.