public
Description: Code as Art, Art as Code. Processing and Ruby are meant for each other.
Homepage: http://github.com/jashkenas/ruby-processing/wikis
Clone URL: git://github.com/jashkenas/ruby-processing.git
Search Repo:
ruby-processing / specs / base_exporter_spec.rb
100644 61 lines (48 sloc) 1.606 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Specs for the Basic utility functions of the exporters.
# -- omygawshkenas
 
require 'script/base_exporter'
 
describe "Processing::BaseExporter" do
  before :all do
    @ex = Processing::BaseExporter.new
    @ex.instance_eval do
      @main_file = "full_screen.rb"
      @main_file_path = "samples/full_screen.rb"
    end
    @info = @ex.extract_information
  end
  
  describe "(extracting information from source code)" do
    
    it "should get the class name" do
      @info[:class_name].should == "FullScreen"
    end
    
    it "should get the title" do
      @info[:title].should == "Full Screen"
    end
    
    it "should get the width" do
      @info[:width].should == "600"
    end
    
    it "should get the height" do
      @info[:height].should == "600"
    end
    
    it "should get the description" do
      @info[:description].should_not be_empty
    end
    
    it "should get the libraries it needs to load" do
      @info[:libs_to_load].should == ["opengl"]
    end
    
    it "should be able to set instance variables" do
      @ex.hash_to_ivars(@info)
      ["@class_name", "@width", "@height", "@description", "@libs_to_load", "@title"].each do |var|
        @ex.instance_variables.should include(var)
      end
    end
    
    it "should extract requires that actually exist" do
      @ex.extract_real_requires(__FILE__).should == ["script/base_exporter.rb"]
    end
  end
  
  it "should be able to render erb" do
    @mom = "Mom"
    erb = "Hello <%= @mom %>!"
    ans = @ex.render_erb_from_string_with_binding(erb, binding)
    ans.should == "Hello Mom!"
  end
  
end