|
|
scenario :valid_users do
password = 'password'
User.create! \
:name => 'Chris Wanstrath',
:password => password,
:email => 'chris@ozmm.org',
:admin => true,
:password_confirmation => password
User.create! \
:name => 'PJ Hyett',
:password => password,
:email => 'pjhyett@gmail.com',
:password_confirmation => password
User.create! \
:name => 'Tom Preston-Werner',
:password => password,
:email => 'tompw@powerset.com',
:password_confirmation => password
end
defunkt, pjhyett, mojombo = User.find(:all)
scenario :scenarios_rb => :valid_users do
# How meta.
Snippet.create! \
:user => defunkt,
:name => 'scenarios.rb',
:language => 'Ruby',
:body => %q(
class Array
def descending?
self == sort.reverse
end
def ascending?
self == sort
end
end
).strip
Snippet.create! \
:user => pjhyett,
:name => 'patch test/spec/rails with pastie',
:language => 'Ruby',
:body => %q(
require 'open-uri'
pastie_url = "http://pastie.caboo.se/%s.txt"
%w( 50718 48373 67389 67379 67999 ).each do |pastie|
patch = open(pastie_url % pastie).read
File.open('patch.diff', 'w+') do |f|
f.puts patch
end
`patch -p0 < patch.diff && rm patch.diff`
puts "Patched with pastie ##{pastie}."
end
).strip
snippet = Snippet.find(:first)
Rewrite.create! \
:user => pjhyett,
:name => 'Re: scenarios.rb',
:language => 'Ruby',
:body => File.read(__FILE__),
:snippet => snippet,
:votes_count => 0
Rewrite.create! \
:user => mojombo,
:name => 'You guys both suck',
:language => 'Ruby',
:body => "class Suck\n def initialize(sucker)\n @sucker = sucker\n end\nend",
:snippet => snippet,
:votes_count => 2
end
scenario :lots_of_snippets => :valid_users do
ActiveRecord::Base.record_timestamps = false
time = Time.now - 1.week
100.times do |i|
Snippet.create! \
:user => defunkt,
:name => "cool snippet ##{i}",
:language => i.even? ? 'Ruby' : 'Javascript',
:body => "#{File.read(__FILE__).first(200)}",
:created_at => (time += 1.hour)
end
ActiveRecord::Base.record_timestamps = true
end
|