Sha256: 6a6cbb792a06efb68a28ae480fce0345157fc1e89eed43dc0ec420dd769be12b

Contents?: true

Size: 859 Bytes

Versions: 2

Compression:

Stored size: 859 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

require 'factory_girl/syntax/sham'

describe "a factory using sham syntax" do
  before do
    Factory.clear_caches
    Sham.name  { "Name" }
    Sham.email { "somebody#{rand(5)}@example.com" }

    Factory.define :user do |factory|
      factory.first_name { Sham.name }
      factory.last_name  { Sham.name }
      factory.email      { Sham.email }
    end
  end

  after do
    Factory.factories.clear
    Factory.sequences.clear
  end

  describe "after making an instance" do
    before do
      @instance = Factory.create(:user, :last_name => 'Rye')
    end

    it "should support a sham called 'name'" do
      @instance.first_name.should == 'Name'
    end

    it "should use the sham for the email" do
      @instance.email.should =~ /somebody\d@example.com/
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
masa-iwasaki-factory_girl-1.2.3.2 spec/factory_girl/syntax/sham_spec.rb
masa-iwasaki-factory_girl-1.2.3.1 spec/factory_girl/syntax/sham_spec.rb