Class: Syntropy::Test
- Inherits:
-
Minitest::Test
- Object
- Minitest::Test
- Syntropy::Test
- Defined in:
- lib/syntropy/test.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
Class Method Summary collapse
Instance Method Summary collapse
- #env ⇒ Object
- #get(path, **headers) ⇒ Object
- #http_request(headers, body = nil) ⇒ Object
- #load_module(ref) ⇒ Object
- #post(path, content_type, body, **headers) ⇒ Object
- #post_form(path, form) ⇒ Object
- #post_json(path, obj) ⇒ Object
- #setup ⇒ Object
- #teardown ⇒ Object
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
17 18 19 |
# File 'lib/syntropy/test.rb', line 17 def app @app end |
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
17 18 19 |
# File 'lib/syntropy/test.rb', line 17 def machine @machine end |
Class Method Details
.env=(env) ⇒ Object
13 14 15 |
# File 'lib/syntropy/test.rb', line 13 def self.env=(env) @@env = env end |
Instance Method Details
#env ⇒ Object
19 20 21 |
# File 'lib/syntropy/test.rb', line 19 def env @@env end |
#get(path, **headers) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/syntropy/test.rb', line 31 def get(path, **headers) http_request( headers.merge( ':method' => 'GET', ':path' => path ) ) end |
#http_request(headers, body = nil) ⇒ Object
27 28 29 |
# File 'lib/syntropy/test.rb', line 27 def http_request(headers, body = nil) @test_harness.request(headers, body) end |
#load_module(ref) ⇒ Object
23 24 25 |
# File 'lib/syntropy/test.rb', line 23 def load_module(ref) app.module_loader.load(ref) end |
#post(path, content_type, body, **headers) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/syntropy/test.rb', line 40 def post(path, content_type, body, **headers) headers = headers.merge('content-type' => content_type) if content_type http_request( headers.merge( { ':method' => 'POST', ':path' => path } ), body ) end |
#post_form(path, form) ⇒ Object
57 58 59 |
# File 'lib/syntropy/test.rb', line 57 def post_form(path, form, **) post(path, 'application/x-www-form-urlencoded', URI.encode_www_form(form), **) end |
#post_json(path, obj) ⇒ Object
53 54 55 |
# File 'lib/syntropy/test.rb', line 53 def post_json(path, obj, **) post(path, 'application/json', JSON.dump(obj), **) end |
#setup ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/syntropy/test.rb', line 61 def setup raise 'Environment not set' if !@@env @machine = UM.new @app = Syntropy::App.new( root_dir: @@env[:root_dir], mount_path: '/', machine: @machine ) @test_harness = Syntropy::TestHarness.new(@app) end |
#teardown ⇒ Object
73 74 75 76 77 |
# File 'lib/syntropy/test.rb', line 73 def teardown @machine = nil @app = nil @test_harness = nil end |