test/unit/sinatra_runner_tests.rb in deas-0.23.1 vs test/unit/sinatra_runner_tests.rb in deas-0.23.2

- old
+ new

@@ -4,11 +4,11 @@ require 'deas/template' require 'deas/sinatra_runner' class Deas::SinatraRunner - class BaseTests < Assert::Context + class UnitTests < Assert::Context desc "Deas::SinatraRunner" setup do @fake_sinatra_call = FakeSinatraCall.new @runner = Deas::SinatraRunner.new(FlagViewHandler, @fake_sinatra_call) end @@ -80,11 +80,11 @@ assert_equal exp_result, subject.render('index') end end - class RunTests < BaseTests + class RunTests < UnitTests desc "run" setup do @return_value = @runner.run @handler = @runner.instance_variable_get("@handler") end @@ -100,9 +100,48 @@ assert_equal true, subject.run_bang_called end should "return the handler's run! return value" do assert_equal true, @return_value + end + + end + + class ParamsTests < UnitTests + desc "normalizing params" + + should "convert any non-string hash keys to string keys" do + exp_params = { + 'a' => 'aye', + 'b' => 'bee', + 'attachment' => { + 'tempfile' => 'a-file', + 'content_type' => 'whatever' + }, + 'attachments' => [ + { 'tempfile' => 'a-file' }, + { 'tempfile' => 'b-file' } + ] + } + assert_equal exp_params, runner_params({ + :a => 'aye', + 'b' => 'bee', + 'attachment' => { + :tempfile => 'a-file', + :content_type => 'whatever' + }, + 'attachments' => [ + { :tempfile => 'a-file' }, + { 'tempfile' => 'b-file' } + ] + }) + end + + private + + def runner_params(params) + @fake_sinatra_call.params = params + Deas::SinatraRunner.new(FlagViewHandler, @fake_sinatra_call).params end end end