user and recipient and tests

This commit is contained in:
Jared Cosulich 2017-02-25 11:00:27 -05:00
parent d70e30ec93
commit df2ea95ceb
50 changed files with 1412 additions and 37 deletions

View file

@ -0,0 +1,42 @@
require 'rails_helper'
RSpec.describe "recipients/edit", type: :view do
before(:each) do
@recipient = assign(:recipient, Recipient.create!(
:name => "MyString",
:phone => "MyString",
:gender => "MyString",
:race => "MyString",
:ethnicity => "MyString",
:home_language_id => 1,
:income => "MyString",
:opted_out => false,
:school_id => 1
))
end
it "renders the edit recipient form" do
render
assert_select "form[action=?][method=?]", recipient_path(@recipient), "post" do
assert_select "input#recipient_name[name=?]", "recipient[name]"
assert_select "input#recipient_phone[name=?]", "recipient[phone]"
assert_select "input#recipient_gender[name=?]", "recipient[gender]"
assert_select "input#recipient_race[name=?]", "recipient[race]"
assert_select "input#recipient_ethnicity[name=?]", "recipient[ethnicity]"
assert_select "input#recipient_home_language_id[name=?]", "recipient[home_language_id]"
assert_select "input#recipient_income[name=?]", "recipient[income]"
assert_select "input#recipient_opted_out[name=?]", "recipient[opted_out]"
assert_select "input#recipient_school_id[name=?]", "recipient[school_id]"
end
end
end

View file

@ -0,0 +1,43 @@
require 'rails_helper'
RSpec.describe "recipients/index", type: :view do
before(:each) do
assign(:recipients, [
Recipient.create!(
:name => "Name",
:phone => "Phone",
:gender => "Gender",
:race => "Race",
:ethnicity => "Ethnicity",
:home_language_id => 2,
:income => "Income",
:opted_out => false,
:school_id => 3
),
Recipient.create!(
:name => "Name",
:phone => "Phone",
:gender => "Gender",
:race => "Race",
:ethnicity => "Ethnicity",
:home_language_id => 2,
:income => "Income",
:opted_out => false,
:school_id => 3
)
])
end
it "renders a list of recipients" do
render
assert_select "tr>td", :text => "Name".to_s, :count => 2
assert_select "tr>td", :text => "Phone".to_s, :count => 2
assert_select "tr>td", :text => "Gender".to_s, :count => 2
assert_select "tr>td", :text => "Race".to_s, :count => 2
assert_select "tr>td", :text => "Ethnicity".to_s, :count => 2
assert_select "tr>td", :text => 2.to_s, :count => 2
assert_select "tr>td", :text => "Income".to_s, :count => 2
assert_select "tr>td", :text => false.to_s, :count => 2
assert_select "tr>td", :text => 3.to_s, :count => 2
end
end

View file

@ -0,0 +1,42 @@
require 'rails_helper'
RSpec.describe "recipients/new", type: :view do
before(:each) do
assign(:recipient, Recipient.new(
:name => "MyString",
:phone => "MyString",
:gender => "MyString",
:race => "MyString",
:ethnicity => "MyString",
:home_language_id => 1,
:income => "MyString",
:opted_out => false,
:school_id => 1
))
end
it "renders new recipient form" do
render
assert_select "form[action=?][method=?]", recipients_path, "post" do
assert_select "input#recipient_name[name=?]", "recipient[name]"
assert_select "input#recipient_phone[name=?]", "recipient[phone]"
assert_select "input#recipient_gender[name=?]", "recipient[gender]"
assert_select "input#recipient_race[name=?]", "recipient[race]"
assert_select "input#recipient_ethnicity[name=?]", "recipient[ethnicity]"
assert_select "input#recipient_home_language_id[name=?]", "recipient[home_language_id]"
assert_select "input#recipient_income[name=?]", "recipient[income]"
assert_select "input#recipient_opted_out[name=?]", "recipient[opted_out]"
assert_select "input#recipient_school_id[name=?]", "recipient[school_id]"
end
end
end

View file

@ -0,0 +1,30 @@
require 'rails_helper'
RSpec.describe "recipients/show", type: :view do
before(:each) do
@recipient = assign(:recipient, Recipient.create!(
:name => "Name",
:phone => "Phone",
:gender => "Gender",
:race => "Race",
:ethnicity => "Ethnicity",
:home_language_id => 2,
:income => "Income",
:opted_out => false,
:school_id => 3
))
end
it "renders attributes in <p>" do
render
expect(rendered).to match(/Name/)
expect(rendered).to match(/Phone/)
expect(rendered).to match(/Gender/)
expect(rendered).to match(/Race/)
expect(rendered).to match(/Ethnicity/)
expect(rendered).to match(/2/)
expect(rendered).to match(/Income/)
expect(rendered).to match(/false/)
expect(rendered).to match(/3/)
end
end