Sha256: 3dda76c577fc719a2ca2468dc795f5bf5d853b1ffe9a2a797d98219281df0e97

Contents?: true

Size: 1.61 KB

Versions: 3

Compression:

Stored size: 1.61 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'
Spec::Runner.configuration.global_fixtures = :people

describe "HelperBehaviour", :behaviour_type => :helper do
  helper_name :explicit
  
  it "should have direct access to methods defined in helpers" do
    method_in_explicit_helper.should =~ /text from a method/
  end
end


describe "HelperBehaviour#eval_erb", :behaviour_type => :helper do
  helper_name :explicit
  
  it "should support methods that accept blocks" do
    eval_erb("<% prepend 'foo' do %>bar<% end %>").should == "foobar"
  end
end

describe "HelperBehaviour.fixtures", :behaviour_type => :helper do
  helper_name :explicit
  fixtures :animals

  it "loads fixtures" do
    pig = animals(:pig)
    pig.class.should == Animal
  end

  it "loads global fixtures" do
    lachie = people(:lachie)
    lachie.class.should == Person
  end  
end

describe ExplicitHelper, :behaviour_type => :helper do
  it "should not require naming the helper if describe is passed a type" do
    method_in_explicit_helper.should match(/text from a method/)
  end
end

module Spec
  module Rails
    module DSL
      describe HelperBehaviour do
        it "should tell you its behaviour_type is :helper" do
          behaviour = HelperBehaviour.new("") {}
          behaviour.behaviour_type.should == :helper
        end
      end
    end
  end
end

module Bug11223
  # see http://rubyforge.org/tracker/index.php?func=detail&aid=11223&group_id=797&atid=3149
  describe 'Accessing flash from helper spec', :behaviour_type => :helper do
    it 'should not raise an error' do
      lambda { flash['test'] }.should_not raise_error
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
has_finder-0.1.1 spec/rails/vendor/plugins/rspec_on_rails/spec/rails/dsl/helper_spec_spec.rb
has_finder-0.1.2 spec/rails/vendor/plugins/rspec_on_rails/spec/rails/dsl/helper_spec_spec.rb
has_finder-0.1.3 spec/rails/vendor/plugins/rspec_on_rails/spec/rails/dsl/helper_spec_spec.rb