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
class PublishesPosts < Struct.new(:post_id, :ui) | |
def run | |
Blog.lookup_post(post_id, | |
:success => lambda {|post| post.publish; ui.post_published(post) }, | |
:failure => lambda {|post_id| ui.no_such_post(post_id) }) | |
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
class PublishesPosts < Struct.new(:post_id, :ui) | |
def run | |
Blog.lookup_post(post_id) do |result| | |
result.success => lambda {|post| post.publish; ui.post_published(post) }, | |
result.failure => lambda {|post_id| ui.no_such_post(post_id) }) | |
end | |
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
class PublishesPosts < Struct.new(:post_id, :ui) | |
def run | |
Blog.lookup_post(post_id, PublishesAPost.new(ui)) | |
end | |
end | |
class PublishesAPost < Struct.new(:ui) | |
def post_found(post) | |
post.publish | |
ui.post_published(post) |
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
class PublishesPosts < Struct.new(:post_id, :ui) | |
def run | |
Blog.lookup_post(post_id, self) | |
end | |
def post_found(post) | |
post.publish | |
ui.post_published(post) | |
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
namespace :cron | |
task :validate_models => [:environment] do | |
[Post, Comment].each do |klass| | |
klass.all.each do |obj| | |
ErrorMailer.report_errors('me@example.com', obj) unless obj.valid? | |
end | |
end | |
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
namespace :cron | |
task :validate_models => [:environment] do | |
UseCases::ValidatesPostsAndComments.new.run | |
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
class ApplicationController < ActionController | |
def wiki | |
@wiki ||= if (current_user.admin?) | |
AdminWiki.new | |
else | |
ReadonlyWiki.new | |
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
context 'EventBus methods cascade' do | |
context 'clear' do | |
When(:result) { EventBus.clear } | |
Then { result.should == EventBus } | |
end | |
context 'publish' do | |
When(:result) { EventBus.publish('aa123bb', {}) } | |
Then { result.should == EventBus } |
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
import static org.junit.Assert.*; | |
import org.junit.Test; | |
public class PotterTester { | |
private double price(int... books) { | |
return 0.0; | |
} | |
@Test |
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
import static org.junit.Assert.*; | |
import org.junit.Test; | |
public class OcpPotterTester { | |
private double price(int... books) { | |
Basket basket = new BasketFactory().create(); | |
return basket.bestPrice(books); | |
} |