aboutsummaryrefslogtreecommitdiff
path: root/spec/lib/ruleset_spec.rb
blob: 7b77e3e61468ceab58b9d078f6387e73dfe46e4e (plain)
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
# frozen_string_literal: true

require 'rspec'
require_relative '../../lib/chotto/ruleset'
require_relative '../../lib/chotto/messages'

RSpec.describe Chotto::RuleSet do
  let(:db) { instance_double('Chotto::Database') }
  let(:messages) { double('Chotto::Messages', mth: true) }
  let(:only_new) { true }
  let(:rule) do
    proc do
      messages.mth
    end
  end
  let(:subject) do
    Chotto::RuleSet.new('a name', db, only_new, rule)
  end

  describe '#run' do
    it 'evaluates the run block' do
      expect(Chotto::Messages).to receive(:new).with(db: db, only_new: true).and_return(messages)
      expect(messages).to receive(:mth)

      subject.run
    end
  end
end