require 'active_support' require 'fileutils' Given /^our impartials are stored in "([^"]*)"$/ do |location| @location = location Impartial.configure do |config| config.paths = [location] end end Given /^our impartials are stored in "([^"]*)" or "([^"]*)"$/ do |location1, location2| @location = location2 Impartial.configure do |config| config.paths = [location1, location2] end end Given /^an impartial named "([^"]*)"$/ do |name| @name = name.underscore @shortname = name.demodulize.underscore FileUtils.mkdir_p File.join(@location || 'impartials', @name) path = File.join(@location || 'impartials', @name, "#{@name}.rb") File.open path, "w" do |f| f.puts <<-FILE require 'impartial' class #{@name.camelize} < Impartial::Base end FILE end end Given /^it has a handlebars template$/ do path = File.join(@location || 'impartials', @name, "#{@name}.html.hbs") File.open path, "w" do |f| f.puts <<-FILE
Hello World!
FILE end end Given /^it has a LESS stylesheet$/ do path = File.join(@location || 'impartials', @name, "#{@name}.css.less") File.open path, "w" do |f| f.puts <<-FILE .#{@name.camelize.gsub('::', '-')} { text-shadow: 0px -2px 0px #333, 0px 2px 3px #666; } FILE end end Then /^I can render the impartial to a string$/ do path = File.join('.', @location || 'impartials', @name, @shortname) require path Impartial.render(@shortname).to_s.should eql <<-STRING
Hello World!
STRING end