diff options
-rw-r--r-- | spec/hashie/dash_spec.rb | 11 | ||||
-rw-r--r-- | spec/spec_helper.rb | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/spec/hashie/dash_spec.rb b/spec/hashie/dash_spec.rb index 453d62f..cc03128 100644 --- a/spec/hashie/dash_spec.rb +++ b/spec/hashie/dash_spec.rb @@ -12,6 +12,10 @@ class DashTest < Hashie::Dash property :count, default: 0 end +class DashTestDefaultProc < Hashie::Dash + property :fields, default: -> { [] } +end + class DashNoRequiredTest < Hashie::Dash property :first_name property :email @@ -51,6 +55,13 @@ class DeferredWithSelfTest < Hashie::Dash property :updated_at, default: ->(test) { test.created_at } end +describe DashTestDefaultProc do + it "as_json behaves correctly with default proc" do + object = described_class.new + expect(object.as_json).to be == { "fields" => [] } + end +end + describe DashTest do def property_required_error(property) [ArgumentError, "The property '#{property}' is required for #{subject.class.name}."] diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2cd68e3..726568c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,6 +10,10 @@ require 'hashie' require 'rspec/pending_for' require './spec/support/ruby_version_check' +# NOTE: should this be here? +require 'active_support' +require 'active_support/core_ext' + RSpec.configure do |config| config.extend RubyVersionCheck config.expect_with :rspec do |expect| |