Class: RenamerMock

Inherits:
Renamer show all
Defined in:
lib/test/test_helper.rb

Instance Attribute Summary collapse

Attributes included from Options

#options

Instance Method Summary collapse

Methods inherited from Renamer

#rename_functions

Methods included from Options

#opt, #opt_if

Instance Attribute Details

#renamesObject (readonly)

Returns the value of attribute renames.



13
14
15
# File 'lib/test/test_helper.rb', line 13

def renames
  @renames
end

Instance Method Details

#actual_delete(fn) ⇒ Object



61
62
63
# File 'lib/test/test_helper.rb', line 61

def actual_delete(fn)
  @renames << [fn, :deleted]
end

#actual_delete_origObject



59
# File 'lib/test/test_helper.rb', line 59

alias actual_delete_orig actual_delete

#actual_rename(o, n) ⇒ Object



55
56
57
# File 'lib/test/test_helper.rb', line 55

def actual_rename(o, n)
  @renames << [o, n]
end

#actual_rename_origObject



53
# File 'lib/test/test_helper.rb', line 53

alias actual_rename_orig actual_rename

#rename(path, oldfn, newfn, full_path = false) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/test/test_helper.rb', line 37

def rename(path, oldfn, newfn, full_path = false)
  super
  if @onrename
    r = @onrename.call(:path => path,
                 :oldfn => oldfn,
                 :newfn => newfn,
                 :full_path => full_path,
                 :result => @result,
                 :result_type => @result_type, 
                 :result_path => @result_path, 
                 :result_file => @result_file,
                 :confirm => @confirm)
    @yielded = true
  end
end

#run(name, options, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/test/test_helper.rb', line 15

def run(name, options, &block)
  @onrename = block
  @renames = []
  @yielded = true
  p = options[:file_provider]
  if p.methods.include? "on_after"
    p.on_after do
      unless @onrename and @yielded
        @onrename.call :result => @result, :result_type => @result_type, :result_path => @result_path, :result_file => @result_file
        @yielded = true
      end
    end
  end
  super(name, options) do |rtype, result, path, file|
    @result = result
    @result_type = rtype
    @result_path = path
    @result_file = file
    @yielded = false
  end
end