Sha256: fc6d8d4ca07ac5501818c3f9349c0f4be8970dadc6433460ddf9da61209bf571

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 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

    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.rails3_1_or_more? and Rails::VERSION::MINOR == 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.10.1 test/rails_helper_api_test.rb
cells-3.10.0 test/rails_helper_api_test.rb
cells-3.9.1 test/rails_helper_api_test.rb
cells-3.9.0 test/rails_helper_api_test.rb