Sha256: fe7f733ab9bd1c48e3671375eb14e6cdda4af19686d8c852a2187def724eea86

Contents?: true

Size: 1.4 KB

Versions: 7

Compression:

Stored size: 1.4 KB

Contents

#
# field_spec.rb
# Crowdskout
#
# Copyright (c) 2016 Kyle Schutt. All rights reserved.require 'spec_helper'

require 'spec_helper'

describe Crowdskout::Components::Field do
  context "hash value" do 
    before do 
      @json_string = %[{
                          "Gender" : {
                              "id" : 1,
                              "value" : "Male"
                            }
                        }]
      @hash = JSON.parse(@json_string)
    end

    it "creates a component" do
      component = Crowdskout::Components::Field.create(@hash)
      expect(component.key_name).to eq "Gender"
      component.value.should be_kind_of(Crowdskout::Components::Value)
    end
    it "generates the correct json object" do 
      component = Crowdskout::Components::Field.create(@hash)
      expect(JSON.parse(component.to_json)).to eq @hash
    end
  end
  context "string value" do 
    before do 
      @json_string = %[{
                          "Gender" : "Male"
                        }]
      @hash = JSON.parse(@json_string)
    end

    it "creates a component" do
      component = Crowdskout::Components::Field.create(@hash)
      expect(component.key_name).to eq "Gender"
      expect(component.value).to eq "Male"
    end
    it "generates the correct json object" do 
      component = Crowdskout::Components::Field.create(@hash)
      expect(JSON.parse(component.to_json)).to eq @hash
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
crowdskout-0.0.19 spec/crowdskout/components/profiles/field_spec.rb
crowdskout-0.0.13 spec/crowdskout/components/profiles/field_spec.rb
crowdskout-0.0.10 spec/crowdskout/components/profiles/field_spec.rb
crowdskout-0.0.9 spec/crowdskout/components/profiles/field_spec.rb
crowdskout-0.0.8 spec/crowdskout/components/profiles/field_spec.rb
crowdskout-0.0.7 spec/crowdskout/components/profiles/field_spec.rb
crowdskout-0.0.6 spec/crowdskout/components/profiles/field_spec.rb