Created
June 9, 2010 04:42
-
-
Save hotgazpacho/431058 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Microsoft.Scripting.Hosting; | |
namespace InteropConsole | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
ScriptEngine engine = IronRuby.Ruby.CreateEngine(); | |
ScriptScope scope = engine.CreateScope(); | |
engine.Execute("require 'factories.rb'", scope); | |
dynamic user = engine.Execute<FactoryGirlSpike.Poco.User>("u = Factory.build(:user)", scope); | |
Console.WriteLine(user); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'factory_girl' | |
require 'FactoryGirlSpike.dll' | |
include FactoryGirlSpike::Poco | |
# Let's define a sequence that factories can use. This sequence defines a | |
# unique e-mail address. The first address will be "[email protected]", | |
# and the second will be "[email protected]." | |
Factory.sequence :email do |n| | |
"somebody#{n}@example.com" | |
end | |
# Let's define a factory for the User model. The class name is guessed from the | |
# factory name. | |
Factory.define :user do |f| | |
# These properties are set statically, and are evaluated when the factory is | |
# defined. | |
f.first_name 'John' | |
f.last_name 'Doe' | |
f.admin false | |
# This property is set "lazily." The block will be called whenever an | |
# instance is generated, and the return value of the block is used as the | |
# value for the attribute. | |
f.email { Factory.next(:email) } | |
end |
Author
hotgazpacho
commented
Jun 9, 2010
Change bee0db has this working now :-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment