Sha256: 2aac6a2add0b92cfc381cb18f9872b5080f255a0259cf5985157e5f3f9eb5d19
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 KB
Contents
# frozen_string_literal: true require "assert" require "rails-nm" require "much-config" require "nm/source" module RailsNm class UnitTests < Assert::Context desc "RailsNm" subject{ unit_module } let(:unit_module){ RailsNm } should have_imeths :source, :encode, :render_content should "be configured as expected" do assert_that(subject).includes(MuchConfig) assert_that(subject.config).is_a(unit_module::Config) end should "know its attributes" do assert_that(subject.source).equals(subject.config.source) end should "encode using the configured encoder" do object = [{ key: "value" }, ["key", "value"]].sample assert_that(subject.encode(object)).equals(JSON.dump(object)) end # See test/system/rails-nm_tests.rb for system tests that test rendering # template content. end class ConfigTests < UnitTests desc "Config" subject{ config_class } let(:config_class){ unit_module::Config } end class ConfigInitTests < ConfigTests desc "when init" subject{ config_class.new } should have_accessors :views_path, :default_format, :extension should have_accessors :locals, :cache, :encoder should have_imeths :source should "know its attributes" do assert_that(subject.views_path).equals(::Rails.root.join("app/views")) assert_that(subject.default_format).equals(:json) assert_that(subject.extension).equals(:nm) assert_that(subject.locals).equals({}) assert_that(subject.cache).equals(!Rails.env.development?) assert_that(subject.encoder).is_a(Proc) assert_that(subject.source) .equals( Nm::Source.new( subject.views_path, cache: subject.cache, extension: subject.extension, locals: subject.locals, ), ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails-nm-0.1.0 | test/unit/rails-nm_tests.rb |