Sha256: 56c2b2079e573f3161af5af9982d8f98f9425b5cc173ef35edb0d1a9b04fd576

Contents?: true

Size: 1.97 KB

Versions: 3

Compression:

Stored size: 1.97 KB

Contents

require 'spec_helper'

describe StoredAttribute do

  describe :default_values do

    context :new do

      subject { Post.new }

      its(:show_date) { should be_false }
      its(:show_author) { should be_true }
      its(:background_color) { should == '#FFFFFF' }

    end

    context :create do

      subject { Post.create }

      its(:show_date) { should be_false }
      its(:show_author) { should be_true }
      its(:background_color) { should == '#FFFFFF' }

    end

  end

  describe :changing_values do

    context :new do

      subject { Post.new }

      before(:each) do
        subject.show_date = true
        subject.show_author = false
        subject.background_color = '#000000'
      end

      its(:show_date) { should be_true }
      its(:show_author) { should be_false }
      its(:background_color) { should == '#000000' }

    end

    context :create do

      subject { Post.create }

      before(:each) do
        subject.show_date = true
        subject.show_author = false
        subject.background_color = '#000000'
      end

      its(:show_date) { should be_true }
      its(:show_author) { should be_false }
      its(:background_color) { should == '#000000' }

      describe 'on initialize' do

        subject do
          Post.create({
            :show_date => true,
            :show_author => false,
            :background_color => '#000000'
          })
        end

        its(:show_date) { should be_true }
        its(:show_author) { should be_false }
        its(:background_color) { should == '#000000' }

      end

      describe 'with update' do

        subject do
          post = Post.create
          post.update_attributes({
            :show_date => true,
            :show_author => false,
            :background_color => '#000000'
          })
          post
        end

        its(:show_date) { should be_true }
        its(:show_author) { should be_false }
        its(:background_color) { should == '#000000' }

      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stored_attribute-1.0.0 spec/stored_attribute_spec.rb
stored_attribute-0.0.2 spec/stored_attribute_spec.rb
stored_attribute-0.0.1 spec/stored_attribute_spec.rb