Sha256: 718fb39198566d2c6c65439e822660506bc94e911823aa5dbfe21c7d6e103757

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

module Trajectory
  describe Users do
    it 'can be initialize from an array of JSON attributes of its components' do
      json_users_collection = [{'id' => 1234, 'email' => 'foo@exemple.com'}, {'id' => 42, 'email' => 'bar@exemple.com'}]

      users = Users.from_json(json_users_collection)

      users.should be_kind_of(Users)
      users.first.id.should == 1234
      users.first.email.should == 'foo@exemple.com'

      users[1].id.should == 42
      users[1].email.should == 'bar@exemple.com'
    end

    it 'can find a project by id' do
      user = double(:user, id: 1234)
      users = Users.new(double(:project, id: 1),
                 double(:user, id: 2),
                 user,
                 double(:user, id: 3))

      users.find_by_id(1234).should == user
    end

    it "returns false when it can't find a user by id" do
      users = Users.new(double(:user, id: 1),
                              double(:user, id: 2),
                              double(:user, id: 3))

      users.find_by_id(1234).should == false
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trajectory-0.1.2 spec/unit/domain/users_spec.rb
trajectory-0.1.1 spec/unit/domain/users_spec.rb
trajectory-0.1.0 spec/unit/domain/users_spec.rb