Sha256: 96d412e24139cc297e17734b6e3ff31b298b5d22a38e9643b0159eb4c3203e14

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

require 'test_helper'
require 'cell/rails/helper_api'


class RailsHelperAPITest < MiniTest::Spec
  class ::Fruit
    extend ActiveModel::Naming
    include ActiveModel::Conversion

    def initialize(attributes={})
      @attributes = attributes
    end

    def title
      @attributes[:title]
    end

    def persisted?
      false
    end
  end


  class FakeUrlFor # it be sinatra's url helper instance
    def url_for(*)
    end
  end

  module FakeHelpers
    def fruits_path(model, *args)
      "/fruits"
    end
  end

  class BassistCell < Cell::Base
    include Cell::Rails::HelperAPI
    include AbstractController::Helpers

    self._helpers = FakeHelpers
    self._routes = FakeUrlFor.new

    def edit
      @tone = "C"
      @fruit = Fruit.new(:title => "Banana")
      render
    end
  end

  describe "Rails::HelperAPI" do
    it "allows accessing the request object" do
      skip unless Cell.rails_version.~ ("3.2") # FIXME: that is only working in Rails 3.2.

      form = BassistCell.new.render_state(:edit)
      form.must_match /<form accept-charset="UTF-8" action="\/fruits"/
      form.must_match /name="fruit\[title\]"/
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cells-3.11.3 test/rails_helper_api_test.rb
cells-3.11.2 test/rails_helper_api_test.rb
cells-3.11.1 test/rails_helper_api_test.rb
cells-3.11.0 test/rails_helper_api_test.rb