Skip to content

Commit

Permalink
Update: Pass specs for major render paths
Browse files Browse the repository at this point in the history
  • Loading branch information
AidenEscamilla committed Feb 6, 2024
1 parent 8e0aeed commit fc5ce6c
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 47 deletions.
2 changes: 1 addition & 1 deletion job_tracker/spec/requests/home_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe "Homes", type: :request do
describe "GET /index" do
it "returns http success" do
get "/home/index"
get "/home#index"
expect(response).to have_http_status(:success)
end
end
Expand Down
4 changes: 2 additions & 2 deletions job_tracker/spec/routing/job_descriptions_routing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
expect(patch: "/job_descriptions/1").to route_to("job_descriptions#update", id: "1")
end

it "routes to #destroy" do
expect(delete: "/job_descriptions/1").to route_to("job_descriptions#destroy", id: "1")
it "does not routes to #destroy" do
expect(delete: "/job_descriptions/1").to_not route_to("job_descriptions#destroy", id: "1")
end
end
end
25 changes: 16 additions & 9 deletions job_tracker/spec/views/employers/edit.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,33 @@
name: "MyString",
phone_number: "MyString",
email: "MyString",
address: ""
address: { "street" => "MyStreet1234", "city" => "MyCity", "state" => "MyState", "zip" => 00005}
)
}

before(:each) do
assign(:employer, employer)
render
end

it "renders the edit employer form" do
render

assert_select "form[action=?][method=?]", employer_path(employer), "post" do

assert_select "input[name=?]", "employer[name]"

assert_select "input[name=?]", "employer[phone_number]"

assert_select "input[name=?]", "employer[email]"

assert_select "input[name=?]", "employer[address]"

assert_select "input[name=?]", "employer[name]"

assert_select "input[name=?]", "employer[phone_number]"

assert_select "input[name=?]", "employer[email]"

assert_select "input[name=?]", "employer[address][street]"

assert_select "input[name=?]", "employer[address][city]"

assert_select "input[name=?]", "employer[address][state]"

assert_select "input[name=?]", "employer[address][zip]"
end
end
end
22 changes: 11 additions & 11 deletions job_tracker/spec/views/employers/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
before(:each) do
assign(:employers, [
Employer.create!(
name: "Name",
phone_number: "Phone Number",
name: "Example",
email: "Email",
address: ""
phone_number: "1234567890",
address: { "street" => "MyStreet1234", "city" => "MyCity", "state" => "MyState", "zip" => 00005}
),
Employer.create!(
name: "Name",
phone_number: "Phone Number",
name: "Example",
email: "Email",
address: ""
phone_number: "1234567890",
address: { "street" => "MyStreet1234", "city" => "MyCity", "state" => "MyState", "zip" => 00005}
)
])
end

it "renders a list of employers" do
render
cell_selector = Rails::VERSION::STRING >= '7' ? 'div>p' : 'tr>td'
assert_select cell_selector, text: Regexp.new("Name".to_s), count: 2
assert_select cell_selector, text: Regexp.new("Phone Number".to_s), count: 2
assert_select cell_selector, text: Regexp.new("Email".to_s), count: 2
assert_select cell_selector, text: Regexp.new("".to_s), count: 2

assert_select "h2", text: "Name: Example", count: 2
assert_select "div>b", text: "Email:", count: 2
assert_select "div>b", text: "Phone Number:", count: 2
assert_select "div>b", text: "Address:", count: 2
end
end
16 changes: 11 additions & 5 deletions job_tracker/spec/views/employers/new.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
RSpec.describe "employers/new", type: :view do
before(:each) do
assign(:employer, Employer.new(
name: "MyString",
phone_number: "MyString",
email: "MyString",
address: ""
name: "MyName",
phone_number: "1234567890",
email: "[email protected]",
address: { "street" => "MyStreet", "city" => "MyCity", "state" => "MyState", "zip" => 12345 }
))
end

Expand All @@ -21,7 +21,13 @@

assert_select "input[name=?]", "employer[email]"

assert_select "input[name=?]", "employer[address]"
assert_select "input[name=?]", "employer[address][street]"

assert_select "input[name=?]", "employer[address][city]"

assert_select "input[name=?]", "employer[address][state]"

assert_select "input[name=?]", "employer[address][zip]"
end
end
end
10 changes: 9 additions & 1 deletion job_tracker/spec/views/job_applications/edit.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
require 'rails_helper'

RSpec.describe "job_applications/edit", type: :view do
let(:employer) {
Employer.create!(
name: "MyName",
phone_number: "1234567890",
email: "",
address: { "street" => "MyStreet", "city" => "MyCity", "state" => "MyState", "zip" => 12345 }
)
}
let(:job_application) {
JobApplication.create!()
JobApplication.create!(employer: employer)
}

before(:each) do
Expand Down
13 changes: 11 additions & 2 deletions job_tracker/spec/views/job_applications/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
require 'rails_helper'

RSpec.describe "job_applications/index", type: :view do
let(:employer) {
Employer.create!(
name: "MyName",
phone_number: "1234567890",
email: "",
address: { "street" => "MyStreet", "city" => "MyCity", "state" => "MyState", "zip" => 12345 }
)
}

before(:each) do
assign(:job_applications, [
JobApplication.create!(),
JobApplication.create!()
JobApplication.create!(employer: employer),
JobApplication.create!(employer: employer)
])
end

Expand Down
14 changes: 12 additions & 2 deletions job_tracker/spec/views/job_applications/show.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
require 'rails_helper'

RSpec.describe "job_applications/show", type: :view do
let(:employer) { Employer.create!(name: "MyString") }
let(:job_application) { JobApplication.create!(employer: employer) }
let(:job_description) { JobDescription.create!(job_application: job_application) }


before(:each) do
assign(:job_application, JobApplication.create!())
job_application.job_description = job_description
assign(:job_application, job_application)
end

it "renders attributes in <p>" do
it "renders attributes" do
render

assert_select "h1>b", text: "Title:", count: 1
assert_select "div>b", text: "Employer:", count: 1
assert_select "div>b", text: "Status:", count: 1
end
end
7 changes: 5 additions & 2 deletions job_tracker/spec/views/job_descriptions/edit.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
require 'rails_helper'

RSpec.describe "job_descriptions/edit", type: :view do
let(:employer) { Employer.create!(name: "MyString") }
let(:job_application) { JobApplication.create!(employer: employer) }

let(:job_description) {
JobDescription.create!(
description: "MyText",
requirements: "MyText",
job_classification: "MyString",
min_salary: 1,
max_salary: 1,
job_application: nil
job_application: job_application
)
}

Expand All @@ -31,7 +34,7 @@

assert_select "input[name=?]", "job_description[max_salary]"

assert_select "input[name=?]", "job_description[job_application_id]"
assert_select "select[name=?]", "job_description[job_application_id]"
end
end
end
22 changes: 13 additions & 9 deletions job_tracker/spec/views/job_descriptions/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require 'rails_helper'

RSpec.describe "job_descriptions/index", type: :view do
let(:employer) { Employer.create!(name: "MyString") }
let(:job_application1) { JobApplication.create!(employer: employer) }
let(:job_application2) { JobApplication.create!(employer: employer) }

before(:each) do
assign(:job_descriptions, [
JobDescription.create!(
Expand All @@ -9,27 +13,27 @@
job_classification: "Job Classification",
min_salary: 2,
max_salary: 3,
job_application: nil
job_application: job_application1
),
JobDescription.create!(
description: "MyText",
requirements: "MyText",
job_classification: "Job Classification",
min_salary: 2,
max_salary: 3,
job_application: nil
job_application: job_application2
)
])
end

it "renders a list of job_descriptions" do
render
cell_selector = Rails::VERSION::STRING >= '7' ? 'div>p' : 'tr>td'
assert_select cell_selector, text: Regexp.new("MyText".to_s), count: 2
assert_select cell_selector, text: Regexp.new("MyText".to_s), count: 2
assert_select cell_selector, text: Regexp.new("Job Classification".to_s), count: 2
assert_select cell_selector, text: Regexp.new(2.to_s), count: 2
assert_select cell_selector, text: Regexp.new(3.to_s), count: 2
assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2

assert_select "div>h2", text: Regexp.new("Job application:".to_s), count: 2
assert_select "div>p", text: Regexp.new("Description:".to_s), count: 2
assert_select "div>p", text: Regexp.new("Requirements".to_s), count: 2
assert_select "div>p", text: Regexp.new("Job classification".to_s), count: 2
assert_select "div>p", text: Regexp.new("Min salary:"), count: 2
assert_select "div>p", text: Regexp.new("Max salary:"), count: 2
end
end
7 changes: 5 additions & 2 deletions job_tracker/spec/views/job_descriptions/new.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
require 'rails_helper'

RSpec.describe "job_descriptions/new", type: :view do
let(:employer) { Employer.create!(name: "MyString") }
let(:job_application) { JobApplication.create!(employer: employer) }

before(:each) do
assign(:job_description, JobDescription.new(
description: "MyText",
requirements: "MyText",
job_classification: "MyString",
min_salary: 1,
max_salary: 1,
job_application: nil
job_application_id: job_application.id
))
end

Expand All @@ -27,7 +30,7 @@

assert_select "input[name=?]", "job_description[max_salary]"

assert_select "input[name=?]", "job_description[job_application_id]"
assert_select "select[name=?]", "job_description[job_application_id]"
end
end
end
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
require 'rails_helper'

RSpec.describe "job_descriptions/show", type: :view do
let(:employer) { Employer.create!(name: "MyString") }
let(:job_application) { JobApplication.create!(employer: employer) }
before(:each) do

assign(:job_description, JobDescription.create!(
description: "MyText",
requirements: "MyText",
job_classification: "Job Classification",
min_salary: 2,
max_salary: 3,
job_application: nil
job_application: job_application
))
end

Expand Down

0 comments on commit fc5ce6c

Please sign in to comment.