Skip to content

Commit

Permalink
Merge pull request #123 from hassox/update-rspec
Browse files Browse the repository at this point in the history
Update rspec after merging a bunch of PRs
  • Loading branch information
Daniel Neighman committed Dec 9, 2015
2 parents 3ac9b92 + 749e57e commit 06860f0
Show file tree
Hide file tree
Showing 14 changed files with 390 additions and 385 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ gem 'rake'
gem 'rack', '1.3'

group :test do
gem 'rspec', '~>2'
gem 'rspec', '~>3'
gem 'rack-test'
end
25 changes: 15 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ PATH
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.1.3)
diff-lcs (1.2.5)
rack (1.3.0)
rack-test (0.6.0)
rack (>= 1.0)
rake (0.8.7)
rspec (2.10.0)
rspec-core (~> 2.10.0)
rspec-expectations (~> 2.10.0)
rspec-mocks (~> 2.10.0)
rspec-core (2.10.1)
rspec-expectations (2.10.0)
diff-lcs (~> 1.1.3)
rspec-mocks (2.10.1)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-core (3.3.2)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)

PLATFORMS
ruby
Expand All @@ -28,7 +33,7 @@ DEPENDENCIES
rack (= 1.3)
rack-test
rake
rspec (~> 2)
rspec (~> 3)
warden!

BUNDLED WITH
Expand Down
2 changes: 1 addition & 1 deletion lib/warden/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# encoding: utf-8
module Warden
VERSION = "1.2.3".freeze
VERSION = "1.2.4".freeze
end
36 changes: 18 additions & 18 deletions spec/warden/authenticated_data_store_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
app = lambda do |e|
e['warden'].authenticate(:pass)
e['warden'].authenticate(:pass, :scope => :foo)
e['warden'].should be_authenticated
e['warden'].should be_authenticated(:foo)
expect(e['warden']).to be_authenticated
expect(e['warden']).to be_authenticated(:foo)

# Store the data for :default
e['warden'].session[:key] = "value"
valid_response
end
setup_rack(app).call(@env)
@env['rack.session']['warden.user.default.session'].should eq({:key => "value"})
@env['rack.session']['warden.user.foo.session'].should be_nil
expect(@env['rack.session']['warden.user.default.session']).to eq(key: "value")
expect(@env['rack.session']['warden.user.foo.session']).to be_nil
end

it "should store data for the foo user" do
Expand All @@ -34,7 +34,7 @@
valid_response
end
setup_rack(app).call(@env)
@env['rack.session']['warden.user.foo.session'].should eq({:key => "value"})
expect(@env['rack.session']['warden.user.foo.session']).to eq(key: "value")
end

it "should store the data separately" do
Expand All @@ -44,8 +44,8 @@
valid_response
end
setup_rack(app).call(@env)
@env['rack.session']['warden.user.default.session'].should eq({:key => "value"})
@env['rack.session']['warden.user.foo.session' ].should eq({:key => "another value"})
expect(@env['rack.session']['warden.user.default.session']).to eq(key: "value")
expect(@env['rack.session']['warden.user.foo.session' ]).to eq(key: "another value")
end

it "should clear the foo scoped data when foo logs out" do
Expand All @@ -56,8 +56,8 @@
valid_response
end
setup_rack(app).call(@env)
@env['rack.session']['warden.user.default.session'].should eq({:key => "value"})
@env['rack.session']['warden.user.foo.session' ].should be_nil
expect(@env['rack.session']['warden.user.default.session']).to eq(key: "value")
expect(@env['rack.session']['warden.user.foo.session' ]).to be_nil
end

it "should clear out the default data when :default logs out" do
Expand All @@ -68,8 +68,8 @@
valid_response
end
setup_rack(app).call(@env)
@env['rack.session']['warden.user.default.session'].should be_nil
@env['rack.session']['warden.user.foo.session' ].should eq({:key => "another value"})
expect(@env['rack.session']['warden.user.default.session']).to be_nil
expect(@env['rack.session']['warden.user.foo.session' ]).to eq(key: "another value")
end

it "should clear out all data when a general logout is performed" do
Expand All @@ -80,8 +80,8 @@
valid_response
end
setup_rack(app).call(@env)
@env['rack.session']['warden.user.default.session'].should be_nil
@env['rack.session']['warden.user.foo.session' ].should be_nil
expect(@env['rack.session']['warden.user.default.session']).to be_nil
expect(@env['rack.session']['warden.user.foo.session' ]).to be_nil
end

it "should logout multiple persons at once" do
Expand All @@ -95,9 +95,9 @@
valid_response
end
setup_rack(app).call(@env)
@env['rack.session']['warden.user.default.session'].should be_nil
@env['rack.session']['warden.user.foo.session' ].should eq({:key => "another value"})
@env['rack.session']['warden.user.bar.session' ].should be_nil
expect(@env['rack.session']['warden.user.default.session']).to be_nil
expect(@env['rack.session']['warden.user.foo.session' ]).to eq(key: "another value")
expect(@env['rack.session']['warden.user.bar.session' ]).to be_nil
end

it "should not store data for a user who is not logged in" do
Expand All @@ -107,8 +107,8 @@
valid_response
end

lambda do
expect {
setup_rack(app).call(@env)
end.should raise_error(Warden::NotAuthenticated)
}.to raise_error(Warden::NotAuthenticated)
end
end
20 changes: 10 additions & 10 deletions spec/warden/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,40 @@

it "should behave like a hash" do
@config[:foo] = :bar
@config[:foo].should be(:bar)
expect(@config[:foo]).to eq(:bar)
end

it "should provide hash accessors" do
@config.failure_app = :foo
@config[:failure_app].should be(:foo)
expect(@config[:failure_app]).to eq(:foo)
@config[:failure_app] = :bar
@config.failure_app.should be(:bar)
expect(@config.failure_app).to eq(:bar)
end

it "should allow to read and set default strategies" do
@config.default_strategies :foo, :bar
@config.default_strategies.should eq([:foo, :bar])
expect(@config.default_strategies).to eq([:foo, :bar])
end

it "should allow to silence missing strategies" do
@config.silence_missing_strategies!
@config.silence_missing_strategies?.should be_true
expect(@config.silence_missing_strategies?).to eq(true)
end

it "should set the default_scope" do
@config.default_scope.should be(:default)
expect(@config.default_scope).to eq(:default)
@config.default_scope = :foo
@config.default_scope.should be(:foo)
expect(@config.default_scope).to eq(:foo)
end

it "should merge given options on initialization" do
Warden::Config.new(:foo => :bar)[:foo].should be(:bar)
expect(Warden::Config.new(:foo => :bar)[:foo]).to eq(:bar)
end

it "should setup defaults with the scope_defaults method" do
c = Warden::Config.new
c.scope_defaults :foo, :strategies => [:foo, :bar], :store => false
c.default_strategies(:scope => :foo).should eq([:foo, :bar])
c.scope_defaults(:foo).should eq({:store => false})
expect(c.default_strategies(:scope => :foo)).to eq([:foo, :bar])
expect(c.scope_defaults(:foo)).to eq(store: false)
end
end
14 changes: 7 additions & 7 deletions spec/warden/errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,40 @@
end

it "should report that it is empty on first creation" do
@errors.empty?.should be_true
expect(@errors).to be_empty
end

it "should continue to report that it is empty even after being checked" do
@errors.on(:foo)
@errors.empty?.should be_true
expect(@errors).to be_empty
end

it "should add an error" do
@errors.add(:login, "Login or password incorrect")
@errors[:login].should eq(["Login or password incorrect"])
expect(@errors[:login]).to eq(["Login or password incorrect"])
end

it "should allow many errors to be added to the same field" do
@errors.add(:login, "bad 1")
@errors.add(:login, "bad 2")
@errors.on(:login).should eq(["bad 1", "bad 2"])
expect(@errors.on(:login)).to eq(["bad 1", "bad 2"])
end

it "should give the full messages for an error" do
@errors.add(:login, "login wrong")
@errors.add(:password, "password wrong")
["password wrong", "login wrong"].each do |msg|
@errors.full_messages.should include(msg)
expect(@errors.full_messages).to include(msg)
end
end

it "should return the error for a specific field / label" do
@errors.add(:login, "wrong")
@errors.on(:login).should eq(["wrong"])
expect(@errors.on(:login)).to eq(["wrong"])
end

it "should return nil for a specific field if it's not been set" do
@errors.on(:not_there).should be_nil
expect(@errors.on(:not_there)).to be_nil
end

end
Loading

0 comments on commit 06860f0

Please sign in to comment.