RubyOnRails
14 一月 2012 | View Comments
Rcov doesn’t work after I upgrade rspec to 2.8,
here is a quick fix
add following code into your spec_helper
<div id="_mcePaste">require 'rspec/autorun'</div>
Tagged in rcov, rspec
ruby
7 四月 2011 | View Comments
Rspec has a convenient way to write simple test
describe [1, 2, 3, 3] do
its(:size) { should == 4 }
its("uniq.size") { should == 3 }
end
Tagged in rspec, testing, Tips
RubyOnRails,Tips
21 七月 2010 | View Comments
Rails UnitTest
in file
test/test_helper.rb in
class ActiveSupport::TestCase add
teardown :clean_mongodb
def clean_mongodb
puts "cleaning mongodb...."
Mongoid.database.collections.each do |collection|
unless collection.name =~ /^system\./
collection.remove
end
end
puts "finished cleaning mongodb."
end
Rspec
in file
spec/spec_helper.rb, in
Spec::Runner.configure add
config.after(:each) do
puts "cleaning mongodb...."
Mongoid.database.collections.each do |collection|
unless collection.name =~ /^system\./
collection.remove
end
end
puts "finished cleaning mongodb."
end
Cucumber
add new file
features/support/mongodb_clean.rb
After do |scenario|
puts "cleaning mongodb...."
Mongoid.database.collections.each do |collection|
unless collection.name =~ /^system\./
collection.remove
end
end
puts "finished cleaning mongodb."
end
Tagged in cucumber, mongoid, rspec, RubyOnRails, test