Sha256: 7618f7949a0b62b3bd575e6a8c9e2a10fcc94c08508d02c1af6f76144442d091

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

describe "SugarCube::Anonymous" do

  before do
    @h = SugarCube::Anonymous[{ foo: 'FOO', "bar" => 'BAR' }]
  end

  describe "NSDictionary#to_object" do

    it 'should return an instance of SugarCube::Anonymous' do
      SugarCube::Anonymous.should === { foo: 'FOO', "bar" => 'BAR' }.to_object
    end

  end

  describe "constructor" do

    it 'should give an instance of SugarCube::Anonymous' do
      SugarCube::Anonymous.should === @h
    end

  end

  describe "getter" do

    it 'should have an #foo method, and return "FOO"' do
      @h.foo.should == 'FOO'
    end

    it 'should have an #bar method, and return "BAR"' do
      @h.bar.should == 'BAR'
    end

    it 'should raise NoMethodError on non-existing keys' do
      should.raise(NoMethodError) {
        @h.hoge
      }
    end

  end

  describe "setter" do

    it 'should have an #foo= method, and return "Foo"' do
      @h.foo = 'Foo'
      @h.foo.should == 'Foo'
    end

    it 'should have a #bar= method, and return "Bar"' do
      @h.bar = 'Bar'
      @h.bar.should == 'Bar'
    end

    it 'should raise NoMethodError on non-existing keys' do
      should.raise(NoMethodError) {
        @h.hoge.should == 'Hoge'
      }
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sugarcube-0.20.1 spec/anonymous_spec.rb
sugarcube-0.20.0 spec/anonymous_spec.rb