polyspec 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +87 -0
- data/Rakefile +2 -0
- data/bin/polyspec +31 -0
- data/lib/polyspec.rb +9 -0
- data/lib/polyspec/cli_option_parser.rb +40 -0
- data/lib/polyspec/django_project_runner.rb +12 -0
- data/lib/polyspec/golang_project_runner.rb +32 -0
- data/lib/polyspec/runner_factory.rb +20 -0
- data/lib/polyspec/test_setup_runner.rb +66 -0
- data/lib/polyspec/version.rb +3 -0
- data/polyspec.gemspec +29 -0
- data/spec/features/django_spec.rb +15 -0
- data/spec/features/goapp_spec.rb +22 -0
- data/spec/fixtures/django-app/app/__init__.py +0 -0
- data/spec/fixtures/django-app/app/settings.py +83 -0
- data/spec/fixtures/django-app/app/urls.py +10 -0
- data/spec/fixtures/django-app/app/wsgi.py +14 -0
- data/spec/fixtures/django-app/manage.py +10 -0
- data/spec/fixtures/django-app/spec/sanity_spec.rb +7 -0
- data/spec/fixtures/go-app/src/stuffs/main.go +17 -0
- data/spec/fixtures/go-app/src/stuffs/spec/main_spec.rb +9 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/cli_helpers.rb +17 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e84e9acc653e4a15a32bb41214af7d421b044134
|
4
|
+
data.tar.gz: 30b61200eef1c8a7a43a91c0ad89cfa96202066f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a7c2abfb06f20757267d8766be11c2270a59a017c405662cc04e53a2e90fad2af46cdecbb6363a2c28ad55066159f329f5cc3097c99699d2e3421ae34e060ae
|
7
|
+
data.tar.gz: c971c47615644df505dbca7cefc52f63d166919714d7b0aacaa463cd0fdc916b16523f5d5fd1accf282947eb0035a5bec284fd8bc3aea70d323b2efaaf076381
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 TJ Taylor
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Polyspec
|
2
|
+
|
3
|
+
Test all your web-apps with Ruby and RSpec.
|
4
|
+
|
5
|
+
The motivation for this was two-fold. I wanted a) a way to write
|
6
|
+
clear, understandable tests for Golang HTTP APIs, and b) to write
|
7
|
+
capybara tests for Django apps. This provides both in a nice,
|
8
|
+
neat little package.
|
9
|
+
|
10
|
+
So far, there are default configurations for the
|
11
|
+
following languages/frameworks:
|
12
|
+
|
13
|
+
* Golang
|
14
|
+
* Django
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'polyspec'
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
$ gem install polyspec
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
In it's simplest incarnation, all you need to do is run the binary:
|
35
|
+
|
36
|
+
$ polyspec
|
37
|
+
|
38
|
+
If you have one of the configured app types, polyspec will just look
|
39
|
+
in your APP_ROOT/spec directory and run all the files matching the pattern
|
40
|
+
`spec/**/*_spec.rb`.
|
41
|
+
|
42
|
+
If you stray from the the default configuration, you need to specify some
|
43
|
+
cli arguments. From the CLI help:
|
44
|
+
|
45
|
+
Usage: /Users/ttaylor/.rbenv/versions/2.1.4/bin/polyspec [options]
|
46
|
+
-e, --start-command COMMAND The command used to start the app
|
47
|
+
-p, --port PORT The port the app will be running on
|
48
|
+
Defaults to 3000
|
49
|
+
-s, --stop-command COMMAND The command used to stop the app
|
50
|
+
If this is empty, the pid will be used to kill it
|
51
|
+
-b, --build-command COMMAND The command used to build/setup the app
|
52
|
+
-c, --check-path COMMAND The command used to check that the app is running
|
53
|
+
This assumes that it can perform a GET
|
54
|
+
to 'http://localhost:$PORT/$CHECK_PATH'
|
55
|
+
-t, --wait-tries NUM The number of times to try hitting the check-url before it gives up
|
56
|
+
|
57
|
+
Probably the most interesting one is the check-path. The CLI expects
|
58
|
+
to be able to hit your app on the port you give (or 3000) at this path.
|
59
|
+
|
60
|
+
The rest of the options are run verbatim by the runner, with only a
|
61
|
+
few notable things:
|
62
|
+
|
63
|
+
* The build command is run once, you can use this to specify a build step
|
64
|
+
(like `make` or `go build`) or maybe even DB migrations
|
65
|
+
(`rake db:migrate` anyone?)
|
66
|
+
|
67
|
+
* The start and stop commands are run before and after each test (respectively).
|
68
|
+
This ensures you have clean state in your app.
|
69
|
+
|
70
|
+
## Contributing
|
71
|
+
|
72
|
+
1. Fork it ( https://github.com/dugancathal/polyspec/fork )
|
73
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
74
|
+
3. Write some tests
|
75
|
+
4. Write some code
|
76
|
+
5. Commit your changes (`git commit -am 'Add some feature'`)
|
77
|
+
6. Push to the branch (`git push origin my-new-feature`)
|
78
|
+
7. Create a new Pull Request
|
79
|
+
|
80
|
+
### Testing
|
81
|
+
|
82
|
+
The full test suite requires both golang and python to be installed.
|
83
|
+
On a Mac, you can just do (presuming you have homebrew installed):
|
84
|
+
|
85
|
+
brew install go
|
86
|
+
brew install python
|
87
|
+
pip install django # (or whichever installer you choose to use)
|
data/Rakefile
ADDED
data/bin/polyspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'polyspec'
|
4
|
+
require 'optparse'
|
5
|
+
require 'rspec'
|
6
|
+
|
7
|
+
options = Polyspec::CliOptionParser.new(ARGV).parse
|
8
|
+
|
9
|
+
runner = if options[:start_command]
|
10
|
+
Polyspec::TestSetupRunner.from_args(options)
|
11
|
+
else
|
12
|
+
Polyspec::RunnerFactory.new(ARGV[0] || Dir.pwd).get.new
|
13
|
+
end
|
14
|
+
|
15
|
+
runner.port = options[:port] || 3000
|
16
|
+
runner.check_url = options[:check_url] || '/'
|
17
|
+
|
18
|
+
runner.build
|
19
|
+
RSpec.configure do |c|
|
20
|
+
c.around(:each) do |e|
|
21
|
+
runner.start
|
22
|
+
e.run
|
23
|
+
runner.stop
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
require 'shellwords'
|
28
|
+
spec_opts = ENV['SPEC_OPTS'] || '-P spec/**/*_spec.rb'
|
29
|
+
RSpec::Core::Runner.run(Shellwords.split(spec_opts))
|
30
|
+
|
31
|
+
runner.cleanup
|
data/lib/polyspec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Polyspec
|
2
|
+
class CliOptionParser
|
3
|
+
attr_reader :args
|
4
|
+
def initialize(args_array)
|
5
|
+
@args = args_array.dup
|
6
|
+
end
|
7
|
+
|
8
|
+
def parse
|
9
|
+
options = {}
|
10
|
+
OptionParser.new(args) do |opts|
|
11
|
+
opts.banner = "Usage: #$0 [options]"
|
12
|
+
|
13
|
+
opts.on("-e", "--start-command COMMAND", "The command used to start the app") do |e|
|
14
|
+
options[:start_command] = e
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on("-p", "--port PORT", Integer, "The port the app will be running on", "Defaults to 3000") do |p|
|
18
|
+
options[:port] = p
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("-s", "--stop-command COMMAND", "The command used to stop the app", "If this is empty, the pid will be used to kill it") do |s|
|
22
|
+
options[:stop_command] = s
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on("-b", "--build-command COMMAND", "The command used to build/setup the app") do |b|
|
26
|
+
options[:build_command] = b
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on("-c", "--check-path COMMAND", "The command used to check that the app is running", "This assumes that it can perform a GET", "to 'http://localhost:$PORT/$CHECK_PATH'") do |b|
|
30
|
+
options[:build_command] = b
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on("-t", "--wait-tries NUM", Integer, "The number of times to try hitting the check-url before it gives up") do |t|
|
34
|
+
options[:wait_tries] = t
|
35
|
+
end
|
36
|
+
end.parse!
|
37
|
+
options
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Polyspec
|
4
|
+
class GolangProjectRunner < TestSetupRunner
|
5
|
+
TMP_FILE_PATTERN = "/tmp/polyspec-app-%s"
|
6
|
+
def build_command
|
7
|
+
"go build -o #{binary_file} #{package_name}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def start_command
|
11
|
+
binary_file
|
12
|
+
end
|
13
|
+
|
14
|
+
def cleanup
|
15
|
+
FileUtils.rm(binary_file)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def runtime_hash
|
21
|
+
@runtime_hash ||= Time.now.to_i
|
22
|
+
end
|
23
|
+
|
24
|
+
def package_name
|
25
|
+
Dir.pwd.split('src/').last
|
26
|
+
end
|
27
|
+
|
28
|
+
def binary_file
|
29
|
+
TMP_FILE_PATTERN % runtime_hash
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'find'
|
2
|
+
|
3
|
+
module Polyspec
|
4
|
+
class RunnerFactory
|
5
|
+
attr_reader :project_path
|
6
|
+
def initialize(project_path)
|
7
|
+
@project_path = project_path
|
8
|
+
end
|
9
|
+
|
10
|
+
PROJECT_TYPE_MATCHERS = {
|
11
|
+
DjangoProjectRunner => ->(project_files) { project_files.any? {|f| next if File.extname(f) == '.pyc'; File.read(f).match(/django/i) } },
|
12
|
+
GolangProjectRunner => ->(project_files) { project_files.any? {|f| File.extname(f) == '.go' } },
|
13
|
+
}
|
14
|
+
|
15
|
+
def get
|
16
|
+
project_files = Find.find(project_path).select {|f| File.file?(f) }
|
17
|
+
PROJECT_TYPE_MATCHERS.find {|runner, matcher| matcher.call(project_files) }.first
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Polyspec
|
4
|
+
class TestSetupRunner
|
5
|
+
attr_accessor :build_command, :start_command, :stop_command, :wait_check, :wait_tries, :pid, :port, :check_url
|
6
|
+
DEFAULT_WAIT_TRIES = 3
|
7
|
+
DEFAULT_WAIT_CHECK = ->(port, check_url) {
|
8
|
+
begin
|
9
|
+
HTTParty.get("http://localhost:#{port}#{check_url}")
|
10
|
+
rescue
|
11
|
+
end
|
12
|
+
}
|
13
|
+
|
14
|
+
def self.from_args(args)
|
15
|
+
runner = new
|
16
|
+
|
17
|
+
runner.build_command = options[:build_command]
|
18
|
+
runner.start_command = options[:start_command]
|
19
|
+
runner.stop_command = options[:stop_command]
|
20
|
+
runner.wait_tries = options[:wait_tries]
|
21
|
+
runner.port = options[:port]
|
22
|
+
runner.check_url = options[:check_url]
|
23
|
+
runner
|
24
|
+
end
|
25
|
+
|
26
|
+
def build
|
27
|
+
`#{build_command}`
|
28
|
+
end
|
29
|
+
|
30
|
+
def start
|
31
|
+
self.pid = Process.spawn(start_command, pgroup: true)
|
32
|
+
wait_for_app_to_boot
|
33
|
+
pid
|
34
|
+
end
|
35
|
+
|
36
|
+
def stop
|
37
|
+
if stop_command
|
38
|
+
`#{stop_command}`
|
39
|
+
else
|
40
|
+
Process.kill(-9, pid)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def cleanup
|
45
|
+
# NOOP
|
46
|
+
end
|
47
|
+
|
48
|
+
def wait_tries
|
49
|
+
@wait_tries || DEFAULT_WAIT_TRIES
|
50
|
+
end
|
51
|
+
|
52
|
+
def wait_check
|
53
|
+
@wait_check || DEFAULT_WAIT_CHECK
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def wait_for_app_to_boot
|
59
|
+
1.upto(wait_tries) do
|
60
|
+
return if wait_check.call(port, check_url)
|
61
|
+
sleep 0.5
|
62
|
+
end
|
63
|
+
raise 'Unable to start the app'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/polyspec.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'polyspec/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "polyspec"
|
8
|
+
spec.version = Polyspec::VERSION
|
9
|
+
spec.authors = ["TJ Taylor"]
|
10
|
+
spec.email = ["dugancathal@gmail.com"]
|
11
|
+
spec.summary = %q{Write specs in ruby for ALL the languages}
|
12
|
+
spec.description = <<-DESC
|
13
|
+
RSpec's DSL for writing tests for your app is fantastic. This gem
|
14
|
+
brings that DSL to all your apps.
|
15
|
+
DESC
|
16
|
+
spec.homepage = ""
|
17
|
+
spec.license = "MIT"
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0")
|
20
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
|
27
|
+
spec.add_dependency "httparty", "~> 0.13"
|
28
|
+
spec.add_dependency "rspec", "~> 3.0"
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Testing a Django app' do
|
4
|
+
let(:django_root) { APP_ROOT.join('spec', 'fixtures', 'django-app') }
|
5
|
+
|
6
|
+
let(:port) { 3001 }
|
7
|
+
describe 'running an app' do
|
8
|
+
it 'runs the given command' do
|
9
|
+
Dir.chdir(django_root) do
|
10
|
+
output = polyspec p: port
|
11
|
+
expect(output).to match /1 example, 0 failures/
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'httparty'
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
describe 'Testing a Golang app' do
|
6
|
+
let(:gopath) { APP_ROOT.join('spec', 'fixtures', 'go-app') }
|
7
|
+
let(:test_goapp) { gopath.join('src', 'stuffs') }
|
8
|
+
|
9
|
+
let(:port) { 3000 }
|
10
|
+
describe 'running an app' do
|
11
|
+
it 'runs the given command' do
|
12
|
+
Dir.chdir(test_goapp) do
|
13
|
+
output = polyspec p: port
|
14
|
+
expect(output).to match /1 example, 0 failures/
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def environment_variables
|
19
|
+
"GOPATH=#{gopath} PORT=#{port}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
File without changes
|
@@ -0,0 +1,83 @@
|
|
1
|
+
"""
|
2
|
+
Django settings for app project.
|
3
|
+
|
4
|
+
For more information on this file, see
|
5
|
+
https://docs.djangoproject.com/en/1.7/topics/settings/
|
6
|
+
|
7
|
+
For the full list of settings and their values, see
|
8
|
+
https://docs.djangoproject.com/en/1.7/ref/settings/
|
9
|
+
"""
|
10
|
+
|
11
|
+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
12
|
+
import os
|
13
|
+
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
14
|
+
|
15
|
+
|
16
|
+
# Quick-start development settings - unsuitable for production
|
17
|
+
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
|
18
|
+
|
19
|
+
# SECURITY WARNING: keep the secret key used in production secret!
|
20
|
+
SECRET_KEY = 'wg(%7#oiqyddi08fum-3ken3@02&j)-0j)j+_-_v50&&^7i#k0'
|
21
|
+
|
22
|
+
# SECURITY WARNING: don't run with debug turned on in production!
|
23
|
+
DEBUG = True
|
24
|
+
|
25
|
+
TEMPLATE_DEBUG = True
|
26
|
+
|
27
|
+
ALLOWED_HOSTS = []
|
28
|
+
|
29
|
+
|
30
|
+
# Application definition
|
31
|
+
|
32
|
+
INSTALLED_APPS = (
|
33
|
+
'django.contrib.admin',
|
34
|
+
'django.contrib.auth',
|
35
|
+
'django.contrib.contenttypes',
|
36
|
+
'django.contrib.sessions',
|
37
|
+
'django.contrib.messages',
|
38
|
+
'django.contrib.staticfiles',
|
39
|
+
)
|
40
|
+
|
41
|
+
MIDDLEWARE_CLASSES = (
|
42
|
+
'django.contrib.sessions.middleware.SessionMiddleware',
|
43
|
+
'django.middleware.common.CommonMiddleware',
|
44
|
+
'django.middleware.csrf.CsrfViewMiddleware',
|
45
|
+
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
46
|
+
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
|
47
|
+
'django.contrib.messages.middleware.MessageMiddleware',
|
48
|
+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
49
|
+
)
|
50
|
+
|
51
|
+
ROOT_URLCONF = 'app.urls'
|
52
|
+
|
53
|
+
WSGI_APPLICATION = 'app.wsgi.application'
|
54
|
+
|
55
|
+
|
56
|
+
# Database
|
57
|
+
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
|
58
|
+
|
59
|
+
DATABASES = {
|
60
|
+
'default': {
|
61
|
+
'ENGINE': 'django.db.backends.sqlite3',
|
62
|
+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
# Internationalization
|
67
|
+
# https://docs.djangoproject.com/en/1.7/topics/i18n/
|
68
|
+
|
69
|
+
LANGUAGE_CODE = 'en-us'
|
70
|
+
|
71
|
+
TIME_ZONE = 'UTC'
|
72
|
+
|
73
|
+
USE_I18N = True
|
74
|
+
|
75
|
+
USE_L10N = True
|
76
|
+
|
77
|
+
USE_TZ = True
|
78
|
+
|
79
|
+
|
80
|
+
# Static files (CSS, JavaScript, Images)
|
81
|
+
# https://docs.djangoproject.com/en/1.7/howto/static-files/
|
82
|
+
|
83
|
+
STATIC_URL = '/static/'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
from django.conf.urls import patterns, include, url
|
2
|
+
from django.contrib import admin
|
3
|
+
|
4
|
+
urlpatterns = patterns('',
|
5
|
+
# Examples:
|
6
|
+
# url(r'^$', 'app.views.home', name='home'),
|
7
|
+
# url(r'^blog/', include('blog.urls')),
|
8
|
+
|
9
|
+
url(r'^admin/', include(admin.site.urls)),
|
10
|
+
)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"""
|
2
|
+
WSGI config for app project.
|
3
|
+
|
4
|
+
It exposes the WSGI callable as a module-level variable named ``application``.
|
5
|
+
|
6
|
+
For more information on this file, see
|
7
|
+
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
|
8
|
+
"""
|
9
|
+
|
10
|
+
import os
|
11
|
+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")
|
12
|
+
|
13
|
+
from django.core.wsgi import get_wsgi_application
|
14
|
+
application = get_wsgi_application()
|
@@ -0,0 +1,17 @@
|
|
1
|
+
package main
|
2
|
+
|
3
|
+
import (
|
4
|
+
"fmt"
|
5
|
+
"net/http"
|
6
|
+
"os"
|
7
|
+
)
|
8
|
+
|
9
|
+
func main() {
|
10
|
+
port := os.Getenv("PORT")
|
11
|
+
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
12
|
+
w.Header().Set("Content-Type", "application/json")
|
13
|
+
w.Write([]byte(`{"foo": "bar"}`))
|
14
|
+
})
|
15
|
+
|
16
|
+
http.ListenAndServe(fmt.Sprintf(":%s", port), nil)
|
17
|
+
}
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'rspec'
|
3
|
+
|
4
|
+
APP_ROOT = Pathname(File.expand_path('../../', __FILE__))
|
5
|
+
|
6
|
+
Dir[APP_ROOT.join('spec/support/**/*.rb')].each {|f| require f }
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.expect_with :rspec do |expectations|
|
10
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
11
|
+
end
|
12
|
+
|
13
|
+
config.mock_with :rspec do |mocks|
|
14
|
+
mocks.verify_partial_doubles = true
|
15
|
+
end
|
16
|
+
|
17
|
+
config.include(CliHelpers)
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
module CliHelpers
|
3
|
+
def polyspec(args={})
|
4
|
+
binary_location = APP_ROOT.join('bin', 'polyspec')
|
5
|
+
full_arg_list = convert_keys_to_switches(args)
|
6
|
+
`#{environment_variables} ruby -Ilib #{binary_location} #{full_arg_list} 2>&1`
|
7
|
+
end
|
8
|
+
|
9
|
+
def convert_keys_to_switches(args)
|
10
|
+
switched_args = args.map {|k, v| ["-#{k}", v] }
|
11
|
+
switched_args.flatten.join(' ')
|
12
|
+
end
|
13
|
+
|
14
|
+
def environment_variables
|
15
|
+
# Define me if you need to (e.g. GOPATH)
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: polyspec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TJ Taylor
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.13'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.13'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: |2
|
70
|
+
RSpec's DSL for writing tests for your app is fantastic. This gem
|
71
|
+
brings that DSL to all your apps.
|
72
|
+
email:
|
73
|
+
- dugancathal@gmail.com
|
74
|
+
executables:
|
75
|
+
- polyspec
|
76
|
+
extensions: []
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- ".gitignore"
|
80
|
+
- ".rspec"
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/polyspec
|
86
|
+
- lib/polyspec.rb
|
87
|
+
- lib/polyspec/cli_option_parser.rb
|
88
|
+
- lib/polyspec/django_project_runner.rb
|
89
|
+
- lib/polyspec/golang_project_runner.rb
|
90
|
+
- lib/polyspec/runner_factory.rb
|
91
|
+
- lib/polyspec/test_setup_runner.rb
|
92
|
+
- lib/polyspec/version.rb
|
93
|
+
- polyspec.gemspec
|
94
|
+
- spec/features/django_spec.rb
|
95
|
+
- spec/features/goapp_spec.rb
|
96
|
+
- spec/fixtures/django-app/app/__init__.py
|
97
|
+
- spec/fixtures/django-app/app/settings.py
|
98
|
+
- spec/fixtures/django-app/app/urls.py
|
99
|
+
- spec/fixtures/django-app/app/wsgi.py
|
100
|
+
- spec/fixtures/django-app/manage.py
|
101
|
+
- spec/fixtures/django-app/spec/sanity_spec.rb
|
102
|
+
- spec/fixtures/go-app/src/stuffs/main.go
|
103
|
+
- spec/fixtures/go-app/src/stuffs/spec/main_spec.rb
|
104
|
+
- spec/spec_helper.rb
|
105
|
+
- spec/support/cli_helpers.rb
|
106
|
+
homepage: ''
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.2.2
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Write specs in ruby for ALL the languages
|
130
|
+
test_files:
|
131
|
+
- spec/features/django_spec.rb
|
132
|
+
- spec/features/goapp_spec.rb
|
133
|
+
- spec/fixtures/django-app/app/__init__.py
|
134
|
+
- spec/fixtures/django-app/app/settings.py
|
135
|
+
- spec/fixtures/django-app/app/urls.py
|
136
|
+
- spec/fixtures/django-app/app/wsgi.py
|
137
|
+
- spec/fixtures/django-app/manage.py
|
138
|
+
- spec/fixtures/django-app/spec/sanity_spec.rb
|
139
|
+
- spec/fixtures/go-app/src/stuffs/main.go
|
140
|
+
- spec/fixtures/go-app/src/stuffs/spec/main_spec.rb
|
141
|
+
- spec/spec_helper.rb
|
142
|
+
- spec/support/cli_helpers.rb
|