Sha256: 8032669d5790a3c3d5a41f8f7aeb96c3134196492ed064d3d2c79f35d2738bce

Contents?: true

Size: 1.18 KB

Versions: 30

Compression:

Stored size: 1.18 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe Resourceful::Response, "when first created" do
  before(:each) { @response = Resourceful::Response.new }

  it "should have an empty formats array" do
    @response.formats.should == []
  end
end

describe Resourceful::Response, "with a few formats" do
  before :each do
    @response = Resourceful::Response.new
    @response.html
    @response.js  {'javascript'}
    @response.xml {'xml'}
  end

  it "should store the formats and blocks" do
    @response.formats.should have_any {|f,p| f == :js  && p.call == 'javascript'}
    @response.formats.should have_any {|f,p| f == :xml && p.call == 'xml'}
  end

  it "should give formats without a block an empty block" do
    @response.formats.should have_any {|f,p| f == :html && Proc === p && p.call.nil?}
  end

  it "shouldn't allow duplicate formats" do
    @response.js {'not javascript'}
    @response.formats.should     have_any {|f,p| f == :js && p.call == 'javascript'}
    @response.formats.should_not have_any {|f,p| f == :js && p.call == 'not javascript'}
  end

  it "should keep the formats in sorted order" do
    @response.formats.map(&:first).should == [:html, :js, :xml]
  end
end

Version data entries

30 entries across 30 versions & 5 rubygems

Version Path
make_resourceful-2.0.0.pre.beta spec/response_spec.rb
make_resourceful-1.0.2 spec/response_spec.rb
radiant-templates-extension-1.0.8 vendor/plugins/make_resourceful/spec/response_spec.rb
radiant-templates-extension-1.0.7 vendor/plugins/make_resourceful/spec/response_spec.rb
make_resourceful_rails2-1.0.1.1 spec/response_spec.rb
make_resourceful_rails2-1.0.1 spec/response_spec.rb
make_resourceful-1.0.1 spec/response_spec.rb
make_resourceful-1.0 spec/response_spec.rb
easy_admin_ui-0.5.9 vendor/plugins/make_resourceful/spec/response_spec.rb
easy_admin_ui-0.5.8 vendor/plugins/make_resourceful/spec/response_spec.rb
easy_admin_ui-0.5.7 vendor/plugins/make_resourceful/spec/response_spec.rb
easy_admin_ui-0.5.6 vendor/plugins/make_resourceful/spec/response_spec.rb
easy_admin_ui-0.5.5 vendor/plugins/make_resourceful/spec/response_spec.rb
easy_admin_ui-0.5.4 vendor/plugins/make_resourceful/spec/response_spec.rb
easy_admin_ui-0.5.3 vendor/plugins/make_resourceful/spec/response_spec.rb
easy_admin_ui-0.5.2 vendor/plugins/make_resourceful/spec/response_spec.rb
easy_admin_ui-0.5.1 vendor/plugins/make_resourceful/spec/response_spec.rb
easy_admin_ui-0.5.0 vendor/plugins/make_resourceful/spec/response_spec.rb
radiant-templates-extension-1.0.6 vendor/plugins/make_resourceful/spec/response_spec.rb
radiant-templates-extension-1.0.5 vendor/plugins/make_resourceful/spec/response_spec.rb