-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require File.expand_path('../config/boot.rb', __FILE__) | ||
require 'padrino-core/cli/rake' | ||
PadrinoTasks.init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# install watchr | ||
# $ gem install watchr | ||
# | ||
# Run With: | ||
# $ watchr test.watchr | ||
# | ||
|
||
# -------------------------------------------------- | ||
# Helpers | ||
# -------------------------------------------------- | ||
|
||
def run(cmd) | ||
puts(cmd) | ||
system("clear") | ||
system("ruby #{cmd}") | ||
end | ||
|
||
# -------------------------------------------------- | ||
# Watchr Rules | ||
# -------------------------------------------------- | ||
watch("^lib/(.*)\.rb") { |m| run("test/#{m[1]}_test.rb") } | ||
|
||
watch("^(.*)/controllers/(.*).rb") { |m| run("test/#{m[1]}/controllers/#{m[2]}_controller_test.rb") } | ||
watch("^test/(.*)/controllers/(.*)_test.rb") { |m| run("test/#{m[1]}/controllers/#{m[2]}_test.rb") } | ||
|
||
watch("^(.*)/models/(.*).rb") { |m| run("test/#{m[1]}/models/#{m[2]}_test.rb") } | ||
watch("^test/(.*)/(.*)_test.rb") { |m| run("test/#{m[1]}/models/#{m[2]}_test.rb") } | ||
|
||
watch("test.*/test_config\.rb") { system( "padrino rake test" ) } | ||
watch("^test/(.*)_test\.rb") { |m| run("test/#{m[1]}_test.rb") } | ||
|
||
# -------------------------------------------------- | ||
# Signal Handling | ||
# -------------------------------------------------- | ||
# Ctrl-\ | ||
Signal.trap('QUIT') do | ||
system 'clear' | ||
puts " --- Running all tests ---\n\n" | ||
system "padrino rake test" | ||
end | ||
|
||
# Ctrl-C | ||
Signal.trap('INT') { abort("\n") } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
Sham.define do | ||
username { Faker::Internet.user_name } | ||
first_name { Faker::Name.first_name } | ||
last_name { Faker::Name.last_name } | ||
password { (1..10).map { ('a'..'z').to_a.rand }.join } | ||
email { Faker::Internet.email } | ||
title { Faker::Lorem.words(3).join(' ') } | ||
body { Faker::Lorem.words(8).join(' ') } | ||
tag_name { Faker::Lorem.words(1).join } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class DatabaseCleanerMiddleware < Riot::ContextMiddleware | ||
register | ||
|
||
def call(context) | ||
setup_database_cleaner(context) if clean_database?(context) | ||
middleware.call(context) | ||
end | ||
|
||
private | ||
|
||
def clean_database?(context) | ||
context.option(:clean_database) | ||
end | ||
|
||
def setup_database_cleaner(context) | ||
context.setup { DatabaseCleaner.clean } | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters