Skip to content

Commit

Permalink
Favor RSpec.describe over describe.
Browse files Browse the repository at this point in the history
Add `.rspec` file and remove require statements that are no longer
needed.
  • Loading branch information
jsmestad committed Sep 24, 2017
1 parent ab33d3d commit 883f131
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 60 deletions.
3 changes: 3 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--require spec_helper
--format documentation
--color
4 changes: 1 addition & 3 deletions spec/warden/authenticated_data_store_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'

describe "authenticated data store" do
RSpec.describe "authenticated data store" do

before(:each) do
@env = env_with_params
Expand Down
4 changes: 1 addition & 3 deletions spec/warden/config_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'

describe Warden::Config do
RSpec.describe Warden::Config do

before(:each) do
@config = Warden::Config.new
Expand Down
4 changes: 1 addition & 3 deletions spec/warden/errors_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'

describe Warden::Proxy::Errors do
RSpec.describe Warden::Proxy::Errors do

before(:each) do
@errors = Warden::Proxy::Errors.new
Expand Down
4 changes: 1 addition & 3 deletions spec/warden/hooks_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'

describe "standard authentication hooks" do
RSpec.describe "standard authentication hooks" do

before(:all) do
load_strategies
Expand Down
4 changes: 1 addition & 3 deletions spec/warden/manager_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'

describe Warden::Manager do
RSpec.describe Warden::Manager do

before(:all) do
load_strategies
Expand Down
24 changes: 11 additions & 13 deletions spec/warden/proxy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'

describe Warden::Proxy do
RSpec.describe Warden::Proxy do
before(:all) do
load_strategies
end

before(:each) do
@basic_app = lambda{|env| [200,{'Content-Type' => 'text/plain'},'OK']}
@basic_app = lambda{|_env| [200,{'Content-Type' => 'text/plain'},'OK']}
@authd_app = lambda do |e|
e['warden'].authenticate
if e['warden'].authenticated?
Expand Down Expand Up @@ -48,21 +46,21 @@

it "should allow authentication in my application" do
env = env_with_params('/', :username => "fred", :password => "sekrit")
app = lambda do |_env|
_env['warden'].authenticate
expect(_env['warden']).to be_authenticated
expect(_env['warden.spec.strategies']).to eq([:password])
app = lambda do |env|
env['warden'].authenticate
expect(env['warden']).to be_authenticated
expect(env['warden.spec.strategies']).to eq([:password])
valid_response
end
setup_rack(app).call(env)
end

it "should allow me to select which strategies I use in my application" do
env = env_with_params("/", :foo => "bar")
app = lambda do |_env|
_env['warden'].authenticate(:failz)
expect(_env['warden']).not_to be_authenticated
expect(_env['warden.spec.strategies']).to eq([:failz])
app = lambda do |env|
env['warden'].authenticate(:failz)
expect(env['warden']).not_to be_authenticated
expect(env['warden.spec.strategies']).to eq([:failz])
valid_response
end
setup_rack(app).call(env)
Expand Down Expand Up @@ -730,7 +728,7 @@

it "should return false if scope cannot be retrieved from session" do
begin
Warden::Manager.serialize_from_session { |k| nil }
Warden::Manager.serialize_from_session { |_k| nil }
app = lambda do |env|
env['rack.session']['warden.user.foo_scope.key'] = "a foo user"
env['warden'].authenticated?(:foo_scope)
Expand Down
11 changes: 5 additions & 6 deletions spec/warden/scoped_session_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'

describe Warden::Manager do
RSpec.describe Warden::Manager do
before(:each) do
@env = env_with_params
@env['rack.session'] ||= {}
Expand All @@ -17,6 +15,7 @@
rescue
end
end

after(:each) do
Warden::Manager.serialize_from_session { |k| k }
Warden::Manager.serialize_into_session { |u| u }
Expand All @@ -40,14 +39,14 @@ def serializer_respond_to?(name)
end

it "should respond to {scope}_deserialize if Manager.serialize_from_session is called with scope" do
Rack::Builder.new do
Warden::Manager.serialize_from_session ( :admin ) { |n| n }
Rack::Builder.new do
Warden::Manager.serialize_from_session(:admin) { |n| n }
end
serializer_respond_to?(:admin_deserialize).should be_true
end

it "should respond to {scope}_serialize if Manager.serialize_into_session is called with scope" do
Rack::Builder.new do
Rack::Builder.new do
Warden::Manager.serialize_into_session(:admin) { |n| n }
end
serializer_respond_to?(:admin_serialize).should be_true
Expand Down
4 changes: 1 addition & 3 deletions spec/warden/session_serializer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'

describe Warden::SessionSerializer do
RSpec.describe Warden::SessionSerializer do
before(:each) do
@env = env_with_params
@env['rack.session'] ||= {}
Expand Down
4 changes: 1 addition & 3 deletions spec/warden/strategies_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'

describe Warden::Strategies do
RSpec.describe Warden::Strategies do
it "should let me add a strategy via a block" do
Warden::Strategies.add(:strategy1) do
def authenticate!
Expand Down
4 changes: 1 addition & 3 deletions spec/warden/test/helpers_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'

describe Warden::Test::Helpers do
RSpec.describe Warden::Test::Helpers do
before{ $captures = [] }
after{ Warden.test_reset! }

Expand Down
4 changes: 1 addition & 3 deletions spec/warden/test/mock_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'

describe Warden::Test::Mock do
RSpec.describe Warden::Test::Mock do
before{ $captures = [] }
after{ Warden.test_reset! }

Expand Down
26 changes: 12 additions & 14 deletions spec/warden/test/test_mode_spec.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'

describe Warden::Test::WardenHelpers do
RSpec.describe Warden::Test::WardenHelpers do
before :all do
Warden.test_mode!
end

before do
$captures = []
@app = lambda{|e| valid_response }
@app = lambda{|_e| valid_response }
end

after do
Warden.test_reset!
end

it{ expect(Warden).to respond_to(:test_mode!) }
it{ expect(Warden).to respond_to(:on_next_request) }
it{ expect(Warden).to respond_to(:test_reset!) }
it{ expect(Warden).to respond_to(:test_mode!) }
it{ expect(Warden).to respond_to(:on_next_request) }
it{ expect(Warden).to respond_to(:test_reset!) }

it "should execute the on_next_request block on the next request" do
Warden.on_next_request do |warden|
Expand All @@ -31,15 +29,15 @@
end

it "should execute many on_next_request blocks on the next request" do
Warden.on_next_request{|w| $captures << :first }
Warden.on_next_request{|w| $captures << :second }
Warden.on_next_request{|_w| $captures << :first }
Warden.on_next_request{|_w| $captures << :second }
setup_rack(@app).call(env_with_params)
expect($captures).to eq([:first, :second])
end

it "should not execute on_next_request blocks on subsequent requests" do
app = setup_rack(@app)
Warden.on_next_request{|w| $captures << :first }
Warden.on_next_request{|_w| $captures << :first }
app.call(env_with_params)
expect($captures).to eq([:first])
$captures.clear
Expand All @@ -49,17 +47,17 @@

it "should allow me to set new_on_next_request items to execute in the same test" do
app = setup_rack(@app)
Warden.on_next_request{|w| $captures << :first }
Warden.on_next_request{|_w| $captures << :first }
app.call(env_with_params)
expect($captures).to eq([:first])
Warden.on_next_request{|w| $captures << :second }
Warden.on_next_request{|_w| $captures << :second }
app.call(env_with_params)
expect($captures).to eq([:first, :second])
end

it "should remove the on_next_request items when test is reset" do
app = setup_rack(@app)
Warden.on_next_request{|w| $captures << :first }
Warden.on_next_request{|_w| $captures << :first }
Warden.test_reset!
app.call(env_with_params)
expect($captures).to eq([])
Expand All @@ -68,7 +66,7 @@
context "asset requests" do
it "should not execute on_next_request blocks if this is an asset request" do
app = setup_rack(@app)
Warden.on_next_request{|w| $captures << :first }
Warden.on_next_request{|_w| $captures << :first }
app.call(env_with_params("/assets/fun.gif"))
expect($captures).to eq([])
end
Expand Down

0 comments on commit 883f131

Please sign in to comment.