Permalink
Browse files

Updated to new FactoryGirl namespace and moved sqlite3 jruby code to …

…Gemfile.
  • Loading branch information...
1 parent 0fa470e commit efe2dcc5f69927f40276bf4a5c114db31a9a244e @parndt parndt committed Sep 10, 2011
View
@@ -3,3 +3,6 @@ source "http://rubygems.org"
gem 'forem-theme-base', :git => "git://github.com/radar/forem-theme-base"
gemspec
+
+gem 'sqlite3', :platform => :ruby
+gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
View
@@ -61,9 +61,9 @@ GEM
database_cleaner (0.6.7)
diff-lcs (1.1.3)
erubis (2.7.0)
- factory_girl (2.0.5)
- factory_girl_rails (1.1.0)
- factory_girl (~> 2.0.0)
+ factory_girl (2.1.0)
+ factory_girl_rails (1.2.0)
+ factory_girl (~> 2.1.0)
railties (>= 3.0.0)
ffi (1.0.9)
hike (1.2.1)
@@ -150,9 +150,10 @@ PLATFORMS
ruby
DEPENDENCIES
+ activerecord-jdbcsqlite3-adapter
capybara
database_cleaner
- factory_girl_rails
+ factory_girl_rails (>= 1.2.0)
forem!
forem-theme-base!
launchy
View
@@ -13,12 +13,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "rspec-rails", "~> 2.6"
s.add_development_dependency "capybara"
s.add_development_dependency 'rails', '~> 3.1.0'
- unless defined?(JRUBY_VERSION)
- s.add_development_dependency "sqlite3"
- else
- s.add_development_dependency "activerecord-jdbcsqlite3-adapter"
- end
- s.add_development_dependency "factory_girl_rails"
+ s.add_development_dependency "factory_girl_rails", '>= 1.2.0'
s.add_development_dependency "database_cleaner"
s.add_dependency "rails", '3.1.0'
s.add_dependency "simple_form"
@@ -13,8 +13,8 @@
end
context "users signed in as admins" do
+ let!(:forum) { FactoryGirl.create(:forum, :title => "Original Name") }
before do
- @forum = Factory(:forum, :title => "Original Name")
sign_in! :admin => true
visit root_path
# Ensure that people can navigate to this area.
@@ -1,9 +1,9 @@
require 'spec_helper'
describe "topics" do
- let(:forum) { Factory(:forum) }
- let(:topic) { Factory(:topic, :forum => forum) }
- let(:other_topic) { Factory(:topic, :forum => forum, :subject => "SECOND TOPIC") }
+ let(:forum) { FactoryGirl.create(:forum) }
+ let(:topic) { FactoryGirl.create(:topic, :forum => forum) }
+ let(:other_topic) { FactoryGirl.create(:topic, :forum => forum, :subject => "SECOND TOPIC") }
before do
sign_in! :admin => true
@@ -1,7 +1,7 @@
require 'spec_helper'
describe "forums" do
- let!(:forum) { Factory(:forum) }
+ let!(:forum) { FactoryGirl.create(:forum) }
it "listing all" do
visit forums_path
@@ -12,11 +12,11 @@
context "visiting a forum" do
before do
- @topic_1 = Factory(:topic, :subject => "Unpinned", :forum => forum)
- @topic_2 = Factory(:topic, :subject => "Most Recent", :forum => forum)
- Factory(:post, :topic => @topic_2, :created_at => Time.now + 30.seconds)
- @topic_3 = Factory(:topic, :subject => "PINNED!", :forum => forum, :pinned => true)
- @topic_4 = Factory(:topic, :subject => "HIDDEN!", :forum => forum, :hidden => true)
+ @topic_1 = FactoryGirl.create(:topic, :subject => "Unpinned", :forum => forum)
+ @topic_2 = FactoryGirl.create(:topic, :subject => "Most Recent", :forum => forum)
+ FactoryGirl.create(:post, :topic => @topic_2, :created_at => Time.now + 30.seconds)
+ @topic_3 = FactoryGirl.create(:topic, :subject => "PINNED!", :forum => forum, :pinned => true)
+ @topic_4 = FactoryGirl.create(:topic, :subject => "HIDDEN!", :forum => forum, :hidden => true)
visit forum_path(forum.id)
end
@@ -9,8 +9,8 @@
end
# TODO: FG'ize
- let(:forum) { Factory(:forum) }
- let(:topic) { Factory(:topic, :forum => forum) }
+ let(:forum) { FactoryGirl.create(:forum) }
+ let(:topic) { FactoryGirl.create(:topic, :forum => forum) }
context "not signed in users" do
it "cannot begin to post a reply" do
@@ -78,7 +78,7 @@
context "deleting" do
before do
- topic.posts << Factory(:post, :user => Factory(:user, :login => 'other_forem_user'))
+ topic.posts << FactoryGirl.create(:post, :user => FactoryGirl.create(:user, :login => 'other_forem_user'))
sign_in!
visit forum_topic_path(forum, topic)
@@ -2,11 +2,11 @@
describe "topics" do
- let(:forum) { Factory(:forum) }
- let(:topic) { Factory(:topic, :forum => forum) }
- let(:first_user) { Factory(:user, :login => 'first_forem_user') }
- let(:user) { Factory(:user, :login => 'other_forem_user', :email => "bob@boblaw.com") }
- let(:other_topic) { Factory(:topic, :subject => 'Another forem topic', :user => user, :forum => forum) }
+ let(:forum) { FactoryGirl.create(:forum) }
+ let(:topic) { FactoryGirl.create(:topic, :forum => forum) }
+ let(:first_user) { FactoryGirl.create(:user, :login => 'first_forem_user') }
+ let(:user) { FactoryGirl.create(:user, :login => 'other_forem_user', :email => "bob@boblaw.com") }
+ let(:other_topic) { FactoryGirl.create(:topic, :subject => 'Another forem topic', :user => user, :forum => forum) }
context "not signed in" do
before do
@@ -115,7 +115,7 @@
context "viewing a topic" do
let(:topic) do
- Factory(:topic, :forum => forum, :user => user)
+ FactoryGirl.create(:topic, :forum => forum, :user => user)
end
it "is free for all" do
View
@@ -1,8 +1,8 @@
require 'spec_helper'
describe Forem::Post do
- let(:post) { Factory(:post) }
- let(:reply) { Factory(:post, :reply_to => post) }
+ let(:post) { FactoryGirl.create(:post) }
+ let(:reply) { FactoryGirl.create(:post, :reply_to => post) }
context "upon deletion" do
View
@@ -35,8 +35,8 @@
describe "pinning" do
before(:each) do
Forem::Topic.delete_all
- @topic1 = Factory(:topic)
- @topic2 = Factory(:topic)
+ @topic1 = FactoryGirl.create(:topic)
+ @topic2 = FactoryGirl.create(:topic)
end
it "should show pinned topics up top" do
@@ -50,11 +50,11 @@
before do
Forem::Topic.delete_all
@topic1 = Forem::Topic.create :subject => "POST"
- Factory(:post, :topic => @topic1, :created_at => 1.seconds.ago)
+ FactoryGirl.create(:post, :topic => @topic1, :created_at => 1.seconds.ago)
@topic2 = Forem::Topic.create :subject => "POST"
- Factory(:post, :topic => @topic2, :created_at => 5.seconds.ago)
+ FactoryGirl.create(:post, :topic => @topic2, :created_at => 5.seconds.ago)
@topic3 = Forem::Topic.create :subject => "POST"
- Factory(:post, :topic => @topic3, :created_at => 10.seconds.ago)
+ FactoryGirl.create(:post, :topic => @topic3, :created_at => 10.seconds.ago)
end
it "should show topics by most recent post" do
@@ -1,4 +1,6 @@
-Factory.define(:forum, :class => Forem::Forum) do |f|
- f.title "Welcome to Forem!"
- f.description "A placeholder forum."
+FactoryGirl.define do
+ factory :forum, :class => Forem::Forum do |f|
+ f.title "Welcome to Forem!"
+ f.description "A placeholder forum."
+ end
end
@@ -1,4 +1,6 @@
-Factory.define(:post, :class => Forem::Post) do |t|
- t.text "This is a brand new post!"
- t.user {|u| u.association(:user) }
+FactoryGirl.define do
+ factory :post, :class => Forem::Post do |t|
+ t.text "This is a brand new post!"
+ t.user {|u| u.association(:user) }
+ end
end
@@ -1,6 +1,8 @@
-Factory.define(:topic, :class => Forem::Topic) do |t|
- t.subject "FIRST TOPIC"
- t.forum {|f| f.association(:forum) }
- t.user {|u| u.association(:user) }
- t.posts { |p| [p.association(:post)]}
+FactoryGirl.define do
+ factory :topic, :class => Forem::Topic do |t|
+ t.subject "FIRST TOPIC"
+ t.forum {|f| f.association(:forum) }
+ t.user {|u| u.association(:user) }
+ t.posts { |p| [p.association(:post)]}
+ end
end
@@ -1,4 +1,6 @@
-Factory.define(:user) do |f|
- f.login "forem_user"
- f.email "bob@boblaw.com"
+FactoryGirl.define do
+ factory :user do |f|
+ f.login "forem_user"
+ f.email "bob@boblaw.com"
+ end
end

0 comments on commit efe2dcc

Please sign in to comment.