spec/parsed_file_spec.rb in fukuzatsu-1.0.4 vs spec/parsed_file_spec.rb in fukuzatsu-1.0.5
- old
+ new
@@ -1,10 +1,10 @@
require 'spec_helper'
describe ParsedFile do
- let(:parsed_file) { ParsedFile.new(path_to_file: "bar/foo.rb") }
+ let(:parsed_file) { ParsedFile.new(path_to_file: "./spec/fixtures/eg_class.rb") }
let(:analyzer) { Analyzer.new("class Foo; end") }
describe "#class_name" do
before do
allow(parsed_file).to receive(:analyzer) { analyzer }
@@ -14,21 +14,21 @@
end
end
describe "#content" do
it "reads from file" do
- allow(File).to receive(:open).with("bar/foo.rb", "r") {
+ allow(File).to receive(:open).with("./spec/fixtures/eg_class.rb", "r") {
instance_double("File", read: "whatever")
}
- expect(parsed_file.content).to eq("whatever")
+ expect(parsed_file.send(:content)).to eq("whatever")
end
end
describe "#analyzer" do
it "instantiates an Analyzer instance with content" do
allow(parsed_file).to receive("content") { "stuff" }
- expect(parsed_file.analyzer.class.name).to eq "Analyzer"
+ expect(parsed_file.send(:analyzer).class.name).to eq "Analyzer"
end
end
describe "#complexity" do
before do
@@ -43,22 +43,22 @@
describe "methods" do
before do
allow(parsed_file).to receive(:analyzer) { analyzer }
end
it "retrieves methods from analyzer" do
- allow(analyzer).to receive(:extract_methods) { [:talk, :walk] }
+ allow(analyzer).to receive(:methods) { [:talk, :walk] }
expect(parsed_file.methods).to eq([:talk, :walk])
end
end
describe "summary" do
it "builds a hash" do
- allow(parsed_file).to receive(:path_to_results) { "doc/fukuzatsu/foo.rb.htm" }
- allow(parsed_file).to receive(:path_to_file) { "foo.rb.htm" }
+ allow(parsed_file).to receive(:path_to_results) { "doc/fukuzatsu/spec/fixtures/eg_class.rb" }
+ allow(parsed_file).to receive(:path_to_file) { "eg_class.rb.htm" }
allow(parsed_file).to receive(:class_name) { "Foo" }
allow(parsed_file).to receive(:complexity) { 11 }
- expect(parsed_file.summary[:results_file]).to eq "doc/fukuzatsu/foo.rb.htm"
- expect(parsed_file.summary[:path_to_file]).to eq "foo.rb.htm"
+ expect(parsed_file.summary[:results_file]).to eq "doc/fukuzatsu/spec/fixtures/eg_class.rb"
+ expect(parsed_file.summary[:path_to_file]).to eq "eg_class.rb.htm"
expect(parsed_file.summary[:class_name]).to eq "Foo"
expect(parsed_file.summary[:complexity]).to eq 11
end
end