Skip to content

Commit

Permalink
layed groundwork for :all, :except, :only parameters for update_stale…
Browse files Browse the repository at this point in the history
…/! functions
  • Loading branch information
jsmestad committed Feb 20, 2010
1 parent 6828a22 commit 16b9813
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/stale_fish.rb
Expand Up @@ -23,7 +23,7 @@ def configuration

def update_stale(options={})
# this is without force
fixtures.each do |fixture|
fixtures(options).each do |fixture|
if fixture.is_stale?
fixture.update!
end
Expand All @@ -32,13 +32,18 @@ def update_stale(options={})

def update_stale!(options={})
# forced update regardless
fixtures.each do |fixture|
fixtures(options).each do |fixture|
fixture.update!
end
end

def fixtures
@fixtures ||= []
def fixtures(params={})
if params[:only] || params[:except]
only = params[:only] || params[:except]
return @fixtures.select { |f| params[:only].includes?(f.name.to_sym) }
else
@fixtures ||= []
end
end

protected
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/stale_fish_spec.rb
Expand Up @@ -57,4 +57,10 @@
StaleFish.update_stale!
end
end

context ".fixtures" do
it "should accept the :all parameter"
it "should accept the :only parameter with an array of symbols"
it "should accept the :except parameter with an array of symbols"
end
end

0 comments on commit 16b9813

Please sign in to comment.