Upgraded Rails and RSpec
[monkeycharger.git] / vendor / plugins / rspec_on_rails / spec / rails / dsl / helper_spec_spec.rb
blob569efe1d90672ce516d5c8b6b2c5f119c0c7f258
1 require File.dirname(__FILE__) + '/../../spec_helper'
2 Spec::Runner.configuration.global_fixtures = :people
4 describe "HelperBehaviour", :behaviour_type => :helper do
5   helper_name :explicit
6   
7   it "should have direct access to methods defined in helpers" do
8     method_in_explicit_helper.should =~ /text from a method/
9   end
10 end
13 describe "HelperBehaviour#eval_erb", :behaviour_type => :helper do
14   helper_name :explicit
15   
16   it "should support methods that accept blocks" do
17     eval_erb("<% prepend 'foo' do %>bar<% end %>").should == "foobar"
18   end
19 end
21 describe "HelperBehaviour.fixtures", :behaviour_type => :helper do
22   helper_name :explicit
23   fixtures :animals
25   it "loads fixtures" do
26     pig = animals(:pig)
27     pig.class.should == Animal
28   end
30   it "loads global fixtures" do
31     lachie = people(:lachie)
32     lachie.class.should == Person
33   end  
34 end
36 describe ExplicitHelper, :behaviour_type => :helper do
37   it "should not require naming the helper if describe is passed a type" do
38     method_in_explicit_helper.should match(/text from a method/)
39   end
40 end
42 module Spec
43   module Rails
44     module DSL
45       describe HelperBehaviour do
46         it "should tell you its behaviour_type is :helper" do
47           behaviour = HelperBehaviour.new("") {}
48           behaviour.behaviour_type.should == :helper
49         end
50       end
51     end
52   end
53 end
55 module Bug11223
56   # see http://rubyforge.org/tracker/index.php?func=detail&aid=11223&group_id=797&atid=3149
57   describe 'Accessing flash from helper spec', :behaviour_type => :helper do
58     it 'should not raise an error' do
59       lambda { flash['test'] }.should_not raise_error
60     end
61   end
62 end