spec/praxis/router_spec.rb in praxis-0.21 vs spec/praxis/router_spec.rb in praxis-0.22.pre.1

- old
+ new

@@ -1,8 +1,13 @@ require 'spec_helper' describe Praxis::Router do + let(:application) do + app = Praxis::Application.new(skip_registration: true) + app.versioning_scheme = [:header, :params] + app + end describe Praxis::Router::VersionMatcher do let(:resource_definition){ double("resource_definition", version_options: { using: [:header, :params] }) } let(:action){ double("action", resource_definition: resource_definition ) } let(:target){ double("target", action: action ) } let(:args){ {version: "1.0"} } @@ -15,11 +20,11 @@ end end context '.call' do let(:env){ {"HTTP_X_API_VERSION" => request_version } } - let(:request) {Praxis::Request.new(env)} + let(:request) {Praxis::Request.new(env,application: application)} context 'with matching versions' do let(:request_version) { "1.0" } it 'calls the target' do expect(target).to receive(:call).with(request) @@ -65,11 +70,10 @@ expect(request_router.string_for(request)).to eq('path') end end end - let(:application) { instance_double('Praxis::Application')} subject(:router) {Praxis::Router.new(application)} context "attributes" do its(:request_class) {should be(Praxis::Request)} end @@ -102,11 +106,11 @@ context ".call" do let(:env){ {"PATH_INFO"=>request_path_info, "REQUEST_METHOD"=>request_verb} } let(:request_verb) { 'POST' } let(:request_path_info) { '/' } let(:request_version){ nil } - let(:request) {Praxis::Request.new(env)} + let(:request) {Praxis::Request.new(env, application: application)} let(:router_response){ 1 } let(:router_response_for_post){ "POST result" } let(:router_response_for_wildcard){ "* result" } let(:post_target_router){ double("POST target", call: router_response_for_post) } let(:any_target_router){ double("ANY target", call: router_response_for_wildcard) } @@ -183,10 +187,10 @@ expect(headers).to have_key('X-Cascade') expect(headers['X-Cascade']).to eq('pass') end context 'with X-Cascade disabled' do - let(:config) { Praxis::Application.instance.config.praxis } + let(:config) { application.config.praxis } before do expect(config).to receive(:x_cascade).and_return(false) end it 'does not set X-Cascade: pass' do