Skip to content

Commit

Permalink
update rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
nov committed Aug 12, 2014
1 parent 92f171d commit 01218bc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/rack/oauth2/util.rb
Expand Up @@ -47,7 +47,7 @@ def uri_match?(base, given)
given.path = '/' if given.path.blank?
[:scheme, :host, :port].all? do |key|
base.send(key) == given.send(key)
end && /^#{base.path}/ =~ given.path
end && !!(/^#{base.path}/ =~ given.path)
rescue
false
end
Expand Down
3 changes: 2 additions & 1 deletion rack-oauth2.gemspec
Expand Up @@ -21,6 +21,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "attr_required", ">= 0.0.5"
s.add_development_dependency "rake", ">= 0.8"
s.add_development_dependency "simplecov"
s.add_development_dependency "rspec", ">= 2"
s.add_development_dependency "rspec"
s.add_development_dependency "rspec-its"
s.add_development_dependency "webmock", ">= 1.6.2"
end
14 changes: 7 additions & 7 deletions spec/rack/oauth2/oauth2_spec.rb
Expand Up @@ -5,35 +5,35 @@
after { Rack::OAuth2.debugging = false }

its(:logger) { should be_a Logger }
its(:debugging?) { should be_false }
its(:debugging?) { should == false }

describe '.debug!' do
before { Rack::OAuth2.debug! }
its(:debugging?) { should be_true }
its(:debugging?) { should == true }
end

describe '.debug' do
it 'should enable debugging within given block' do
Rack::OAuth2.debug do
Rack::OAuth2.debugging?.should be_true
Rack::OAuth2.debugging?.should == true
end
Rack::OAuth2.debugging?.should be_false
Rack::OAuth2.debugging?.should == false
end

it 'should not force disable debugging' do
Rack::OAuth2.debug!
Rack::OAuth2.debug do
Rack::OAuth2.debugging?.should be_true
Rack::OAuth2.debugging?.should == true
end
Rack::OAuth2.debugging?.should be_true
Rack::OAuth2.debugging?.should == true
end
end

describe '.http_config' do
context 'when request_filter added' do
context 'when "debug!" is called' do
after { Rack::OAuth2.reset_http_config! }

it 'should put Debugger::RequestFilter at last' do
Rack::OAuth2.debug!
Rack::OAuth2.http_config do |config|
Expand Down
14 changes: 7 additions & 7 deletions spec/rack/oauth2/util_spec.rb
Expand Up @@ -73,24 +73,24 @@
describe '.uri_match?' do
context 'when invalid URI is given' do
it do
util.uri_match?('::', '::').should be_false
util.uri_match?(123, 'http://client.example.com/other').should be_false
util.uri_match?('http://client.example.com/other', nil).should be_false
util.uri_match?('::', '::').should == false
util.uri_match?(123, 'http://client.example.com/other').should == false
util.uri_match?('http://client.example.com/other', nil).should == false
end
end

context 'when exactry same' do
it { util.uri_match?(uri, uri).should be_true }
it { util.uri_match?(uri, uri).should == true }
end

context 'when path prefix matches' do
it { util.uri_match?(uri, "#{uri}/deep_path").should be_true }
it { util.uri_match?(uri, "#{uri}/deep_path").should == true }
end

context 'otherwise' do
it do
util.uri_match?(uri, 'http://client.example.com/other').should be_false
util.uri_match?(uri, 'http://attacker.example.com/callback').should be_false
util.uri_match?(uri, 'http://client.example.com/other').should == false
util.uri_match?(uri, 'http://attacker.example.com/callback').should == false
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -5,7 +5,15 @@
end

require 'rspec'
require 'rspec/its'
require 'rack/oauth2'

RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = [:should, :expect]
end
end

require 'helpers/time'
require 'helpers/webmock_helper'

Expand Down

0 comments on commit 01218bc

Please sign in to comment.