Permalink
Browse files

Added partial rendering html format fallback

  • Loading branch information...
1 parent 01135c9 commit 04bc2e5a496bc9646d9fa1ce410e777dedb2a8db @pyromaniac pyromaniac committed Jul 15, 2013
View
@@ -1,20 +1,24 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
-guard 'rspec', :version => 2 do
+guard :rspec do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
- watch(%r{^spec/.+_spec\.rb$})
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
- watch('spec/spec_helper.rb') { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
- # Capybara request specs
- watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
+
+ # Capybara features specs
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
+
+ # Turnip features and steps
+ watch(%r{^spec/acceptance/(.+)\.feature$})
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
+
@@ -32,15 +32,14 @@ def error
rescue ::SyntaxError => e
e.message
else
- false
+ nil
end
def translations
@translations ||= Hash[map do |(locale, yaml)|
load_arguments = [yaml]
load_arguments.push "<#{locale}>" if YAML.method(:load).arity == -2
- result = YAML.load yaml
- result = result.presence || {}
+ result = YAML.load(*load_arguments).presence || {}
raise ::SyntaxError.new("(<#{locale}>): Locale should be a hash") unless result.is_a?(Hash)
[locale.to_sym, result.deep_symbolize_keys]
end]
@@ -17,7 +17,15 @@ def initialize(tag_name, markup, tokens)
def render(context)
path = context[@path]
- context.registers[:tracker].register("<%= render '#{path}' %>")
+ context.registers[:tracker].register("<%=
+ old_formats = formats
+ begin
+ self.formats = old_formats | [:html]
+ render '#{path}'
+ ensure
+ self.formats = old_formats
+ end
+ %>")
end
end
View
@@ -12,6 +12,7 @@ def render_layout layout, current_page, page = nil
let!(:root) { Fabricate :root, name: 'root' }
let!(:first) { Fabricate :page, slug: 'first', parent: root }
let!(:second) { Fabricate :page, slug: 'second', parent: first, page_parts: [main, sidebar] }
+ let!(:css) { Fabricate :page, slug: 'page.css', parent: first }
let!(:main) { Fabricate(:main) }
let!(:sidebar) { Fabricate(:sidebar, handler: 'yaml', body: YAML.dump(hash)) }
@@ -59,6 +60,15 @@ def render_layout layout, current_page, page = nil
response.body.should == 'shared/first content'
end
end
+
+ context 'render tag with other format' do
+ let!(:application) { Fabricate :application, :body => "{% render 'shared/first' %}" }
+
+ specify do
+ get "/#{css.location}"
+ response.body.should == 'shared/first content'
+ end
+ end
end
end

0 comments on commit 04bc2e5

Please sign in to comment.