File: example_template_spec.rb

package info (click to toggle)
ruby-guard-compat 1.2.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 140 kB
  • sloc: ruby: 350; makefile: 3
file content (30 lines) | stat: -rw-r--r-- 779 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'guard/compat/test/template'

require 'guard/compat/example'

RSpec.describe Guard::MyPlugin do
  describe 'template' do
    subject { Guard::Compat::Test::Template.new(described_class) }

    # Stub the template, because we are testing the helper, not the plugin
    let(:template_contents) do
      <<-EOS
      guard :myplugin do
        watch(/(foo).rb/) { |m| "spec/\#{m[1]}_spec.rb" }
        watch(/bar.rb/)
      end
      EOS
    end

    before do
      allow(IO).to receive(:read)
        .with('lib/guard/myplugin/templates/Guardfile')
        .and_return(template_contents)
    end

    it 'translates changes' do
      expect(subject.changed('foo.rb')).to eq(['spec/foo_spec.rb'])
      expect(subject.changed('bar.rb')).to eq(['bar.rb'])
    end
  end
end