Logo: Relish

  1. Sign in

Project: Appsent 0.1.0.rc1

Simple usage example

Background
Given
a file named "Conffile" with:
mongodb do
  host  String, 'Host to connect to MongoDB' => 'localhost'
  port  Fixnum, 'MongoDB port'               => 27017
end
And
a file named "my_app.rb" with:
require 'appsent'

AppSent.init :path => 'config', :env => 'production'

puts 'All stuff work!'
Scenarios
config does not exist
When
I run ruby my_app.rb
Then
the output should contain:
missing config file 'config/mongodb.yml'
Config has no environment
When
I add file named "config/mongodb.yml"
And
I run ruby my_app.rb
Then
the output should contain:
config file 'config/mongodb.yml' has no 'production' environment
required parameteres do not specified
When
I write to "config/mongodb.yml" with:
production:
  optional_value: temp
And
I run ruby my_app.rb
Then
the output should contain:
wrong config file 'config/mongodb.yml':
  host: localhost # does not exist(Host to connect to MongoDB), String
  port: 27017 # does not exist(MongoDB port), Fixnum
Some parameter is wrong type
When
I write to "config/mongodb.yml" following:
production:
  host: 100500
  port: 27017
And
I run ruby my_app.rb
Then
the output should contain:
wrong config file 'config/mongodb.yml':
  host: 100500 # wrong type,should be String(Host to connect to MongoDB)
All config present and have right values
When
I write to "config/mongodb.yml" following:
production:
  host: 'somehost.com'
  port: 27017
And
I run ruby my_app.rb
Then
the output should contain:
All stuff work!

Last published over 7 years ago by kucaahbe.