Sha256: 8317395af054551701559ae381a7154de6b5788249bc2b966d9f693978a49ee8

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

describe ":methods options" do

  describe "string attribute" do
    describe "default methods" do
      let(:model_klass) do
        _person = Person.dup
        _person.instance_eval do
          include AttributeEnums::ActiveRecord
          attribute_enums :gender, in: [:male, :female], ask_methods: true
        end
        _person
      end

      subject { model_klass.new }

      it do
        subject.should respond_to(:male?)
        subject.should respond_to(:female?)
      end
      it do
        subject.gender = :male
        subject.male?.should be_true
        subject.female?.should be_false
      end
    end
  

    describe "prefix methods" do
      let(:model_klass) do
        _person = Person.dup
        _person.instance_eval do
          include AttributeEnums::ActiveRecord
          attribute_enums :gender, in: [:male, :female], ask_methods: {prefix: 'gender_'}
        end
        _person
      end

      subject { model_klass.new }

      it do
        subject.should respond_to(:gender_male?)
      end
      it do
        subject.gender = :male
        subject.gender_male?.should be_true
      end
    end
  end


  describe "boolean attribute" do
    # this option is invalid boolean attribute.
  end


end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
attribute_enums-0.2.2 spec/common_and_active_record/ask_methods_options_spec.rb
attribute_enums-0.2.1 spec/common_and_active_record/ask_methods_options_spec.rb
attribute_enums-0.2.0 spec/common_and_active_record/ask_methods_options_spec.rb