From 5246fdad261146bb8fa613ce021c12867be58968 Mon Sep 17 00:00:00 2001 From: Dmytrii Nagirniak Date: Fri, 16 Dec 2011 11:07:49 +1100 Subject: [PATCH] added spec to support ORMs with 'simple columns' (Neo4j) --- features/factory_girl_steps.feature | 4 ++++ features/support/factories.rb | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/features/factory_girl_steps.feature b/features/factory_girl_steps.feature index b5bb9c748..27ed54f8c 100644 --- a/features/factory_girl_steps.feature +++ b/features/factory_girl_steps.feature @@ -215,3 +215,7 @@ Feature: Use step definitions generated by factories And the post "Tagged post" should not have the following tags: | name | | funky | + + Scenario: step definitions work correctly with ORMs that have simple `columns` + Given a simple column exists + Then there should be 1 SimpleColumn diff --git a/features/support/factories.rb b/features/support/factories.rb index bc91a4d6f..dbe1757ad 100644 --- a/features/support/factories.rb +++ b/features/support/factories.rb @@ -58,6 +58,21 @@ class Tag < ActiveRecord::Base class NonActiveRecord end +class SimpleColumn + def self.columns + [:name] + end + + def save! + @@count ||= 0 + @@count += 1 + end + + def self.count + @@count + end +end + FactoryGirl.define do # To make sure the step defs work with an email sequence :email do |n| @@ -90,6 +105,10 @@ class NonActiveRecord # This is here to ensure that factory step definitions don't raise for a non-AR factory factory :non_active_record do end + + # This is here to make FG work with ORMs that have `columns => [:name, :admin, :etc]` on the class (Neo4j) + factory :simple_column do + end end require 'factory_girl/step_definitions'