2010-08-21 22:48:24 +00:00
|
|
|
### Snippets
|
|
|
|
|
|
|
|
# helps create a simple snippet with a slug and template
|
2012-04-25 13:56:38 +00:00
|
|
|
def new_snippet(name, template = nil)
|
|
|
|
@site.snippets.new(:name => name, :template => template)
|
|
|
|
end
|
|
|
|
|
2010-08-21 22:48:24 +00:00
|
|
|
def create_snippet(name, template = nil)
|
2012-04-25 13:56:38 +00:00
|
|
|
snippet = new_snippet(name, template)
|
|
|
|
snippet.save!
|
2010-08-21 22:48:24 +00:00
|
|
|
snippet
|
|
|
|
end
|
|
|
|
|
|
|
|
# creates a snippet
|
|
|
|
|
|
|
|
Given /^a snippet named "([^"]*)" with the template:$/ do |name, template|
|
|
|
|
@snippet = create_snippet(name, template)
|
|
|
|
end
|
|
|
|
|
2012-04-25 13:56:38 +00:00
|
|
|
Given /^a snippet named "([^"]*)" with id "([^"]*)" and template:$/ do |name, id, template|
|
|
|
|
@snippet = new_snippet(name, template)
|
|
|
|
@snippet.id = BSON::ObjectId(id)
|
|
|
|
@snippet.save!
|
|
|
|
end
|
|
|
|
|
2012-02-29 01:11:56 +00:00
|
|
|
When /^I change the snippet template to "([^"]*)"$/ do |code|
|
|
|
|
page.evaluate_script "window.application_view.view.editor.setValue('#{code}')"
|
|
|
|
end
|
|
|
|
|
2011-06-02 13:15:11 +00:00
|
|
|
# checks to see if a string is in the slug
|
|
|
|
Then /^I should have "(.*)" in the (.*) snippet/ do |content, snippet_slug|
|
|
|
|
snippet = @site.snippets.where(:slug => snippet_slug).first
|
|
|
|
raise "Could not find snippet: #{snippet_slug}" unless snippet
|
|
|
|
|
|
|
|
snippet.template.should == content
|
|
|
|
end
|
2010-08-21 22:48:24 +00:00
|
|
|
|