Sha256: e4c542eff82d38909a27721985b4117865aac59f59c936f61603124a20a48825

Contents?: true

Size: 1.15 KB

Versions: 17

Compression:

Stored size: 1.15 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

describe 'Class definition returning its last value' do
  it 'with a number' do
    value = class Klass1
      def hello; 'hello again'; end
      123
    end

    value.should == 123
  end

  it 'with a string' do
    value = class Klass2
      def hello; 'hello again'; end
      'hi!'
    end

    value.should == 'hi!'
  end

  it 'with a method' do
    value = class Klass2
      def hello; 'hello again'; end
    end

    value.should == nil
  end

  it 'with a class method' do
    value = class Klass3
      def self.hello; 'hello again'; end
    end

    value.should == nil
  end

  it 'with nothing' do
    value = class Klass4; end
    value.should == nil
  end

  it 'with attr_*' do
    value = class Klass5
      attr_accessor :my_attribute
    end
    value.should == nil
  end

  it 'with a nested class/module' do
    value = class Klass6
      class Klass
        123
      end
    end
    value.should == 123
  end

  it 'with a ' do
    value = class Klass7
      class Klass
        123
      end
    end
    value.should == 123
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
opal-0.3.44 spec/rubyspec/core/class/last_value_spec.rb
opal-0.3.43 spec/rubyspec/core/class/last_value_spec.rb
opal-0.3.42 spec/core/class/last_value_spec.rb
opal-0.3.41 spec/core/class/last_value_spec.rb
opal-0.3.40 spec/core/class/last_value_spec.rb
opal-0.3.39 spec/core/class/last_value_spec.rb
opal-0.3.38 spec/core/class/last_value_spec.rb
opal-0.3.37 spec/core/class/last_value_spec.rb
opal-0.3.36 spec/core/class/last_value_spec.rb
opal-0.3.35 spec/core/class/last_value_spec.rb
opal-0.3.34 spec/core/class/last_value_spec.rb
opal-0.3.33 spec/core/class/last_value_spec.rb
opal-0.3.32 spec/core/class/last_value_spec.rb
opal-0.3.31 spec/core/class/last_value_spec.rb
opal-0.3.30 spec/core/class/last_value_spec.rb
opal-0.3.29 spec/core/class/last_value_spec.rb
opal-0.3.28 spec/core/class/last_value_spec.rb