Permalink
Browse files

Merge pull request #59 from tmiller/inject-test-touchup

Make injector spec more consistent
  • Loading branch information...
2 parents f7953a8 + 85e1aa7 commit cb92a2b9240364e312d9b35765e5a7ccc6bba0eb @garybernhardt committed Sep 23, 2012
Showing with 2 additions and 3 deletions.
  1. +2 −3 spec/injector_spec.rb
View
@@ -9,6 +9,8 @@ def method_taking_only_a_block(&block); 'nothing' end
def method_taking_subject(subject); subject; end
def method_taking_optional_id(id = 0); id; end
def method_taking_optional_arg(uninjectable_optional_arg = 0); uninjectable_optional_arg; end
+ def method_taking_exception(exception); exception; end
+ def method_taking_request(rack_request); rack_request; end
let(:injector) do
Raptor::Injector.new([Raptor::Injectables::Fixed.new(:id, 5)])
@@ -65,23 +67,20 @@ def method_taking_optional_arg(uninjectable_optional_arg = 0); uninjectable_opti
end
it "injects requests once it's been given one" do
- def method_taking_request(rack_request); rack_request; end
request = stub
method = method(:method_taking_request)
injector_with_request = injector.add_request(request)
injector_with_request.call(method).should == request
end
it "injects route variables once it's been given the route path" do
- def method_taking_id(id); id; end
request = stub(:path_info => "/posts/5")
method = method(:method_taking_id)
injector_with_route_path = injector.add_route_path(request, "/posts/:id")
injector_with_route_path.call(method).should == "5"
end
it "injects an exception after being given an exception" do
- def method_taking_exception(exception); exception; end
e = RuntimeError.new
method = method(:method_taking_exception)
injector_with_exception = injector.add_exception(e)

0 comments on commit cb92a2b

Please sign in to comment.