Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failing test for Dash default with proc not working with AS as_json #363

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions spec/hashie/dash_spec.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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}."]
Expand Down
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -10,6 +10,10 @@
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|
Expand Down