Sha256: 59a38fd417da13f54a1ffa79badadb38bed26544e8a0f1ead37ce36f4349a17a

Contents?: true

Size: 759 Bytes

Versions: 12

Compression:

Stored size: 759 Bytes

Contents

require 'tmpdir'
require 'pathname'
require File.expand_path('../../lib/rabl', __FILE__)

class TestHelperMethods
  include Rabl::Helpers
end

context "Rabl::Helpers" do
  setup do
    @helper_class = TestHelperMethods.new
    @user = User.new
  end

  context "for data_name method" do
    asserts "returns nil if no data" do
      @helper_class.data_name(nil)
    end.equals(nil)

    asserts "returns alias if hash with symbol is passed" do
      @helper_class.data_name(@user => :user)
    end.equals(:user)

    asserts "returns name of first object of a collection" do
      @helper_class.data_name([@user, @user])
    end.equals('users')

    asserts "returns name of an object" do
      @helper_class.data_name(@user)
    end.equals('user')
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rabl-0.6.10 test/helpers_test.rb
rabl-0.6.9 test/helpers_test.rb
rabl-0.6.8 test/helpers_test.rb
rabl-0.6.7 test/helpers_test.rb
rabl-0.6.6 test/helpers_test.rb
rabl-0.6.5 test/helpers_test.rb
rabl-0.6.3 test/helpers_test.rb
rabl-0.6.2 test/helpers_test.rb
rabl-0.6.1 test/helpers_test.rb
rabl-0.6.0 test/helpers_test.rb
rabl-0.5.5.j test/helpers_test.rb
rabl-0.5.5.i test/helpers_test.rb