Sha256: 396e3b8eec17c2070af0744464fc93fc6f0c3eb208e38b57263f8edce9e0761d

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'assert'

class User

  class BaseTest < Assert::Context
    desc "the User class"
    setup do
      @class = User
    end
    subject{ @class }

    should have_instance_methods :options, :preferences
  end

  class ClassPreferencesTest < BaseTest
    desc "preferences"
    subject{ @class.preferences }

    should have_instance_methods :namespace, :option, :define, :options, :metaclass
    should have_accessors :home_url, :show_messages, :font_size
  end

  class InstanceTest < BaseTest
    desc "instance"
    setup do
      @instance = @class.new
    end
    subject{ @instance }

    should have_instance_methods :preferences
  end

  class PreferencesTest < InstanceTest
    desc "preferences"
    setup do
      @preferences = @instance.preferences
      @preferences.home_url = "/home"
      @preferences.show_messages = false
      @preferences.font_size = 15
    end
    subject{ @preferences }

    should have_instance_methods :namespace, :option, :define, :options, :metaclass
    should have_accessors :home_url, :show_messages, :font_size

    should "have set the home_url" do
      assert_equal "/home", subject.home_url
    end
    should "have set show_messages" do
      assert_equal false, subject.show_messages
    end
    should "have set the font_size" do
      assert_equal 15, subject.font_size
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ns-options-0.1.1 test/integration/user_test.rb
ns-options-0.1.0 test/integration/user_test.rb