The Stack Overflow podcast is back! Listen to an interview with our new CEO.
2 deleted 43 characters in body
source | link

I'll try to contribute a bit.

Model

You shouldn't test FactoryGirl itself as in the first test. itIt already has its own tests. If itit's broken -, you'll know it by failed tests.

You'rYou're building :favourite every time. Try Try to do just the following:

  1. Test minimum valid object - Favoritefavorite with minimum values that allow object to be valid  ( thosethose that presence: :true in your model).

    describe Favorite
        subject(:favorite) {Favorite.new(title: title, something: something)}
    
        //Then control your key values with `let()`
    
        let(:title) {'Title'}
        let(:something) {'Something'}
    
        describe '#title' do
            context 'should be present' do
                before {favorite.title = ' '}
                it {should_not.be_valid}
            end
       end
    end
    
  2. Then you can add additional values if needed:

    describe '#some_fav_attr' do
        context 'should be valid' do
            let(:some_fav_attr) {'Text here'}
            it {expect(favorite.some_fav_attr).to eql('Text there')}
        end
    end
    
  1. Then you can add additional values if needed
    describe '#some_fav_attr' do
        context 'should be valid' do
            let(:some_fav_attr) {'Text here'}
            it {expect(favorite.some_fav_attr).to eql('Text there')}
        end
    end

Other tests lookslook fine forto me.

I'll try to contribute a bit.

Model

You shouldn't test FactoryGirl itself as in the first test. it already has its own tests. If it broken - you'll know it by failed tests.

You'r building :favourite every time. Try to do just following:

  1. Test minimum valid object - Favorite with minimum values that allow object to be valid( those that presence: :true in your model).

    describe Favorite
        subject(:favorite) {Favorite.new(title: title, something: something)}
    
        //Then control your key values with `let()`
    
        let(:title) {'Title'}
        let(:something) {'Something'}
    
        describe '#title' do
            context 'should be present' do
                before {favorite.title = ' '}
                it {should_not.be_valid}
            end
       end
    end
    
  1. Then you can add additional values if needed
    describe '#some_fav_attr' do
        context 'should be valid' do
            let(:some_fav_attr) {'Text here'}
            it {expect(favorite.some_fav_attr).to eql('Text there')}
        end
    end

Other tests looks fine for me.

Model

You shouldn't test FactoryGirl itself as in the first test. It already has its own tests. If it's broken, you'll know it by failed tests.

You're building :favourite every time. Try to do just the following:

  1. Test minimum valid object - favorite with minimum values that allow object to be valid  (those that presence: :true in your model).

    describe Favorite
        subject(:favorite) {Favorite.new(title: title, something: something)}
    
        //Then control your key values with `let()`
    
        let(:title) {'Title'}
        let(:something) {'Something'}
    
        describe '#title' do
            context 'should be present' do
                before {favorite.title = ' '}
                it {should_not.be_valid}
            end
       end
    end
    
  2. Then you can add additional values if needed:

    describe '#some_fav_attr' do
        context 'should be valid' do
            let(:some_fav_attr) {'Text here'}
            it {expect(favorite.some_fav_attr).to eql('Text there')}
        end
    end
    

Other tests look fine to me.

1
source | link

I'll try to contribute a bit.

Model

You shouldn't test FactoryGirl itself as in the first test. it already has its own tests. If it broken - you'll know it by failed tests.

You'r building :favourite every time. Try to do just following:

  1. Test minimum valid object - Favorite with minimum values that allow object to be valid( those that presence: :true in your model).

    describe Favorite
        subject(:favorite) {Favorite.new(title: title, something: something)}
    
        //Then control your key values with `let()`
    
        let(:title) {'Title'}
        let(:something) {'Something'}
    
        describe '#title' do
            context 'should be present' do
                before {favorite.title = ' '}
                it {should_not.be_valid}
            end
       end
    end
    
  1. Then you can add additional values if needed
    describe '#some_fav_attr' do
        context 'should be valid' do
            let(:some_fav_attr) {'Text here'}
            it {expect(favorite.some_fav_attr).to eql('Text there')}
        end
    end

Other tests looks fine for me.