Skip to content

Commit 71f4c18

Browse files
authored
Merge pull request #35 from huginn/fix/spec-runner-ci-compat
Fix SpecRunner CI compatibility
2 parents 12c204c + 4446a90 commit 71f4c18

3 files changed

Lines changed: 49 additions & 6 deletions

File tree

lib/huginn_agent/patches/coverage.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
require 'simplecov'
22

33
if !ENV['COVERAGE']
4-
require 'coveralls'
5-
module Coveralls
6-
module Configuration
7-
def self.root
8-
File.expand_path(File.join(Dir.pwd, '../..'))
4+
begin
5+
require 'coveralls'
6+
module Coveralls
7+
module Configuration
8+
def self.root
9+
File.expand_path(File.join(Dir.pwd, '../..'))
10+
end
911
end
1012
end
13+
rescue LoadError
1114
end
1215
end
1316

lib/huginn_agent/spec_runner.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ def bundle
3737
if !File.exist?('.env')
3838
shell_out "cp .env.example .env"
3939
end
40-
shell_out "bundle install --without development production -j 4", 'Installing ruby gems ...'
40+
shell_out "bundle config set --local without 'development production'"
41+
shell_out 'bundle install -j 4', 'Installing ruby gems ...'
4142
end
4243

4344
end
4445

4546
def database
4647
Dir.chdir('spec/huginn') do
48+
remove_schema
4749
shell_out('bundle exec rake db:create db:migrate', 'Creating database ...')
4850
end
4951
end
@@ -76,5 +78,10 @@ def shell_out(command, message = nil, streaming_output = false)
7678
fail
7779
end
7880
end
81+
82+
private
83+
def remove_schema
84+
File.delete('db/schema.rb') if File.exist?('db/schema.rb')
85+
end
7986
end
8087
end

spec/lib/huginn_agent/spec_runner_spec.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,37 @@ class Bundler; def self.with_unbundled_env; yield end end
3434

3535
end
3636
end
37+
38+
context '#bundle' do
39+
before do
40+
allow(Dir).to receive(:chdir).with('spec/huginn').and_yield
41+
allow(File).to receive(:exist?).and_call_original
42+
end
43+
44+
it 'uses bundle config instead of --without' do
45+
allow(File).to receive(:exist?).with('.env').and_return(false)
46+
47+
expect(runner).to receive(:shell_out).with("cp .env.example .env").ordered
48+
expect(runner).to receive(:shell_out).with("bundle config set --local without 'development production'").ordered
49+
expect(runner).to receive(:shell_out).with('bundle install -j 4', 'Installing ruby gems ...').ordered
50+
51+
runner.bundle
52+
end
53+
end
54+
55+
context '#database' do
56+
before do
57+
allow(Dir).to receive(:chdir).with('spec/huginn').and_yield
58+
allow(File).to receive(:exist?).and_call_original
59+
end
60+
61+
it 'removes a generated schema before migrating' do
62+
allow(File).to receive(:exist?).with('db/schema.rb').and_return(true)
63+
64+
expect(File).to receive(:delete).with('db/schema.rb').ordered
65+
expect(runner).to receive(:shell_out).with('bundle exec rake db:create db:migrate', 'Creating database ...').ordered
66+
67+
runner.database
68+
end
69+
end
3770
end

0 commit comments

Comments
 (0)