class Object

Constants

VERSION

Public Instance Methods

fixture(name) click to toggle source

Reads and returns fixture contents as a String.

# File lib/mimi/cli/template/spec/support/fixtures.rb, line 11
def fixture(name)
  File.read(fixture_path(name))
end
fixture_json(name) click to toggle source

Reads and returns fixture contents parsed from a JSON string.

# File lib/mimi/cli/template/spec/support/fixtures.rb, line 17
def fixture_json(name)
  JSON.parse(fixture("#{name}.json"))
end
fixture_path(*name) click to toggle source

Returns pathname of the given fixture or folder in fixtures

# File lib/mimi/cli/template/spec/support/fixtures.rb, line 5
def fixture_path(*name)
  Pathname.pwd.join('spec', 'fixtures', *name)
end
with_env_vars(filename = nil) { || ... } click to toggle source

Runs block with ENV variables loaded from specified file, restores original ENV variables after.

@example

with_env_vars('.env.test') do
  application.config.load
end
# File lib/mimi/cli/template/spec/support/envvars.rb, line 11
def with_env_vars(filename = nil, &_block)
  original_env_vars = ENV.to_hash
  Dotenv.load(filename) if filename
  yield
ensure
  ENV.replace(original_env_vars)
end