Module: Ecology::Test

Included in:
Scope::TestCase
Defined in:
lib/ecology/test_methods.rb

Instance Method Summary collapse

Instance Method Details

#set_up_ecology(file_contents, filename = "some.ecology", options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ecology/test_methods.rb', line 3

def set_up_ecology(file_contents, filename = "some.ecology", options = {})
  match = filename.match(/^(.*)\.erb$/)
  if match
    ENV["ECOLOGY_SPEC"] = match[1]
    File.stubs(:exist?).with(match[1]).returns(false)
  else
    ENV["ECOLOGY_SPEC"] = filename
  end

  File.stubs(:exist?).with(filename + ".erb").returns(false)
  File.stubs(:exist?).with(filename).returns(true)

  unless options[:no_read]
    File.expects(:read).with(filename).returns(file_contents).at_least_once
  end
end