Sha256: ced99ed0979b529a790d7bd437786e87e12cb1c852afa3f1359d3270566f9451

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

require File.dirname(__FILE__) + "/../../spec_helper"

module FixtureReplacement
  describe AttributeBuilder do
    include FixtureReplacementControllerHelper

    before :each do
      @obj = use_module do
        attributes_for :user do |u|
          u.username = random_string
          u.key = random_string
        end

        attributes_for :scott, :from => :user

        attributes_for :foo, :class => User

        attributes_for :admin do |a|
          a.admin_status = true
        end
      end
    end

    models = "user", "foo", "scott"

    models.each do |model|
      it "should have the new_#{model} method as a (module) method on the module" do
        @obj.should respond_to("new_#{model}")
      end

      it "should have the new_#{model} method as a private method in the test case" do
        @obj.private_methods.should include("new_#{model}")
      end

      it "should have the create_#{model} method as a private method in the test case" do
        @obj.private_methods.should include("create_#{model}")
      end

      it "should have the create_#{model} method as a (module) method on the module" do
        @obj.should respond_to("create_#{model}")
      end
    end

    it "should have the username as a string (for User) for new_user" do
      @obj.new_user.username.class.should == String
    end

    it "should have the username as a string (for User) for create_user" do
      @obj.create_user.username.class.should == String
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fixture_replacement-3.0.1 spec/fixture_replacement/integration/attributes_from_spec_without_block.rb