instagram_api_gem icon indicating copy to clipboard operation
instagram_api_gem copied to clipboard

Adding some testing

Open develaper opened this issue 6 years ago • 2 comments

Hi, I was working in a personal project and just discovered this gem and noticed that there's a TODO section in the readme file and I would like to start adding some testing. Let me know if you have any advice.

develaper avatar Sep 17 '18 15:09 develaper

Hi there! Sorry for the delay with answer. Sure. you're welcome to make pull request and add some test suits. I'll merge your changes. I don't have any advice for now. Please, concretize or we can start just from the code. Looking forward for your pull requests.

SergeyMell avatar Sep 23 '18 19:09 SergeyMell

Hi Sergey, I started with the User class. I was trying to test the initializer method when realized that there is no attr_accessor for :user_id so :

context 'initialize' do
   it 'sets user_id when id is specified' do
      user = InstagramApi::User.new('123')
      expect(user.user_id).to eq('123')
   end
end

Results in a NoMethodError: undefined method user_id' for #<InstagramApi::User:0x0000000357d980 @user_id="123">`

But with the attr_accessor the test pass, is there any reason to the lack of it? Should avoid testing the initializer or should add attr_accessor?

develaper avatar Sep 27 '18 16:09 develaper