Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests failing when config.order set to random #115

Merged
merged 6 commits into from
Aug 10, 2013
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/metric_fu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,13 @@ def self.tasks_load(tasks_relative_path)
end

LOADER.setup

def self.reset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a testing concern, only, I'd rather monkey-patch the module in spec/support/metric_monkey.rb or something

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, went back and forth on that myself.

# TODO Don't like how this method needs to know
# all of these class variables that are defined
# in separate classes.
@configuration = nil
@graph = nil
@result = nil
end
end
12 changes: 10 additions & 2 deletions spec/metric_fu/formatter/html_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
# for some platforms.
@metric_with_graph = MetricFu.configuration.mri? ? :cane : :flay
@metric_without_graph = :hotspots
MetricFu::Configuration.run do |config|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you prefer MetricFu::Configuration.run {} over MetricFu.configuration.configure_metrics {}?

config.configure_metrics.each do |metric|
metric.enabled = true if [@metric_with_graph, @metric_without_graph].include?(metric.name)
end
end

MetricFu.result.add(@metric_with_graph) # metric w/ graph
MetricFu.result.add(@metric_without_graph) # metric w/out graph
end
Expand Down Expand Up @@ -67,7 +73,8 @@ def directory(name)

context 'when on OS X' do
before do
MetricFu.configuration.stub(:platform).and_return('darwin')
MetricFu.configuration.stub(:osx?).and_return(true)
MetricFu.configuration.stub(:is_cruise_control_rb?).and_return(false)
end

it "can open the results in the browser" do
Expand Down Expand Up @@ -117,7 +124,8 @@ def directory(name)

context 'when on OS X' do
before do
MetricFu.configuration.stub(:platform).and_return('darwin')
MetricFu.configuration.stub(:osx?).and_return(true)
MetricFu.configuration.stub(:is_cruise_control_rb?).and_return(false)
end

it "can open the results in the browser from the custom output directory" do
Expand Down
8 changes: 4 additions & 4 deletions spec/run_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,7 @@ def data_directory
MetricFu::Configuration.run do |config|
config.formatters.clear
end

cleanup_fs
end


end

context "given other options" do
Expand All @@ -187,6 +183,10 @@ def data_directory

end

after do
cleanup_fs
end

def metric_fu(options = "--no-open")
MfDebugger::Logger.capture_output {
begin
Expand Down
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ def mf_log(msg); mf_debug(msg); end
config.after(:suite) do
cleanup_test_files
end

config.after(:each) do
MetricFu.reset
end
end