File: test_configuration.rb

package info (click to toggle)
ruby-rabl-rails 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 268 kB
  • ctags: 179
  • sloc: ruby: 1,480; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 963 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'helper'

class TestConfiguration < MINITEST_TEST_CLASS
  describe 'Configuration' do
    it 'has a zero score by default' do
      config = RablRails::Configuration.new
      assert_equal 0, config.result_flags
    end

    it 'sets a bit per option' do
      config = RablRails::Configuration.new
      config.replace_nil_values_with_empty_strings = true
      assert_equal 1, config.result_flags

      config = RablRails::Configuration.new
      config.replace_empty_string_values_with_nil = true
      assert_equal 2, config.result_flags

      config = RablRails::Configuration.new
      config.exclude_nil_values = true
      assert_equal 4, config.result_flags
    end

    it 'allows mutiple bits to be set at the same time' do
      config = RablRails::Configuration.new
      config.replace_nil_values_with_empty_strings = true
      config.replace_empty_string_values_with_nil = true
      assert_equal 3, config.result_flags
    end
  end
end