Skip to content

Commit ca7feb3

Browse files
author
childish-sambino
authored
fix: migrate to common prism setup (#421)
1 parent 3cee7ad commit ca7feb3

File tree

6 files changed

+35
-90
lines changed

6 files changed

+35
-90
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ Gemfile.lock
3939

4040
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
4141
.rvmrc
42+
43+
prism

.travis.yml

+11-20
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,25 @@
11
language: ruby
2-
rvm:
3-
- ruby-head
4-
- 2.7
5-
- 2.6
6-
- 2.5
7-
- 2.4
8-
- jruby-9.2
2+
env:
3+
- version=ruby:2.7
4+
- version=ruby:2.6
5+
- version=ruby:2.5
6+
- version=ruby:2.4
7+
- version=jruby:9.2
8+
99
gemfile:
1010
- gemfiles/Sinatra_1.gemfile
1111
- gemfiles/Sinatra_2.gemfile
12-
before_script:
13-
- mkdir prism
14-
- mkdir prism/bin
15-
- export PATH=$PATH:$PWD/prism/bin/
16-
- "./test/prism.sh"
17-
install: make install
18-
script: make test
19-
matrix:
20-
allow_failures:
21-
- rvm: ruby-head
22-
fast_finish: true
12+
13+
script: make test-docker
14+
2315
deploy:
2416
provider: rubygems
2517
api_key:
2618
secure: CWlfN170i/fHPrIufHHLWQ0utjuhxf4ELSxKeypIuO2CNTqNMzocDAa2vxMt4XfO6d2wFPV/LC+IHR7i+sp7PKvjRoa4BLUUxjfBNDboc0gGESeUYlAxwsJo0tOVCNmpxgjQKqtPLz/19A/v/xpxLv2Im/9Idqa5ATd06sMDdM8=
2719
gem: sendgrid-ruby
2820
on:
2921
tags: true
30-
rvm: '2.4'
31-
condition: '$BUNDLE_GEMFILE == *"gemfiles/Sinatra_1.gemfile"'
22+
condition: $version=ruby:2.4 AND '$BUNDLE_GEMFILE == *"gemfiles/Sinatra_1.gemfile"'
3223

3324
notifications:
3425
slack:

Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ARG version=ruby:latest
2+
FROM $version
3+
4+
# Needed for jruby
5+
RUN apt-get update \
6+
&& apt-get install -y make git
7+
8+
COPY prism/prism/nginx/cert.crt /usr/local/share/ca-certificates/cert.crt
9+
RUN update-ca-certificates
10+
11+
WORKDIR /app
12+
COPY . .
13+
14+
RUN make install

Makefile

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
.PHONY: install test
1+
.PHONY: install test test-integ test-docker
22

33
install:
44
gem install bundler:2.1.2; bundle install
55

66
test:
77
bundle exec rake spec
8+
9+
test-integ: test
10+
11+
version ?= ruby:latest
12+
test-docker:
13+
curl -s https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/prism/prism.sh | version=$(version) bash

test/prism.sh

-42
This file was deleted.

test/sendgrid/test_sendgrid-ruby.rb

+1-27
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,8 @@
55

66
class TestAPI < MiniTest::Test
77

8-
unless File.exist?('/usr/local/bin/prism') || File.exist?(File.join(Dir.pwd, 'prism/bin/prism'))
9-
if RUBY_PLATFORM =~ /mswin|mingw/
10-
puts 'Please download the Windows binary (https://github.com/stoplightio/prism/releases) and place it in your /usr/local/bin directory'
11-
else
12-
puts 'Installing Prism'
13-
IO.popen(['curl', '-s', 'https://raw.githubusercontent.com/stoplightio/prism/master/install.sh']) do |io|
14-
out = io.read
15-
unless system(out)
16-
puts "Error downloading the prism binary, you can try downloading directly here (https://github.com/stoplightio/prism/releases) and place in your /usr/local/bin directory, #{out}"
17-
exit
18-
end
19-
end
20-
end
21-
end
22-
23-
puts 'Activating Prism (~20 seconds)'
24-
@@prism_pid = spawn('prism run --mock --list --spec https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json', [:out, :err] => '/dev/null')
25-
sleep(15)
26-
puts 'Prism started'
27-
288
def setup
29-
host = "http://localhost:4010"
30-
@sg = SendGrid::API.new(api_key: "SENDGRID_API_KEY", host: host)
31-
end
32-
33-
Minitest.after_run do
34-
Process.kill('TERM', @@prism_pid)
35-
puts 'Prism shut down'
9+
@sg = SendGrid::API.new(api_key: "SENDGRID_API_KEY")
3610
end
3711

3812
def test_init

0 commit comments

Comments
 (0)