<commit_before>require File.dirname(__FILE__) + '/spec_helper'
require 'machinist/object'

module MachinistSpecs
  
  class Person
    attr_accessor :name, :admin
  end

  class Post
    attr_accessor :title, :body, :published
  end

  describe Machinist do
    before(:each) do
      Person.clear_blueprints!
      Post.clear_blueprints!
    end
  
    it "should set an attribute on the constructed object from a constant in the blueprint" do
      Person.blueprint do
        name "Fred"
      end
      Person.make.name.should == "Fred"
    end
  
    it "should set an attribute on the constructed object from a block in the blueprint" do
      Person.blueprint do
        name { "Fred" }
      end
      Person.make.name.should == "Fred"
    end
  
    it "should default to calling Sham for an attribute in the blueprint" do
      Sham.clear
      Sham.name { "Fred" }
      Person.blueprint { name }
      Person.make.name.should == "Fred"
    end
  
    it "should let the blueprint override an attribute with a default value" do
      Post.blueprint do
        published { false }
      end
      Post.make.published.should be_false
    end
  
    it "should override an attribute from the blueprint with a passed-in attribute" do<commit_msg>Test for calling make on a class with no blueprint<commit_after>require File.dirname(__FILE__) + '/spec_helper'
require 'machinist/object'

module MachinistSpecs
  
  class Person
    attr_accessor :name, :admin
  end

  class Post
    attr_accessor :title, :body, :published
  end

  describe Machinist do
    before(:each) do
      Person.clear_blueprints!
      Post.clear_blueprints!
    end

    it "should raise for make on a class with no blueprint" do
      lambda { Person.make }.should raise_error(RuntimeError)
    end
  
    it "should set an attribute on the constructed object from a constant in the blueprint" do
      Person.blueprint do
        name "Fred"
      end
      Person.make.name.should == "Fred"
    end
  
    it "should set an attribute on the constructed object from a block in the blueprint" do
      Person.blueprint do
        name { "Fred" }
      end
      Person.make.name.should == "Fred"
    end
  
    it "should default to calling Sham for an attribute in the blueprint" do
      Sham.clear
      Sham.name { "Fred" }
      Person.blueprint { name }
      Person.make.name.should == "Fred"
    end
  
    it "should let the blueprint override an attribute with a default value" do
      Post.blueprint do
        published { false }
      end
      Post.make.published.should be_false
    end
  
    it "should override an attribute from the blueprint with a passed-in attribute" do
{'fraction_non_alphanumeric': 0.06504672897196262, 'fraction_numerical': 0.0, 'mean_word_length': 2.470817120622568, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '79842', 'n_tokens_mistral': 791, 'n_tokens_neox': 771, 'n_words': 287}