Sha256: cb577efd51c62ed08418261d99eef33db95759d9146d093138bbddaa70a6a4ce
Contents?: true
Size: 1.69 KB
Versions: 4
Compression:
Stored size: 1.69 KB
Contents
require 'spec_helper' #Rspec 1 doesn't correctly pass blocks to stubs, so skip (covered by integration tests) #https://groups.google.com/forum/?fromgroups=#!topic/rspec/XT7paH2asCo if Jasmine::Dependencies.rspec2? describe "Jasmine::Application" do it "should map paths provided by the config" do handler1 = double(:handler1) handler2 = double(:handler2) app1 = double(:app1) app2 = double(:app2) rack_path_map = {"/foo" => lambda { handler1 }, "/bar" => lambda { handler2 }} config = double(:config, :rack_path_map => rack_path_map, :rack_apps => []) builder = double("Rack::Builder.new") #Rack::Builder instance evals, so builder.run is invalid syntax, #this is the only way to stub out the 'run' dsl it gives to the block. Jasmine::Application.stub(:run).with(handler1).and_return(app1) Jasmine::Application.stub(:run).with(handler2).and_return(app2) builder.should_receive(:map).twice do |path, &app| if path == '/foo' app.call.should == app1 elsif path == '/bar' app.call.should == app2 else raise "Unexpected path passed" end end Jasmine::Application.app(config, builder).should == builder end it "should run rack apps provided by the config" do app1 = double(:app1) app2 = double(:app2) block = lambda { "foo" } config = double(:config, :rack_path_map => [], :rack_apps => [[app1, nil], [app2, block]]) builder = double("Rack::Builder.new") builder.should_receive(:use).with(app1) builder.should_receive(:use).with(app2, &block) Jasmine::Application.app(config, builder).should == builder end end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
jasmine-multi_json-1.3.2.1 | spec/application_spec.rb |
jasmine-1.3.2 | spec/application_spec.rb |
jasmine-multi_json-1.3.1.1 | spec/application_spec.rb |
jasmine-1.3.1 | spec/application_spec.rb |