Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test fixes #46

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/controllers/manufacturers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RSpec.describe ManufacturersController, type: :controller do
before :each do
user = create(:user)
@manufacturer = create(:manufacturer)
create(:manufacturer)
session_login(user)
end

Expand Down
2 changes: 0 additions & 2 deletions spec/controllers/robot_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
require 'rails_helper'

RSpec.describe RobotsController, type: :controller do
# let!(:user) {User.create!(username: 'test', email: '[email protected]', password: 'password')}

before :each do
user = create(:user)
session_login(user)
Expand Down
17 changes: 10 additions & 7 deletions spec/controllers/sessions_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require 'rails_helper'

RSpec.describe SessionsController, type: :controller do
let!(:user) {User.create(username: 'test', email: '[email protected]', password: 'password')}
let!(:manufacturer) {Manufacturer.create!(name: "LKDVDLnjldksjldskj")}
let!(:model) {Model.create!(model_designation: "RX113", manufacturer_id: manufacturer.id)}
let!(:robot) {Robot.create!(designation: "HAL", inventory: false, model_id: model.id, user_id: user.id )}
# let!(:user) {User.create(username: 'test', email: '[email protected]', password: 'password')}
# let!(:manufacturer) {Manufacturer.create!(name: "LKDVDLnjldksjldskj")}
# let!(:model) {Model.create!(model_designation: "RX113", manufacturer_id: manufacturer.id)}
# let!(:robot) {Robot.create!(designation: "HAL", inventory: false, model_id: model.id, user_id: user.id )}

before :each do
user = create(:user)
user = build(:user)
session_login(user)
end

Expand All @@ -26,8 +26,11 @@
xdescribe 'POST "#create"' do
context "when valid params are passed" do
it "responds with status code 302" do
post :create, { User: { email: "[email protected]", password: "password" } }
expect(response).to have_http_status 302

post :create, params: {email: "[email protected]", password: "password"}
user = create(:user).attributes
p user
expect(response).to redirect_to(robots_path)
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/factories/models.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FactoryGirl.define do
# factory :model do
# model_designation "RX113"
# manufacturer_id 1
# end
# end
FactoryGirl.define do
factory :model do
model_designation "RX113"
manufacturer_id 15
end
end
2 changes: 1 addition & 1 deletion spec/factories/robots.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FactoryGirl.define do
factory :model do
factory :robot do
designation "HAL"
inventory false
model_id 1
Expand Down
6 changes: 3 additions & 3 deletions spec/models/manufacturer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe Manufacturer, type: :model do
it "validates that manufacturer has a name" do
expect(FactoryGirl.build(:manufacturer)).to be_valid
expect(create(:manufacturer)).to be_valid
end

it "should require a name" do
Expand All @@ -11,9 +11,9 @@

it "has many models" do
should have_many(:models)
end
end

it "has many robots" do
should have_many(:robots)
end
end
end
10 changes: 6 additions & 4 deletions spec/models/model_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
require 'rails_helper'

RSpec.describe Model, type: :model do
let!(:manufacturer) {Manufacturer.create!(name: "LKDVDLnjldksjldskj")}
let!(:model) {Model.create!(model_designation: "RX113", manufacturer_id: manufacturer.id)}

xit "validates that model has a model_designation" do
expect(FactoryGirl.build(:model)).to be_valid
it "validates that model has a model_designation" do
expect(model).to be_valid
end

it "belongs to a manufacturer" do
should belong_to(:manufacturer)
end
end

it "has many robots" do
should have_many(:robots)
end
end
end
2 changes: 1 addition & 1 deletion spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
it 'has many robots' do
should have_many(:robots)
end
end
end
end
end
1 change: 1 addition & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'spec_helper'
require 'rspec/rails'
require 'rack_session_access/capybara'
require 'factory_girl_rails'
# Add additional requires below this line. Rails is not loaded until this point!

# Requires supporting ruby files with custom matchers and macros, etc, in
Expand Down