Skip to content

Commit

Permalink
Add contract to OutdatednessChecker#initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Dec 31, 2016
1 parent 6b9273e commit 5c9f263
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
8 changes: 2 additions & 6 deletions lib/nanoc/base/services/outdatedness_checker.rb
Expand Up @@ -82,12 +82,8 @@ def apply_rules_multi(rules, objs)

Reasons = Nanoc::Int::OutdatednessReasons

# @param [Nanoc::Int::Site] site
# @param [Nanoc::Int::ChecksumStore] checksum_store
# @param [Nanoc::Int::DependencyStore] dependency_store
# @param [Nanoc::Int::RuleMemoryStore] rule_memory_store
# @param [Nanoc::Int::ActionProvider] action_provider
# @param [Nanoc::Int::ItemRepRepo] reps
# FIXME: Replace C::Any with proper types
contract C::KeywordArgs[site: Nanoc::Int::Site, checksum_store: Nanoc::Int::ChecksumStore, dependency_store: Nanoc::Int::DependencyStore, rule_memory_store: Nanoc::Int::RuleMemoryStore, action_provider: C::Any, reps: Nanoc::Int::ItemRepRepo] => C::Any
def initialize(site:, checksum_store:, dependency_store:, rule_memory_store:, action_provider:, reps:)
@site = site
@checksum_store = checksum_store
Expand Down
21 changes: 15 additions & 6 deletions spec/nanoc/base/services/outdatedness_checker_spec.rb
Expand Up @@ -10,9 +10,22 @@
)
end

let(:site) { double(:site) }
let(:checksum_store) { double(:checksum_store) }
let(:dependency_store) { double(:dependency_store) }

let(:dependency_store) do
Nanoc::Int::DependencyStore.new(objects)
end

let(:objects) { [item] }

let(:site) do
Nanoc::Int::Site.new(
config: config,
items: [],
layouts: [],
code_snippets: [],
)
end

let(:rule_memory_store) do
Nanoc::Int::RuleMemoryStore.new
Expand Down Expand Up @@ -102,10 +115,6 @@
describe '#outdated_due_to_dependencies?' do
subject { outdatedness_checker.send(:outdated_due_to_dependencies?, item) }

let(:dependency_store) do
Nanoc::Int::DependencyStore.new(objects)
end

let(:checksum_store) { Nanoc::Int::ChecksumStore.new(objects: objects) }

let(:other_item) { Nanoc::Int::Item.new('other stuff', {}, '/other.md') }
Expand Down
10 changes: 9 additions & 1 deletion spec/nanoc/base/services/outdatedness_rules_spec.rb
Expand Up @@ -18,11 +18,19 @@
let(:item_rep) { Nanoc::Int::ItemRep.new(item, :default) }
let(:item) { Nanoc::Int::Item.new('stuff', {}, '/foo.md') }

let(:site) { double(:site) }
let(:config) { Nanoc::Int::Configuration.new }
let(:code_snippets) { [] }
let(:objects) { [config] + code_snippets + [item] }

let(:site) do
Nanoc::Int::Site.new(
config: config,
items: [],
layouts: [],
code_snippets: code_snippets,
)
end

let(:action_provider) { double(:action_provider) }
let(:reps) { Nanoc::Int::ItemRepRepo.new }
let(:dependency_store) { Nanoc::Int::DependencyStore.new(dependency_store_objects) }
Expand Down

0 comments on commit 5c9f263

Please sign in to comment.