Steps should try passing unknown methods to config context before failing. Fixes #1879
This commit is contained in:
parent
f2535f4fda
commit
a01656df39
|
@ -1,6 +1,10 @@
|
||||||
master
|
master
|
||||||
===
|
===
|
||||||
|
|
||||||
|
# 4.1.8
|
||||||
|
|
||||||
|
* Let collection loops access ConfigContext for helpers. #1879
|
||||||
|
|
||||||
# 4.1.7
|
# 4.1.7
|
||||||
|
|
||||||
* Upgrade fastimage to 2.0
|
* Upgrade fastimage to 2.0
|
||||||
|
|
|
@ -144,6 +144,33 @@ Feature: Collections
|
||||||
And I should see 'Article: Blog3 Another Article'
|
And I should see 'Article: Blog3 Another Article'
|
||||||
And I should see 'Article: Blog2 Yet Another Article'
|
And I should see 'Article: Blog2 Yet Another Article'
|
||||||
|
|
||||||
|
Scenario: Work with local helpers
|
||||||
|
Given a fixture app "collections-app"
|
||||||
|
And a file named "config.rb" with:
|
||||||
|
"""
|
||||||
|
module TestHelper
|
||||||
|
def help_me
|
||||||
|
"ok"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
include TestHelper
|
||||||
|
|
||||||
|
data.articles.each_with_index do |a, i|
|
||||||
|
proxy "/#{i}-#{help_me}.html", a
|
||||||
|
end
|
||||||
|
"""
|
||||||
|
And a file named "data/articles.yaml" with:
|
||||||
|
"""
|
||||||
|
---
|
||||||
|
- "/blog1/2011-01-01-new-article.html"
|
||||||
|
- "/blog2/2011-01-02-another-article.html"
|
||||||
|
"""
|
||||||
|
Given the Server is running at "collections-app"
|
||||||
|
When I go to "0-ok.html"
|
||||||
|
Then I should see 'Newer Article Content'
|
||||||
|
When I go to "1-ok.html"
|
||||||
|
Then I should see 'Another Article Content'
|
||||||
|
|
||||||
Scenario: Collected data update with file changes
|
Scenario: Collected data update with file changes
|
||||||
Given a fixture app "collections-app"
|
Given a fixture app "collections-app"
|
||||||
|
|
|
@ -90,7 +90,7 @@ module Middleman
|
||||||
pair[:root].realize!(dataset)
|
pair[:root].realize!(dataset)
|
||||||
end
|
end
|
||||||
|
|
||||||
ctx = StepContext.new
|
ctx = StepContext.new(app)
|
||||||
StepContext.current = ctx
|
StepContext.current = ctx
|
||||||
|
|
||||||
leaves = @leaves.dup
|
leaves = @leaves.dup
|
||||||
|
|
|
@ -12,18 +12,21 @@ module Middleman
|
||||||
|
|
||||||
attr_reader :descriptors
|
attr_reader :descriptors
|
||||||
|
|
||||||
def initialize
|
def initialize(app)
|
||||||
|
@app = app
|
||||||
@descriptors = []
|
@descriptors = []
|
||||||
end
|
end
|
||||||
|
|
||||||
def method_missing(name, *args, &block)
|
def method_missing(name, *args, &block)
|
||||||
internal = :"_internal_#{name}"
|
internal = :"_internal_#{name}"
|
||||||
|
|
||||||
return super unless respond_to?(internal)
|
if respond_to?(internal)
|
||||||
|
|
||||||
send(internal, *args, &block).tap do |r|
|
send(internal, *args, &block).tap do |r|
|
||||||
@descriptors << r if r.respond_to?(:execute_descriptor)
|
@descriptors << r if r.respond_to?(:execute_descriptor)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
@app.config_context.send(name, *args, &block)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue