Module: CommandHelper

Defined in:
lib/atig/command/command_helper.rb

Instance Method Summary collapse

Instance Method Details

#call(channel, command, args) ⇒ Object



86
87
88
# File 'lib/atig/command/command_helper.rb', line 86

def call(channel, command, args)
  @gateway.action.call channel, "#{command} #{args.join(' ')}", command, args
end

#init(klass) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/atig/command/command_helper.rb', line 66

def init(klass)
  @log    = mock 'log'
  @opts   = Atig::Option.new({})
  context = OpenStruct.new :log=>@log, :opts=>@opts

  @channel    = mock 'channel'
  @gateway    = FakeGateway.new @channel
  @api        = mock 'api'
  @statuses   = FakeDbEntry.new 'status DB'
  @followings = FakeDbEntry.new 'followings DB'
  @lists      = {
    "A" =>  FakeDbEntry.new('list A'),
    "B" =>  FakeDbEntry.new('list B')
  }

  @me         = user 1,'me'
  @db         = FakeDb.new @statuses, @followings, @lists, @me
  @command = klass.new context, @gateway, FakeScheduler.new(@api), @db
end

#stub_status(key, hash) ⇒ Object



90
91
92
93
94
# File 'lib/atig/command/command_helper.rb', line 90

def stub_status(key, hash)
  @statuses.stub!(key).and_return{|arg,*_|
    hash.fetch(arg, hash[:default])
  }
end