Skip to content

Commit

Permalink
Fix use of deprecated RSpec syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
ged committed Jan 14, 2014
1 parent 16f9b44 commit c6e579c
Show file tree
Hide file tree
Showing 21 changed files with 201 additions and 201 deletions.
96 changes: 48 additions & 48 deletions spec/strelka/app/auth_spec.rb
Expand Up @@ -142,31 +142,31 @@ def handle_request( req )

req = @request_factory.get( '/api/v1/string' )
expect( app ).to require_auth_for_request( req )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.get( '/api/v1/strong' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
req = @request_factory.get( '/api/v1/stri' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
req = @request_factory.get( '/api/v1/string/long' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
end

it "allows auth criteria to be declared with a regexp" do
@app.require_auth_for( %r{/str[io]} )
app = @app.new

req = @request_factory.get( '/api/v1/stri' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.get( '/api/v1/stro' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.get( '/api/v1/string' ) # not right-bound
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.get( '/api/v1/string/long' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.get( '/api/v1/other/string/long' ) # Not left-bound
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.get( '/api/v1/chatlog' ) # Not left-bound
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
end

it "allows auth criteria to be declared with a string and a block" do
Expand All @@ -177,15 +177,15 @@ def handle_request( req )
app = @app.new

req = @request_factory.get( '/api/v1/string' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
req = @request_factory.post( '/api/v1/string' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.put( '/api/v1/string' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.delete( '/api/v1/string' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.options( '/api/v1/string' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
end

it "allows auth criteria to be declared with a regexp and a block" do
Expand All @@ -196,11 +196,11 @@ def handle_request( req )
app = @app.new

req = @request_factory.get( '/api/v1/regexp' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
req = @request_factory.get( '/api/v1/regexp/a_username' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.get( '/api/v1/regexp/%20not+a+username' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
end

it "allows auth criteria to be declared with just a block" do
Expand All @@ -218,21 +218,21 @@ def handle_request( req )
app = @app.new

req = @request_factory.get( '/api/v1/strong' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.get( '/api/v1/marlon_brando' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.post( '/api/v1/somewhere' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.put( '/api/v1/somewhere' )
req.content_type = 'application/x-www-form-urlencoded'
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()

req = @request_factory.get( '/api/v1/string' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
req = @request_factory.get( '/api/v1/marlon_brando/2' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
req = @request_factory.put( '/api/v1/somewhere' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()

end

Expand All @@ -241,31 +241,31 @@ def handle_request( req )
app = @app.new

req = @request_factory.get( '/api/v1/string' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
req = @request_factory.get( '/api/v1/strong' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.get( '/api/v1/stri' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.get( '/api/v1/string/long' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
end

it "allows negative auth criteria to be declared with a regexp" do
@app.no_auth_for( %r{/str[io]} )
app = @app.new

req = @request_factory.get( '/api/v1/stri' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
req = @request_factory.get( '/api/v1/stro' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
req = @request_factory.get( '/api/v1/string' ) # not right-bound
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
req = @request_factory.get( '/api/v1/string/long' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
req = @request_factory.get( '/api/v1/other/string/long' ) # Not left-bound
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
req = @request_factory.get( '/api/v1/chat' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
end

it "allows negative auth criteria to be declared with a string and a block" do
Expand All @@ -274,17 +274,17 @@ def handle_request( req )
app = @app.new

req = @request_factory.get( '/api/v1/string' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
req = @request_factory.get( '/api/v1/strong' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.post( '/api/v1/string' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.put( '/api/v1/string' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.delete( '/api/v1/string' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.options( '/api/v1/string' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
end

it "allows negative auth criteria to be declared with a regexp and a block" do
Expand All @@ -295,13 +295,13 @@ def handle_request( req )
app = @app.new

req = @request_factory.get( '/api/v1/regexp' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.get( '/api/v1/regexp/a_username' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.get( '/api/v1/regexp/%20not+a+username' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.get( '/api/v1/regexp/guest' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()
end

it "allows negative auth criteria to be declared with just a block" do
Expand All @@ -314,11 +314,11 @@ def handle_request( req )
app = @app.new

req = @request_factory.get( '/api/v1/foom' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.post( '/api/v1/foom', :accept => 'text/plain, text/html; q=0.5' )
expect( app.request_should_auth?(req) ).to be_true()
expect( app.request_should_auth?(req) ).to be_truthy()
req = @request_factory.get( '/api/v1/foom', :accept => 'text/plain, text/html; q=0.5' )
expect( app.request_should_auth?(req) ).to be_false()
expect( app.request_should_auth?(req) ).to be_falsey()

end

Expand Down
16 changes: 8 additions & 8 deletions spec/strelka/app/filters_spec.rb
Expand Up @@ -94,20 +94,20 @@ def initialize( appid='params-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC


it "has a single request filter" do
expect( @app.request_filters ).to have(1).member
expect( @app.request_filters.size ).to eq( 1 )
end

it "has a single response filter" do
expect( @app.response_filters ).to have(1).member
expect( @app.response_filters.size ).to eq( 1 )
end

it "passes both the request and the response through it" do
req = @request_factory.get( '/account/118811' )

res = @app.new.handle( req )

expect( req.notes[:saw][:request] ).to be_true()
expect( res.notes[:saw][:response] ).to be_true()
expect( req.notes[:saw][:request] ).to be_truthy()
expect( res.notes[:saw][:response] ).to be_truthy()
end

end
Expand All @@ -132,7 +132,7 @@ def initialize( appid='params-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC


it "has a single request filter" do
expect( @app.request_filters ).to have(1).member
expect( @app.request_filters.size ).to eq( 1 )
end

it "has no response filters" do
Expand All @@ -144,7 +144,7 @@ def initialize( appid='params-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC

res = @app.new.handle( req )

expect( req.notes[:saw][:request] ).to be_true()
expect( req.notes[:saw][:request] ).to be_truthy()
expect( res.notes[:saw][:response] ).to be_nil()
end

Expand Down Expand Up @@ -174,7 +174,7 @@ def initialize( appid='params-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC
end

it "has no response filters" do
expect( @app.response_filters ).to have(1).member
expect( @app.response_filters.size ).to eq( 1 )
end

it "passes just the response through it" do
Expand All @@ -183,7 +183,7 @@ def initialize( appid='params-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC
res = @app.new.handle( req )

expect( req.notes[:saw][:request] ).to be_nil()
expect( res.notes[:saw][:response] ).to be_true()
expect( res.notes[:saw][:response] ).to be_truthy()
end

end
Expand Down
2 changes: 1 addition & 1 deletion spec/strelka/app/parameters_spec.rb
Expand Up @@ -139,7 +139,7 @@ def initialize( appid='params-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC
untaint_all_constraints true
end

expect( @app.untaint_all_constraints ).to be_true()
expect( @app.untaint_all_constraints ).to be_truthy()
req = @request_factory.get( '/user/search?username=shereshnaheth'.taint )
@app.new.handle( req )

Expand Down
26 changes: 13 additions & 13 deletions spec/strelka/app/restresources_spec.rb
Expand Up @@ -74,7 +74,7 @@ def initialize( appid='rest-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
end

it "keeps track of what resources are mounted where" do
expect( @app.resource_verbs ).to have( 1 ).member
expect( @app.resource_verbs.size ).to eq( 1 )
expect( @app.resource_verbs ).to include( 'servers' )
@app.resource_verbs[ 'servers' ].
should include( :OPTIONS, :GET, :HEAD, :POST, :PUT, :DELETE )
Expand Down Expand Up @@ -112,7 +112,7 @@ def initialize( appid='rest-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
end

it "keeps track of what resources are mounted where" do
expect( @app.resource_verbs ).to have( 1 ).member
expect( @app.resource_verbs.size ).to eq( 1 )
expect( @app.resource_verbs ).to include( 'servers' )
@app.resource_verbs[ 'servers' ].
should include( :OPTIONS, :GET, :HEAD )
Expand Down Expand Up @@ -193,7 +193,7 @@ def initialize( appid='rest-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
expect( res.content_type ).to eq( 'application/json' )
body = Yajl.load( res.body )

expect( body ).to have( 2 ).members
expect( body.size ).to eq( 2 )
expect( body.map {|record| record['uuid'] } ).to include( 'test-server', 'step-server' )
end

Expand All @@ -206,7 +206,7 @@ def initialize( appid='rest-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
expect( res.content_type ).to eq( 'application/json' )
body = Yajl.load( res.body )

expect( body ).to have( 1 ).member
expect( body.size ).to eq( 1 )
expect( body[0]['uuid'] ).to eq( 'test-server' )
end

Expand All @@ -219,7 +219,7 @@ def initialize( appid='rest-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
expect( res.content_type ).to eq( 'application/json' )
body = Yajl.load( res.body )

expect( body ).to have( 1 ).member
expect( body.size ).to eq( 1 )
expect( body[0]['uuid'] ).to eq( 'step-server' )
end

Expand All @@ -232,7 +232,7 @@ def initialize( appid='rest-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
expect( res.content_type ).to eq( 'application/json' )
body = Yajl.load( res.body )

expect( body ).to have( 2 ).members
expect( body.size ).to eq( 2 )
expect( body[0]['name'] ).to eq( 'Step' )
end

Expand All @@ -245,7 +245,7 @@ def initialize( appid='rest-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
expect( res.content_type ).to eq( 'application/json' )
body = Yajl.load( res.body )

expect( body ).to have( 2 ).members
expect( body.size ).to eq( 2 )
expect( body[0]['name'] ).to eq( 'Test' )
end

Expand Down Expand Up @@ -287,7 +287,7 @@ def initialize( appid='rest-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
body = Yajl.load( res.body )

expect( body ).to be_an( Array )
expect( body ).to have( 1 ).member
expect( body.size ).to eq( 1 )
expect( body.first ).to be_a( Hash )
expect( body.first['uuid'] ).to eq( 'test-server' )
end
Expand All @@ -301,7 +301,7 @@ def initialize( appid='rest-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
body = Yajl.load( res.body )

expect( body ).to be_an( Array )
expect( body ).to have( 1 ).member
expect( body.size ).to eq( 1 )
expect( body.first ).to be_a( Hash )
expect( body.first['port'] ).to be > 1024
end
Expand All @@ -315,7 +315,7 @@ def initialize( appid='rest-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
body = Yajl.load( res.body )

expect( body ).to be_an( Array )
expect( body ).to have( 1 ).member
expect( body.size ).to eq( 1 )
expect( body.first ).to be_a( Hash )
expect( body.first['name'] ).to eq( 'Step' )
end
Expand All @@ -329,7 +329,7 @@ def initialize( appid='rest-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
body = Yajl.load( res.body )

expect( body ).to be_an( Array )
expect( body ).to have( 4 ).members
expect( body.size ).to eq( 4 )
expect( body.first ).to be_a( Hash )
expect( body.first['server_id'] ).to eq( 1 )
expect( body.first['id'] ).to eq( 1 )
Expand All @@ -343,7 +343,7 @@ def initialize( appid='rest-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
body = Yajl.load( res.body )

expect( body ).to be_an( Array )
expect( body ).to have( 2 ).members
expect( body.size ).to eq( 2 )
expect( body.first ).to be_a( Hash )
expect( body.first['server_id'] ).to eq( 1 )
expect( body.first['id'] ).to eq( 3 )
Expand Down Expand Up @@ -515,7 +515,7 @@ def initialize( appid='rest-test', sspec=TEST_SEND_SPEC, rspec=TEST_RECV_SPEC )
end

it "has its metadata inherited by subclasses" do
expect( subject.resource_verbs ).to have( 1 ).member
expect( subject.resource_verbs.size ).to eq( 1 )
expect( subject.resource_verbs ).to include( 'servers' )
subject.resource_verbs[ 'servers' ].
should include( :OPTIONS, :GET, :HEAD, :POST, :PUT, :DELETE )
Expand Down

0 comments on commit c6e579c

Please sign in to comment.