Skip to content

Commit

Permalink
Removed useless fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
sr committed Feb 25, 2009
1 parent 085b501 commit c6a2d32
Showing 1 changed file with 40 additions and 107 deletions.
147 changes: 40 additions & 107 deletions test/fixtures.rb
@@ -1,113 +1,46 @@
require "integrity"
DataMapper.setup(:default, "sqlite3::memory:")
DataMapper.auto_migrate!

require "dm-sweatshop"
require "integrity"

include DataMapper::Sweatshop::Unique

class Array
def pick
self[rand(self.length)]
end
end

def create_notifier!(name)
klass = Class.new(Integrity::Notifier::Base) do
def self.to_haml; ""; end
def deliver!; nil; end
end

unless Integrity::Notifier.const_defined?(name)
Integrity::Notifier.const_set(name, klass)
module Integrity
module Fixtures

DataMapper.setup(:default, "sqlite3::memory:")
DataMapper.auto_migrate!

Integrity::Project.fixture do
{ :name => (name = unique { /\w+/.gen }),
:uri => "git://github.com/#{/\w+/.gen}/#{name}.git",
:branch => ["master", "test-refactoring", "lh-34"].pick,
:command => ["rake", "make", "ant -buildfile test.xml"].pick,
:public => [true, false].pick,
:building => [true, false].pick }
end

Integrity::Commit.fixture do
project = Integrity::Project.first || Integrity::Project.gen

{ :identifier => Digest::SHA1.hexdigest(/[:paragraph:]/.gen),
:message => /[:sentence:]/.gen,
:author => /\w+ \w+ <\w+@example.org>/.gen,
:committed_at => unique {|i| Time.mktime(2008, 12, 15, 18, (59 - i) % 60) },
:project_id => project.id }
end

Integrity::Build.fixture do
commit = Integrity::Commit.first || Integrity::Commit.gen

{ :output => /[:paragraph:]/.gen,
:successful => true,
:started_at => unique {|i| Time.mktime(2008, 12, 15, 18, i % 60) },
:created_at => unique {|i| Time.mktime(2008, 12, 15, 18, i % 60) },
:completed_at => unique {|i| Time.mktime(2008, 12, 15, 18, i % 60) },
:commit_id => commit.id }
end

Integrity::Build.fixture(:successful) do
Integrity::Build.generate_attributes.update(:successful => true)
end
end
end


Integrity::Project.fixture do
{ :name => (name = unique { /\w+/.gen }),
:uri => "git://github.com/#{/\w+/.gen}/#{name}.git",
:branch => ["master", "test-refactoring", "lh-34"].pick,
:command => ["rake", "make", "ant -buildfile test.xml"].pick,
:public => [true, false].pick,
:building => [true, false].pick }
end

Integrity::Project.fixture(:integrity) do
{ :name => "Integrity",
:uri => "git://github.com/foca/integrity.git",
:branch => "master",
:command => "rake",
:public => true,
:building => false }
end

Integrity::Project.fixture(:my_test_project) do
{ :name => "My Test Project",
:uri => File.dirname(__FILE__) + "/../../",
:branch => "master",
:command => "./test",
:public => true,
:building => false }
end

Integrity::Commit.fixture do
project = Integrity::Project.first || Integrity::Project.gen

{ :identifier => Digest::SHA1.hexdigest(/[:paragraph:]/.gen),
:message => /[:sentence:]/.gen,
:author => /\w+ \w+ <\w+@example.org>/.gen,
:committed_at => unique {|i| Time.mktime(2008, 12, 15, 18, (59 - i) % 60) },
:project_id => project.id }
end

Integrity::Commit.fixture(:successful) do
Integrity::Commit.generate_attributes.update(:build => Integrity::Build.gen(:successful))
end

Integrity::Commit.fixture(:failed) do
Integrity::Commit.generate_attributes.update(:build => Integrity::Build.gen(:failed))
end

Integrity::Commit.fixture(:pending) do
Integrity::Commit.generate_attributes.update(:build => Integrity::Build.gen(:pending))
end

Integrity::Build.fixture do
commit = Integrity::Commit.first || Integrity::Commit.gen

{ :output => /[:paragraph:]/.gen,
:successful => true,
:started_at => unique {|i| Time.mktime(2008, 12, 15, 18, i % 60) },
:created_at => unique {|i| Time.mktime(2008, 12, 15, 18, i % 60) },
:completed_at => unique {|i| Time.mktime(2008, 12, 15, 18, i % 60) },
:commit_id => commit.id }
end

Integrity::Build.fixture(:successful) do
Integrity::Build.generate_attributes.update(:successful => true)
end

Integrity::Build.fixture(:failed) do
Integrity::Build.generate_attributes.update(:successful => false)
end

Integrity::Build.fixture(:pending) do
Integrity::Build.generate_attributes.update(:successful => nil, :started_at => nil, :completed_at => nil)
end

Integrity::Notifier.fixture(:irc) do
create_notifier! "IRC"

{ :project => Integrity::Project.generate,
:name => "IRC",
:config => { :uri => "irc://irc.freenode.net/integrity" }}
end

Integrity::Notifier.fixture(:twitter) do
create_notifier! "Twitter"

{ :project => Integrity::Project.generate,
:name => "Twitter",
:config => { :email => "foo@example.org", :pass => "secret" }}
end

0 comments on commit c6a2d32

Please sign in to comment.