Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Block in Strategy.configure can return nil

  • Loading branch information...
commit 9d4801fc9bf7892ce946cfa9e2199262fa1cdc3b 1 parent e515908
@nashbridges nashbridges authored
Showing with 20 additions and 6 deletions.
  1. +5 −2 lib/omniauth/strategy.rb
  2. +15 −4 spec/omniauth/strategy_spec.rb
View
7 lib/omniauth/strategy.rb
@@ -50,8 +50,11 @@ def default_options
# configure foo: 'bar'
# end
def configure(options = nil)
- yield default_options and return unless options
- default_options.deep_merge!(options)
+ if block_given?
+ yield default_options
+ else
+ default_options.deep_merge!(options)
+ end
end
# Directly declare a default option for your class. This is a useful from
View
19 spec/omniauth/strategy_spec.rb
@@ -28,11 +28,22 @@ def make_env(path = '/auth/test', props = {})
describe ".configure" do
subject { klass = Class.new; klass.send :include, OmniAuth::Strategy; klass }
- it "takes a block and allow for default options setting" do
- subject.configure do |c|
- c.wakka = 'doo'
+ context "when block is passed" do
+ it "allows for default options setting" do
+ subject.configure do |c|
+ c.wakka = 'doo'
+ end
+ expect(subject.default_options["wakka"]).to eq("doo")
+ end
+
+ it "works when block doesn't evaluate to true" do
+ environment_variable = nil
+ subject.configure do |c|
+ c.abc = '123'
+ c.hgi = environment_variable
+ end
+ expect(subject.default_options["abc"]).to eq("123")
end
- expect(subject.default_options["wakka"]).to eq("doo")
end
it "takes a hash and deep merge it" do
Please sign in to comment.
Something went wrong with that request. Please try again.