Skip to content

Commit

Permalink
Tuning Coveralls
Browse files Browse the repository at this point in the history
  • Loading branch information
Nu-hin committed Aug 31, 2018
1 parent 363df24 commit 166ea4a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
16 changes: 16 additions & 0 deletions spec/remote_ruby/execution_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@

expect do
execution_context.execute(s: s) do
# :nocov:
puts s
# :nocov:
end
end.to output(Regexp.new(s)).to_stdout
end
Expand All @@ -41,7 +43,9 @@

it 'creates cache files' do
execution_context.execute do
# :nocov:
0
# :nocov:
end

expect(Dir.glob(File.join(cache_dir, '*'))).not_to be_empty
Expand All @@ -57,14 +61,18 @@

it 'uses cache' do
caching_context.execute do
# :nocov:
10
# :nocov:
end

expect(execution_context).to receive(:cache_adapter).and_call_original
expect(::RemoteRuby::CacheAdapter).to receive(:new).and_call_original

res = execution_context.execute do
# :nocov:
10
# :nocov:
end

expect(res).to eq(10)
Expand All @@ -76,7 +84,9 @@
ec = execution_context

res = ec.execute do
# :nocov:
defined?(ec)
# :nocov:
end

expect(res).to be_falsey
Expand All @@ -99,7 +109,9 @@

it 'includes Rails loading code' do
res = execution_context.execute do
# :nocov:
ENV['RAILS_ENV']
# :nocov:
end

expect(res).to eq('production')
Expand All @@ -119,15 +131,19 @@

it 'redirects stdout to the specified stream' do
execution_context.execute do
# :nocov:
puts 'Hello'
# :nocov:
end

expect(out_str.string).to include('Hello')
end

it 'redirects stderr to the specified stream' do
execution_context.execute do
# :nocov:
warn 'Error'
# :nocov:
end

expect(err_str.string).to include('Error')
Expand Down
7 changes: 3 additions & 4 deletions spec/remote_ruby/locals_extractor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ def fetch_block(&block)
expect(extractor.locals).to include(int_value: int_value)
end

# rubocop:disable Lint/UselessAssignment
context 'with excluded types' do
it 'ignores specified types' do
int_value = 5
string_value = 'A string'

block = fetch_block do
puts int_value
puts string_value
end
block = fetch_block {}

extractor = described_class.new(block, ignore_types: String)
expect(extractor.locals).to include(:int_value)
expect(extractor.locals).not_to include(:string_value)
end
end
# rubocop:enable Lint/UselessAssignment
end
16 changes: 16 additions & 0 deletions spec/remote_ruby/source_extractor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
context 'without arguments' do
it 'returns correct value' do
res = subject.extract do
# :nocov:
a.foo1
foo2
foo3(bar)
Expand All @@ -37,6 +38,7 @@

return 6 unless y
y
# :nocov:
end

expect(res).to eq(desired_result)
Expand All @@ -46,6 +48,7 @@
context 'with arguments' do
it 'returns correct value' do
res = subject.extract do |context, a, b|
# :nocov:
a.foo1
foo2
foo3(bar)
Expand All @@ -59,6 +62,7 @@
return 6
end
y
# :nocov:
end

expect(res).to eq(desired_result)
Expand All @@ -70,23 +74,27 @@
context 'ill-formatted' do
context 'without arguments' do
it 'returns correct value' do
# :nocov:
res = subject.extract do a.foo1; foo2; foo3(bar); x = 3
y = 5 if x == 4
return 6 unless y
y
end
# :nocov:

expect(res).to eq(desired_result)
end
end

context 'with arguments' do
it 'returns correct value' do
# :nocov:
res = subject.extract do |context, a, b| a.foo1; foo2; foo3(bar); x = 3
y = 5 if x == 4
return 6 unless y
y
end
# :nocov:

expect(res).to eq(desired_result)
end
Expand All @@ -100,15 +108,19 @@
context 'well-formatted' do
context 'without arguments' do
it 'returns correct value' do
# :nocov:
res = subject.extract { a.foo1; foo2; foo3(bar); x = 3; y = 5 if x == 4; return 6 unless y; y }
# :nocov:

expect(res).to eq(desired_result)
end
end

context 'with arguments' do
it 'returns correct value' do
# :nocov:
res = subject.extract { |context, a, b| a.foo1; foo2; foo3(bar); x = 3; y = 5 if x == 4; return 6 unless y; y }
# :nocov:

expect(res).to eq(desired_result)
end
Expand All @@ -121,6 +133,7 @@
context 'without arguments' do
it 'returns correct value' do
res = subject.extract {
# :nocov:
a.foo1
foo2
foo3(bar)
Expand All @@ -132,6 +145,7 @@

return 6 unless y
y
# :nocov:
}

expect(res).to eq(desired_result)
Expand All @@ -140,6 +154,7 @@

context 'with arguments' do
it 'returns correct value' do
# :nocov:
res = subject.extract { |context, a, b|
a.foo1
foo2
Expand All @@ -153,6 +168,7 @@
return 6 unless y
y
}
# :nocov:

expect(res).to eq(desired_result)
end
Expand Down
6 changes: 6 additions & 0 deletions spec/remote_ruby_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@
.with(**args).and_return(double(:ec, execute: nil))

remotely(**args) do
# :nocov:
puts 'Hello RemoteRuby'
# :nocov:
end
end

it 'returns block result' do
res = remotely(**args) do
# :nocov:
{ username: 'John' }
# :nocov:
end

expect(res).to eq(username: 'John')
Expand All @@ -36,7 +40,9 @@
a = 3

remotely(**args) do
# :nocov:
a = 4
# :nocov:
end

expect(a).to eq(4)
Expand Down
7 changes: 6 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
require 'bundler/setup'
require 'coveralls'
Coveralls.wear!
require 'simplecov'

SimpleCov.formatter = Coveralls::SimpleCov::Formatter
SimpleCov.start do
add_filter 'spec/integration'
end
require 'remote_ruby'

require_relative 'integration/config'
Expand Down

0 comments on commit 166ea4a

Please sign in to comment.