Class: MochaRails::TestsController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/mocha_rails/tests_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



17
18
19
# File 'app/controllers/mocha_rails/tests_controller.rb', line 17

def index
  @mocha_suite = 'mocha-suite'
end

#listObject



21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/mocha_rails/tests_controller.rb', line 21

def list
  match = '*-suite.js*'
  search = File.join(@test_dir,match)
  e = Regexp.new(@test_dir + "/(.+-suite.js*)$","i")
  @mocha_suites = {}
  Dir[search].map do |path|
    text = path.gsub(e,"\\1")
    file = text.gsub(/-suite.*/,'')
    @mocha_suites[file]=text
  end
end

#pageObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/mocha_rails/tests_controller.rb', line 33

def page
  @mocha_suite = nil
  suite = params[:suite].to_s
  if suite.length == 0
    redirect_to :action => :index
    return
  end

  suite = CGI.unescape(suite)
  search = File.join(@test_dir,suite + '-suite.js*')
  files = Dir[search]
  if files.length > 0
    @mocha_suite = files.first
  end

  render :action => :index
end