fourchette 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,4 +19,4 @@ describe Fourchette::Logger do
19
19
  expect(subject.logger).to be(logger)
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -2,42 +2,67 @@ require 'spec_helper'
2
2
 
3
3
  describe Fourchette::PullRequest do
4
4
  describe '#perform' do
5
- let!(:fork) { double('fork') }
5
+ let(:fork) { double('fork') }
6
6
  subject { described_class.new }
7
7
 
8
8
  after do
9
- Fourchette::Fork.stub(:new).and_return(fork)
9
+ allow(Fourchette::Fork).to receive(:new).and_return(fork)
10
10
  subject.perform(params)
11
11
  end
12
12
 
13
13
  context 'action == synchronize' do
14
- let!(:params) { { 'action' => 'synchronize', 'pull_request' => { 'title' => 'Test Me' } } }
14
+ let(:params) do
15
+ {
16
+ 'action' => 'synchronize',
17
+ 'pull_request' => { 'title' => 'Test Me' }
18
+ }
19
+ end
15
20
 
16
- it { fork.should_receive(:update) }
21
+ it { expect(fork).to receive(:update) }
17
22
  end
18
23
 
19
24
  context 'action == closed' do
20
- let!(:params) { { 'action' => 'closed', 'pull_request' => { 'title' => 'Test Me' } } }
25
+ let(:params) do
26
+ {
27
+ 'action' => 'closed',
28
+ 'pull_request' => { 'title' => 'Test Me' }
29
+ }
30
+ end
21
31
 
22
- it { fork.should_receive(:delete) }
32
+ it { expect(fork).to receive(:delete) }
23
33
  end
24
34
 
25
35
  context 'action == reopened' do
26
- let!(:params) { { 'action' => 'reopened', 'pull_request' => { 'title' => 'Test Me' } } }
36
+ let(:params) do
37
+ {
38
+ 'action' => 'reopened',
39
+ 'pull_request' => { 'title' => 'Test Me' }
40
+ }
41
+ end
27
42
 
28
- it { fork.should_receive(:create) }
43
+ it { expect(fork).to receive(:create) }
29
44
  end
30
45
 
31
46
  context 'action == opened' do
32
- let!(:params) { { 'action' => 'opened', 'pull_request' => { 'title' => 'Test Me' } } }
47
+ let(:params) do
48
+ {
49
+ 'action' => 'opened',
50
+ 'pull_request' => { 'title' => 'Test Me' }
51
+ }
52
+ end
33
53
 
34
- it { fork.should_receive(:create) }
54
+ it { expect(fork).to receive(:create) }
35
55
  end
36
56
 
37
57
  context 'title includes [qa skip]' do
38
- let!(:params) { { 'action' => 'opened', 'pull_request' => { 'title' => 'Skip Me [QA Skip]' } } }
58
+ let(:params) do
59
+ {
60
+ 'action' => 'opened',
61
+ 'pull_request' => { 'title' => 'Skip Me [QA Skip]' }
62
+ }
63
+ end
39
64
 
40
- it { fork.should_not_receive(:create) }
65
+ it { expect(fork).not_to receive(:create) }
41
66
  end
42
67
  end
43
68
  end
@@ -9,36 +9,42 @@ describe Fourchette::Tarball do
9
9
  let(:branch_name) { 'feature/something-new' }
10
10
 
11
11
  before do
12
- subject.stub(:expiration_timestamp).and_return('123')
13
- subject.stub(:clone)
14
- subject.stub(:tar).and_return('tmp/1234567/123.tar.gz')
15
- subject.stub(:system)
16
- stub_const('ENV', {'FOURCHETTE_APP_URL' => 'http://example.com'})
17
- SecureRandom.stub(:uuid).and_return('1234567')
12
+ allow(subject).to receive(:expiration_timestamp).and_return('123')
13
+ allow(subject).to receive(:clone)
14
+ allow(subject).to receive(:tar).and_return('tmp/1234567/123.tar.gz')
15
+ allow(subject).to receive(:system)
16
+ stub_const('ENV', 'FOURCHETTE_APP_URL' => 'http://example.com')
17
+ allow(SecureRandom).to receive(:uuid).and_return('1234567')
18
18
  end
19
19
 
20
- it {
21
- expect(
22
- subject.url(git_repo_url, branch_name, github_repo)
23
- ).to eq "http://example.com/jipiboily/fourchette/1234567/123"
24
- }
20
+ it do
21
+ expect(
22
+ subject.url(git_repo_url, branch_name, github_repo)
23
+ ).to eq 'http://example.com/jipiboily/fourchette/1234567/123'
24
+ end
25
25
 
26
26
  it 'clones the repo and checkout the branch' do
27
- subject.unstub(:clone)
27
+ allow(subject).to receive(:clone).and_call_original
28
28
  git_instance = double
29
- Git.should_receive(:clone).with(git_repo_url, "tmp/1234567", recursive: true).and_return(git_instance)
30
- git_instance.should_receive(:checkout).with(branch_name)
29
+ expect(Git).to receive(:clone).with(
30
+ git_repo_url, 'tmp/1234567', recursive: true
31
+ ).and_return(git_instance)
32
+ expect(git_instance).to receive(:checkout).with(branch_name)
31
33
  subject.url(git_repo_url, branch_name, github_repo)
32
34
  end
33
35
 
34
36
  it 'creates the tarball' do
35
- subject.unstub(:tar)
36
- subject.should_receive(:system).with 'tar -zcf tmp/1234567/123.tar.gz -C tmp/1234567 .'
37
+ allow(subject).to receive(:tar).and_call_original
38
+ expect(subject).to receive(:system).with(
39
+ 'tar -zcf tmp/1234567/123.tar.gz -C tmp/1234567 .'
40
+ )
37
41
  subject.url(git_repo_url, branch_name, github_repo)
38
42
  end
39
43
  end
40
44
 
41
45
  describe '#filepath' do
42
- it { expect(subject.filepath('1234567', '123')).to eq 'tmp/1234567/123.tar.gz' }
46
+ it 'should return the correct filepath' do
47
+ expect(subject.filepath('1234567', '123')).to eq 'tmp/1234567/123.tar.gz'
48
+ end
43
49
  end
44
- end
50
+ end
@@ -1,16 +1,16 @@
1
- require "spec_helper"
2
- require "support/sinatra_helper"
3
- require "sucker_punch/testing/inline"
1
+ require 'spec_helper'
2
+ require 'support/sinatra_helper'
3
+ require 'sucker_punch/testing/inline'
4
4
 
5
- describe "GitHub web hooks receiver" do
6
- it "kicks an async job doing all the work" do
7
- expected_param = { "something" => "ok" }
8
- Fourchette::PullRequest.any_instance
9
- .should_receive(:perform)
5
+ describe 'GitHub web hooks receiver' do
6
+ it 'kicks an async job doing all the work' do
7
+ expected_param = { 'something' => 'ok' }
8
+ expect_any_instance_of(Fourchette::PullRequest)
9
+ .to receive(:perform)
10
10
  .with(expected_param)
11
11
 
12
- post "/hooks",
12
+ post '/hooks',
13
13
  expected_param.to_json,
14
- "CONTENT_TYPE" => "application/json"
14
+ 'CONTENT_TYPE' => 'application/json'
15
15
  end
16
16
  end
@@ -1,29 +1,28 @@
1
- require "spec_helper"
2
- require "support/sinatra_helper"
1
+ require 'spec_helper'
2
+ require 'support/sinatra_helper'
3
3
 
4
- describe "web tarball serving" do
5
- context "valid and not expired URL" do
6
- it "returns the file" do
4
+ describe 'web tarball serving' do
5
+ context 'valid and not expired URL' do
6
+ it 'returns the file' do
7
7
  expire_in_2_secs = Time.now.to_i + 2
8
- Fourchette::Tarball.any_instance
9
- .should_receive(:filepath)
10
- .with("1234567", expire_in_2_secs.to_s)
11
- .and_return { "#{Dir.pwd}/spec/factories/fake_file" }
8
+ expect_any_instance_of(Fourchette::Tarball)
9
+ .to receive(:filepath)
10
+ .with('1234567', expire_in_2_secs.to_s) { "#{Dir.pwd}/spec/factories/fake_file" }
12
11
 
13
12
  get "/jipiboily/fourchette/1234567/#{expire_in_2_secs}"
14
- expect(last_response.headers["Content-Type"]).to eq "application/x-tgz"
15
- expect(last_response.body).to eq "some content..."
13
+ expect(last_response.headers['Content-Type']).to eq 'application/x-tgz'
14
+ expect(last_response.body).to eq 'some content...'
16
15
  end
17
16
  end
18
17
 
19
- context "expired URL" do
20
- it "does NOT returns the file if it is expired" do
18
+ context 'expired URL' do
19
+ it 'does NOT returns the file if it is expired' do
21
20
  expired_one_sec_ago = Time.now.to_i - 1
22
21
  get "/jipiboily/fourchette/1234567/#{expired_one_sec_ago}"
23
22
  expect(last_response).not_to be_ok
24
- expect(last_response.body).not_to eq("Hello World")
23
+ expect(last_response.body).not_to eq('Hello World')
25
24
  expect(last_response.status).to eq(404)
26
- subject.should_not_receive(:send_file)
25
+ expect(subject).not_to receive(:send_file)
27
26
  end
28
27
  end
29
28
  end
data/spec/spec_helper.rb CHANGED
@@ -6,4 +6,4 @@ Coveralls.wear!
6
6
  require_relative '../lib/fourchette'
7
7
 
8
8
  support_include_path = "#{Dir.pwd}/spec/support/**/*.rb"
9
- Dir[support_include_path].each {|f| require f}
9
+ Dir[support_include_path].each { |f| require f }
@@ -1,4 +1,4 @@
1
1
  Logger.class_eval do
2
- def info(*args)
2
+ def info(*_args)
3
3
  end
4
- end
4
+ end
@@ -1,4 +1,4 @@
1
- require "rack/test"
1
+ require 'rack/test'
2
2
  include Rack::Test::Methods
3
3
 
4
4
  def app
data/templates/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'puma'
4
- gem 'fourchette'
4
+ gem 'fourchette'
data/templates/Rakefile CHANGED
@@ -1 +1 @@
1
- require 'fourchette/rake_tasks'
1
+ require 'fourchette/rake_tasks'
@@ -1,9 +1,9 @@
1
- # This is a sample file to see how the really, really basic callback system works.
2
- # See the README for me or just dive in.
1
+ # This is a sample file to see how the really, really basic callback system
2
+ # works. See the README for me or just dive in.
3
3
  class Fourchette::Callbacks
4
4
  include Fourchette::Logger
5
5
 
6
- def initialize params
6
+ def initialize(params)
7
7
  @params = params
8
8
  end
9
9
 
@@ -14,4 +14,4 @@ class Fourchette::Callbacks
14
14
  def after_all
15
15
  logger.info 'Placeholder for after steps... (see callbacks.rb to override)'
16
16
  end
17
- end
17
+ end
@@ -5,4 +5,4 @@ preload_app!
5
5
 
6
6
  rackup DefaultRackup
7
7
  port ENV['PORT'] || 9292
8
- environment ENV['RACK_ENV'] || 'development'
8
+ environment ENV['RACK_ENV'] || 'development'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fourchette
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Philippe Boily
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-29 00:00:00.000000000 Z
11
+ date: 2015-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: 2.14.1
187
+ version: 3.1.0
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: 2.14.1
194
+ version: 3.1.0
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: guard-rspec
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -309,7 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
309
309
  version: '0'
310
310
  requirements: []
311
311
  rubyforge_project:
312
- rubygems_version: 2.2.2
312
+ rubygems_version: 2.4.5
313
313
  signing_key:
314
314
  specification_version: 4
315
315
  summary: Your new best friend for isolated testing environments on Heroku.