In Files

  • rails_generators/gruff/templates/controller.rb
  • rails_generators/gruff/templates/functional_test.rb
  • test/gruff_test_case.rb

Parent

Object

Constants

RMAGICK_BYPASS_VERSION_TEST

require ‘rubygems’

TEST_OUTPUT_DIR

require ‘test_timer’

Public Instance Methods

setup() click to toggle source

fixtures :data

 
               # File rails_generators/gruff/templates/functional_test.rb, line 11
def setup
  @controller = <%Q controller_class_name %>Controller.new
  @request    = ActionController::TestRequest.new
  @response   = ActionController::TestResponse.new
end
            
show() click to toggle source

Then reference it with the named route:

image_tag graph_url(:action => 'show', :id => 42)
 
               # File rails_generators/gruff/templates/controller.rb, line 9
  def show
    g = Gruff::Line.new
    # Uncomment to use your own theme or font
    # See http://colourlovers.com or http://www.firewheeldesign.com/widgets/ for color ideas
#     g.theme = {
#       :colors => ['#663366', '#cccc99', '#cc6633', '#cc9966', '#99cc99'],
#       :marker_color => 'white',
#       :background_colors => ['black', '#333333']
#     }
#     g.font = File.expand_path('artwork/fonts/VeraBd.ttf', RAILS_ROOT)

    g.title = "Gruff-o-Rama"
    
    g.data("Apples", [1, 2, 3, 4, 4, 3])
    g.data("Oranges", [4, 8, 7, 9, 8, 9])
    g.data("Watermelon", [2, 3, 1, 5, 6, 8])
    g.data("Peaches", [9, 9, 10, 8, 7, 9])

    g.labels = {0 => '2004', 2 => '2005', 4 => '2006'}

    send_data(g.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "gruff.png")
  end
            
test_show() click to toggle source

TODO Replace this with your actual tests

 
               # File rails_generators/gruff/templates/functional_test.rb, line 18
def test_show
  get :show
  assert_response :success
  assert_equal 'image/png', @response.headers['Content-Type']
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.

blog comments powered by Disqus