From 01218bcfa505f15d6911221f9dc69f40935b1dfd Mon Sep 17 00:00:00 2001 From: nov Date: Fri, 18 Jul 2014 16:03:12 +0900 Subject: [PATCH] update rspec --- lib/rack/oauth2/util.rb | 2 +- rack-oauth2.gemspec | 3 ++- spec/rack/oauth2/oauth2_spec.rb | 14 +++++++------- spec/rack/oauth2/util_spec.rb | 14 +++++++------- spec/spec_helper.rb | 8 ++++++++ 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/rack/oauth2/util.rb b/lib/rack/oauth2/util.rb index a7cd7cd..e09149a 100644 --- a/lib/rack/oauth2/util.rb +++ b/lib/rack/oauth2/util.rb @@ -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 diff --git a/rack-oauth2.gemspec b/rack-oauth2.gemspec index b70893c..322f6e1 100644 --- a/rack-oauth2.gemspec +++ b/rack-oauth2.gemspec @@ -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 diff --git a/spec/rack/oauth2/oauth2_spec.rb b/spec/rack/oauth2/oauth2_spec.rb index 7e83e69..e8b7027 100644 --- a/spec/rack/oauth2/oauth2_spec.rb +++ b/spec/rack/oauth2/oauth2_spec.rb @@ -5,27 +5,27 @@ 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 @@ -33,7 +33,7 @@ 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| diff --git a/spec/rack/oauth2/util_spec.rb b/spec/rack/oauth2/util_spec.rb index d0f9159..8272b7c 100644 --- a/spec/rack/oauth2/util_spec.rb +++ b/spec/rack/oauth2/util_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ef45756..e0b5c95 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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'