Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use decribed_class in model specs so that when we change names, there…
…'s less to do
- Loading branch information
Showing
5 changed files
with
80 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,70 @@ | ||
require "spec_helper" | ||
|
||
describe Summary, type: :model do | ||
|
||
context "when generating summary" do | ||
before(:each) do | ||
mock_file("http://example.com/test.csv", 'csvs/valid.csv') | ||
validation = Validation.create_validation("http://example.com/test.csv") | ||
|
||
mock_file("http://example.com/test2.csv", 'csvs/errors.csv') | ||
validation = Validation.create_validation("http://example.com/test2.csv") | ||
|
||
mock_file("http://www.example.com/test3.csv", 'csvs/warnings.csv') | ||
validation = Validation.create_validation("http://www.example.com/test3.csv") | ||
@summary = Summary.generate | ||
|
||
@summary = described_class.generate | ||
end | ||
|
||
it "should record number of valid sources" do | ||
expect(@summary.states["valid"]).to eq(1) | ||
end | ||
|
||
it "should record number of invalid sources" do | ||
expect(@summary.states["invalid"]).to eq(1) | ||
end | ||
|
||
it "should record number of not found sources" do | ||
expect(@summary.states["not_found"]).to eq(0) | ||
end | ||
end | ||
|
||
it "should record number of sources with warnings" do | ||
expect(@summary.states["warnings"]).to eq(1) | ||
end | ||
end | ||
|
||
it "should record number of unique sources" do | ||
expect(@summary.sources).to eq(3) | ||
end | ||
|
||
it "should record number of sources per host" do | ||
expect(@summary.hosts.keys.length).to eq(1) | ||
expect(@summary.hosts["example\uff0ecom"]).to eq(3) | ||
end | ||
end | ||
|
||
it "should record occurences of errors" do | ||
expect(@summary.level_summary.errors_breakdown[:ragged_rows]).to eq(1) | ||
expect(@summary.level_summary.warnings_breakdown[:check_options]).to eq(1) | ||
end | ||
|
||
it "should count occurences across population of sources" do | ||
mock_file("http://example.com/test4.csv", 'csvs/multiple_errors.csv') | ||
validation = Validation.create_validation("http://example.com/test4.csv") | ||
@summary = Summary.generate | ||
validation = Validation.create_validation("http://example.com/test4.csv") | ||
@summary = described_class.generate | ||
expect(@summary.sources).to eq(4) | ||
expect(@summary.states["invalid"]).to eq(2) | ||
expect(@summary.level_summary.errors_breakdown[:ragged_rows]).to eq(2) | ||
expect(@summary.level_summary.warnings_breakdown[:check_options]).to eq(1) | ||
end | ||
|
||
it "should record categories of problem" do | ||
mock_file("http://example.com/test4.csv", 'csvs/multiple_errors.csv') | ||
validation = Validation.create_validation("http://example.com/test4.csv") | ||
@summary = Summary.generate | ||
expect(@summary.sources).to eq(4) | ||
@summary = described_class.generate | ||
expect(@summary.sources).to eq(4) | ||
expect(@summary.level_summary.errors_breakdown[:ragged_rows]).to eq(2) | ||
expect(@summary.category_summary.structure_breakdown[:ragged_rows]).to eq(2) | ||
end | ||
|
||
end | ||
end | ||
|
||
end |
Oops, something went wrong.