mirror of
https://github.com/edcommonwealth/Dashboard.git
synced 2026-03-16 09:45:53 -07:00
set up example scaffold with rspec + factorybot tests
This commit is contained in:
parent
533c921a6d
commit
d1e6fb1e39
23 changed files with 512 additions and 6 deletions
26
spec/views/dashboard/examples/edit.html.erb_spec.rb
Normal file
26
spec/views/dashboard/examples/edit.html.erb_spec.rb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
require "rails_helper"
|
||||
|
||||
module Dashboard
|
||||
RSpec.xdescribe "dashboard/examples/edit", type: :view do
|
||||
let(:example) do
|
||||
Example.create!(
|
||||
text: "MyString",
|
||||
body: "MyText"
|
||||
)
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
assign(:example, example)
|
||||
end
|
||||
|
||||
it "renders the edit example form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", example_path(example), "post" do
|
||||
assert_select "input[name=?]", "example[text]"
|
||||
|
||||
assert_select "textarea[name=?]", "example[body]"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
26
spec/views/dashboard/examples/index.html.erb_spec.rb
Normal file
26
spec/views/dashboard/examples/index.html.erb_spec.rb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
require "rails_helper"
|
||||
require "nokogiri"
|
||||
|
||||
module Dashboard
|
||||
RSpec.describe "/dashboard/examples/index", type: :view do
|
||||
before(:each) do
|
||||
assign(:examples, [
|
||||
Example.create!(
|
||||
text: "Word",
|
||||
body: "Sentence"
|
||||
),
|
||||
Example.create!(
|
||||
text: "Word",
|
||||
body: "Sentence"
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it "renders a list of examples" do
|
||||
render
|
||||
cell_selector = Rails::VERSION::STRING >= "7" ? "div>p" : "tr>td"
|
||||
assert_select cell_selector, text: Regexp.new("Word".to_s), count: 2
|
||||
assert_select cell_selector, text: Regexp.new("Sentence".to_s), count: 2
|
||||
end
|
||||
end
|
||||
end
|
||||
22
spec/views/dashboard/examples/new.html.erb_spec.rb
Normal file
22
spec/views/dashboard/examples/new.html.erb_spec.rb
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
require "rails_helper"
|
||||
|
||||
module Dashboard
|
||||
RSpec.xdescribe "dashboard/examples/new", type: :view do
|
||||
before(:each) do
|
||||
assign(:example, Example.new(
|
||||
text: "MyString",
|
||||
body: "MyText"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders new example form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", examples_path, "post" do
|
||||
assert_select "input[name=?]", "example[text]"
|
||||
|
||||
assert_select "textarea[name=?]", "example[body]"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
18
spec/views/dashboard/examples/show.html.erb_spec.rb
Normal file
18
spec/views/dashboard/examples/show.html.erb_spec.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
require "rails_helper"
|
||||
|
||||
module Dashboard
|
||||
RSpec.describe "dashboard/examples/show", type: :view do
|
||||
before(:each) do
|
||||
assign(:example, Example.create!(
|
||||
text: "Word",
|
||||
body: "Sentence"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
expect(rendered).to match(/Word/)
|
||||
expect(rendered).to match(/Sentence/)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue