changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb

changeset 16: 01fd3f10ae84
author: moriq@moriq.com
date: Mon Mar 10 10:13:18 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec_on_rails
1require File.dirname(__FILE__) + '/../../spec_helper'
2Spec::Runner.configuration.global_fixtures = :people
3
4describe ExplicitHelper, :type => :helper do
5 it "should not require naming the helper if describe is passed a type" do
6 method_in_explicit_helper.should match(/text from a method/)
7 end
8end
9
10module Spec
11 module Rails
12 module Example
13 describe HelperExampleGroup, :type => :helper do
14 helper_name :explicit
15
16 it "should have direct access to methods defined in helpers" do
17 method_in_explicit_helper.should =~ /text from a method/
18 end
19
20 it "should have access to named routes" do
21 rspec_on_rails_specs_url.should == "http://test.host/rspec_on_rails_specs"
22 rspec_on_rails_specs_path.should == "/rspec_on_rails_specs"
23 end
24
25 it "should fail if the helper method deson't exist" do
26 lambda { non_existant_helper_method }.should raise_error(NameError)
27 end
28 end
29
30
31 describe HelperExampleGroup, "#eval_erb", :type => :helper do
32 helper_name :explicit
33
34 it "should support methods that accept blocks" do
35 eval_erb("<% prepend 'foo' do %>bar<% end %>").should == "foobar"
36 end
37 end
38
39 describe HelperExampleGroup, ".fixtures", :type => :helper do
40 helper_name :explicit
41 fixtures :animals
42
43 it "should load fixtures" do
44 pig = animals(:pig)
45 pig.class.should == Animal
46 end
47
48 it "should load global fixtures" do
49 lachie = people(:lachie)
50 lachie.class.should == Person
51 end
52 end
53
54 describe HelperExampleGroup, "included modules", :type => :helper do
55 helpers = [
56 ActionView::Helpers::ActiveRecordHelper,
57 ActionView::Helpers::AssetTagHelper,
58 ActionView::Helpers::BenchmarkHelper,
59 ActionView::Helpers::CacheHelper,
60 ActionView::Helpers::CaptureHelper,
61 ActionView::Helpers::DateHelper,
62 ActionView::Helpers::DebugHelper,
63 ActionView::Helpers::FormHelper,
64 ActionView::Helpers::FormOptionsHelper,
65 ActionView::Helpers::FormTagHelper,
66 ActionView::Helpers::JavaScriptHelper,
67 ActionView::Helpers::NumberHelper,
68 ActionView::Helpers::PrototypeHelper,
69 ActionView::Helpers::ScriptaculousHelper,
70 ActionView::Helpers::TagHelper,
71 ActionView::Helpers::TextHelper,
72 ActionView::Helpers::UrlHelper
73 ]
74 helpers << ActionView::Helpers::PaginationHelper rescue nil #removed for 2.0
75 helpers << ActionView::Helpers::JavaScriptMacrosHelper rescue nil #removed for 2.0
76 helpers.each do |helper_module|
77 it "should include #{helper_module}" do
78 self.class.ancestors.should include(helper_module)
79 end
80 end
81 end
82
83 # TODO: BT - Helper Examples should proxy method_missing to a Rails View instance.
84 # When that is done, remove this method
85 describe HelperExampleGroup, "#protect_against_forgery?", :type => :helper do
86 it "should return false" do
87 protect_against_forgery?.should be_false
88 end
89 end
90 end
91 end
92end
93
94module Bug11223
95 # see http://rubyforge.org/tracker/index.php?func=detail&aid=11223&group_id=797&atid=3149
96 describe 'Accessing flash from helper spec', :type => :helper do
97 it 'should not raise an error' do
98 lambda { flash['test'] }.should_not raise_error
99 end
100 end
101end
102
103module Spec
104 module Rails
105 module Example
106 describe HelperExampleGroup do
107 it "should clear its name from the description" do
108 group = describe("foo", :type => :helper) do
109 $nested_group = describe("bar") do
110 end
111 end
112 group.description.to_s.should == "foo"
113 $nested_group.description.to_s.should == "foo bar"
114 end
115 end
116 end
117 end
118end