Sha256: baa65cb0bba623053600dfd8080343fbb60a1001ec2b3f1b55467e1275bcc85f
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
require 'assert' require 'sanford/sanford_runner' require 'sanford/runner' require 'test/support/service_handlers' class Sanford::SanfordRunner class UnitTests < Assert::Context desc "Sanford::SanfordRunner" setup do @runner_class = Sanford::SanfordRunner end subject{ @runner_class } should "be a Runner" do assert_includes Sanford::Runner, subject end should "be able to build a runner with a handler class and params and run it" do response = nil assert_nothing_raised do response = subject.run(BasicServiceHandler, {}) end assert_equal 200, response.code end end class InitTests < UnitTests desc "when init" setup do @request = Sanford::Protocol::Request.new('test', {}) @runner = @runner_class.new(BasicServiceHandler, @request) end subject{ @runner } should "run the handler and return the response it generates when run" do response = subject.run assert_instance_of Sanford::Protocol::Response, response assert_equal 200, response.code assert_equal 'Joe Test', response.data['name'] assert_equal 'joe.test@example.com', response.data['email'] end end class CallbackTests < InitTests setup do @runner = @runner_class.new(FlagServiceHandler, @request) end should "call handler `before` and `after` callbacks when run" do subject.run assert_true subject.handler.before_called assert_true subject.handler.after_called end end # live runner behavior tests are handled via system tests end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sanford-0.10.1 | test/unit/sanford_runner_tests.rb |
sanford-0.10.0 | test/unit/sanford_runner_tests.rb |