Sha256: 718532e4eeb08a829150b218fc1cf6fdd5d797c9dbe6adc844e43448827407b9

Contents?: true

Size: 949 Bytes

Versions: 1

Compression:

Stored size: 949 Bytes

Contents

# frozen_string_literal: true

require "assert"
require "rails-nm"

module RailsNm
  class SystemTests < Assert::Context
    desc "RailsNm"
    subject{ RailsNm }
  end

  class RenderTests < SystemTests
    desc "when rendering an Nm template in Rails"

    let(:user_class){ Struct.new(:id, :first_name, :last_name) }
    let(:users) do
      Array.new(Factory.integer(3)) do
        user_class.new(Factory.integer, Factory.string, Factory.string)
      end
    end

    let(:template_source) do
      <<~SOURCE
        map @users do |user|
          partial "users/user.json", :user => user
        end
      SOURCE
    end

    should "should render as expected" do
      exp =
        users.map do |user|
          {
            "id" => user.id,
            "firstName" => user.first_name,
            "lastName" => user.last_name,
          }
        end

      assert_that(render(template_source, users: users)).equals(exp)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-nm-0.1.0 test/system/rails-nm_tests.rb