File: null_object_builder_spec.rb

package info (click to toggle)
ruby-naught 1.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 276 kB
  • sloc: ruby: 1,091; makefile: 6
file content (31 lines) | stat: -rw-r--r-- 960 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
31
require 'spec_helper'

module Naught
  class NullClassBuilder
    module Commands
      class TestCommand
      end
    end
  end

  describe NullClassBuilder do
    subject(:builder) { NullClassBuilder.new }
    it 'responds to commands defined in NullObjectBuilder::Commands' do
      expect(builder).to respond_to(:test_command)
    end

    it 'translates method calls into command invocations including arguments' do
      test_command = double
      expect(NullClassBuilder::Commands::TestCommand).to receive(:new).
        with(builder, 'foo', 42).
        and_return(test_command)
      expect(test_command).to receive(:call).and_return('COMMAND RESULT')
      expect(builder.test_command('foo', 42)).to eq('COMMAND RESULT')
    end

    it 'handles missing non-command missing methods normally' do
      expect(builder).not_to respond_to(:nonexistant_method)
      expect { builder.nonexistent_method }.to raise_error(NoMethodError)
    end
  end
end