• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Nu-hin / remote_ruby / 13530206102

25 Feb 2025 08:19PM UTC coverage: 90.306% (-0.3%) from 90.599%
13530206102

push

github

Nu-hin
Rename Flavours to Plugins. Allow to register plugins

38 of 39 new or added lines in 7 files covered. (97.44%)

3 existing lines in 1 file now uncovered.

885 of 980 relevant lines covered (90.31%)

59.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.86
/spec/remote_ruby/compiler_spec.rb
1
# frozen_string_literal: true
2

3
describe RemoteRuby::Compiler do
16✔
4
  subject(:compiler) do
16✔
5
    described_class.new(
160✔
6
      client_code,
7
      client_locals: client_locals,
8
      plugins: plugins
9
    )
10
  end
11

12
  let(:client_code) { '3 + 3' }
176✔
13
  let(:client_locals) { {} }
112✔
14
  let(:plugins) { [] }
192✔
15

16
  shared_context 'normal behaviour' do # rubocop:disable RSpec/ContextWording
16✔
17
    subject(:compiled_code) { compiler.compiled_code }
176✔
18

19
    it 'includes client code' do
48✔
20
      expect(compiled_code).to include(client_code)
48✔
21
    end
22

23
    # rubocop:disable Security/Eval, Style/EvalWithLocation, Style/DocumentDynamicEvalDefinition
24
    it 'produces correct code' do
48✔
25
      expect { eval("lambda { #{compiled_code} }") }.not_to raise_error
96✔
26
    end
27
    # rubocop:enable Security/Eval, Style/EvalWithLocation, Style/DocumentDynamicEvalDefinition
28
  end
29

30
  describe '#compiled_code' do
16✔
31
    include_context 'normal behaviour'
16✔
32

33
    context 'with locals' do
16✔
34
      let(:client_locals) { { a: 1, b: 'string', c: [1, 2] } }
64✔
35

36
      include_context 'normal behaviour'
16✔
37

38
      it 'includes locals serialization' do
16✔
39
        client_locals.each_key do |name|
16✔
40
          expect(compiled_code).to include("#{name} = begin")
48✔
41
        end
42
      end
43

44
      context 'when local cannot be dumped' do
16✔
45
        let(:client_locals) { { file: File.open(File::NULL, 'w') } }
32✔
46

47
        it 'prints out a warning' do
16✔
48
          expect { compiled_code }.to output(/file/).to_stderr
32✔
49
        end
50
      end
51
    end
52

53
    context 'with plugins' do
16✔
54
      let(:plugin) do
16✔
UNCOV
55
        (1..3).map do |i|
×
UNCOV
56
          instance_double(
×
57
            RemoteRuby::Plugin,
58
            code_header: "\"code header from plugin #{i}\""
59
          )
60
        end
61
      end
62

63
      include_context 'normal behaviour'
16✔
64

65
      it 'includes plugin headers' do
16✔
66
        plugins.each do |f|
16✔
UNCOV
67
          expect(compiled_code).to include(f.code_header)
×
68
        end
69
      end
70
    end
71
  end
72

73
  describe '#code_hash' do
16✔
74
    it 'produces a hash' do
16✔
75
      expect(compiler.code_hash.size).to eq(64)
16✔
76
    end
77

78
    it 'changes when code changes' do
16✔
79
      different_source_hash = described_class.new('4+4').code_hash
16✔
80
      different_locals_hash =
81
        described_class.new(client_code, client_locals: { e: 34 }).code_hash
16✔
82

83
      plugin = instance_double(RemoteRuby::Plugin, code_header: "require 'open3'")
16✔
84

85
      different_plugins_hash =
86
        described_class.new(
16✔
87
          client_code,
88
          client_locals: client_locals,
89
          plugins: [plugin]
90
        ).code_hash
91

92
      hashes = [
93
        compiler.code_hash,
16✔
94
        different_source_hash,
95
        different_locals_hash,
96
        different_plugins_hash
97
      ]
98

99
      expect(hashes.uniq.count).to eq hashes.count
16✔
100
    end
101
  end
102
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc