Sha256: 1cac94e39b816dd4306744f3bcc6a67ff7b09f6ccbb1967b94ec32864a6a4853

Contents?: true

Size: 1.06 KB

Versions: 142

Compression:

Stored size: 1.06 KB

Contents

require "spec_helper"

describe "syntax methods within dynamic attributes" do
  before do
    define_model("Post", title: :string, user_id: :integer) do
      belongs_to :user

      def generate
        "generate result"
      end
    end
    define_model("User", email: :string)

    FactoryGirl.define do
      sequence(:email_address) {|n| "person-#{n}@example.com" }

      factory :user do
        email { generate(:email_address) }
      end

      factory :post do
        title { generate }
        user { build(:user) }
      end
    end
  end

  it "can access syntax methods from dynamic attributes" do
    FactoryGirl.build(:user).email.should == "person-1@example.com"
    FactoryGirl.attributes_for(:user)[:email].should == "person-2@example.com"
  end

  it "can access syntax methods from dynamic attributes" do
    FactoryGirl.build(:post).user.should be_instance_of(User)
  end

  it "can access methods already existing on the class" do
    FactoryGirl.build(:post).title.should == "generate result"
    FactoryGirl.attributes_for(:post)[:title].should be_nil
  end
end

Version data entries

142 entries across 82 versions & 6 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/factory_girl-3.2.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
classiccms-0.7.5 vendor/bundle/gems/factory_girl-3.3.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
classiccms-0.7.4 vendor/bundle/gems/factory_girl-3.2.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
classiccms-0.7.4 vendor/bundle/gems/factory_girl-3.3.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
classiccms-0.7.3 vendor/bundle/gems/factory_girl-3.2.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
classiccms-0.7.3 vendor/bundle/gems/factory_girl-3.3.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
classiccms-0.7.2 vendor/bundle/gems/factory_girl-3.3.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
classiccms-0.7.2 vendor/bundle/gems/factory_girl-3.2.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
classiccms-0.7.1 vendor/bundle/gems/factory_girl-3.3.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
classiccms-0.7.1 vendor/bundle/gems/factory_girl-3.2.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
classiccms-0.7.0 vendor/bundle/gems/factory_girl-3.3.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
classiccms-0.7.0 vendor/bundle/gems/factory_girl-3.2.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
challah-1.0.0.beta vendor/bundle/gems/factory_girl-4.1.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
challah-0.9.1.beta.3 vendor/bundle/gems/factory_girl-4.1.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
challah-0.9.1.beta vendor/bundle/gems/factory_girl-4.1.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/factory_girl-4.1.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
challah-0.9.0 vendor/bundle/gems/factory_girl-4.1.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
classiccms-0.6.9 vendor/bundle/gems/factory_girl-3.2.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
classiccms-0.6.9 vendor/bundle/gems/factory_girl-3.3.0/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/factory_girl-3.6.1/spec/acceptance/syntax_methods_within_dynamic_attributes_spec.rb