Sha256: eb3767453fbe5b137fa2a2eab3f26804a82c522e0f0f30fa6d2833f9b4f9fd0b

Contents?: true

Size: 767 Bytes

Versions: 14

Compression:

Stored size: 767 Bytes

Contents

module SnippetTestHelper
  VALID_SNIPPET_PARAMS = {
    :name => 'test-snippet',
    :content => 'Funness'
  }
  
  def snippet_params(options = {})
    params = VALID_SNIPPET_PARAMS.dup
    params.merge!(:name => @snippet_name) if @snippet_name
    params.merge!(options)
  end
  
  def destroy_test_snippet(name = @snippet_name)
    while snippet = get_test_snippet(name) do
      snippet.destroy
    end
  end
  
  def get_test_snippet(name = @snippet_name)
    Snippet.find_by_name(name)
  end
  
  def create_test_snippet(options = {})
    options[:name] ||= @snippet_name if @snippet_name
    snippet = Snippet.new snippet_params(options)
    if snippet.save
      snippet
    else
      raise "snippet <#{snippet.inspect}> could not be saved"
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
radiant-0.5.0 test/helpers/snippet_test_helper.rb
radiant-0.5.1 test/helpers/snippet_test_helper.rb
radiant-0.5.2 test/helpers/snippet_test_helper.rb
radiant-0.6.1 test/helpers/snippet_test_helper.rb
radiant-0.6.0 test/helpers/snippet_test_helper.rb
radiant-0.6.2 test/helpers/snippet_test_helper.rb
radiant-0.6.3 test/helpers/snippet_test_helper.rb
radiant-0.6.5.1 test/helpers/snippet_test_helper.rb
radiant-0.6.4 test/helpers/snippet_test_helper.rb
radiant-0.6.5 test/helpers/snippet_test_helper.rb
radiant-0.6.6 test/helpers/snippet_test_helper.rb
radiant-0.6.7 test/helpers/snippet_test_helper.rb
radiant-0.6.9 test/helpers/snippet_test_helper.rb
radiant-0.6.8 test/helpers/snippet_test_helper.rb