-
Notifications
You must be signed in to change notification settings - Fork 96
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
Changes from all commits
d0e4483
0302b09
abbe9e7
0c8d535
00713d2
3e5881c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,13 @@ def self.tasks_load(tasks_relative_path) | |
end | ||
|
||
LOADER.setup | ||
|
||
def self.reset | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,10 @@ | |
# for some platforms. | ||
@metric_with_graph = MetricFu.configuration.mri? ? :cane : :flay | ||
@metric_without_graph = :hotspots | ||
MetricFu.configuration.configure_metrics.each do |metric| | ||
metric.enabled = true if [@metric_with_graph, @metric_without_graph].include?(metric.name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wow, why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why what? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But it's sorta hard to read Couldn't you def enable_metric_with_graph
MetricFu.get_metric(:cane).enabled = true
end
def enable_metric_without_graph
MetricFu.get_metric(:hotspots).enabled = true
end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, hrm, yeah, could do that. That's better. As for 1 (mri ? cane : flay) - I think I address it somewhat in a comment that isn't quite visible in this diff, but basically, if we configure all the metrics, the specs are SUPER slow. So, I just wanted to test that it works for at least 1 metric with a graph and 1 without. Cane is by far the fastest to run, but it - at least when I implemented that code? - didn't work on all platforms, so then pick the next best option which was flay. Yeah, totally not optimal and confusing. I would much prefer some sort of mock metric. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I never knew why you'd prefer cane over flay, here. (I understood the part about not running all the metrics 🌈 ) |
||
end | ||
|
||
MetricFu.result.add(@metric_with_graph) # metric w/ graph | ||
MetricFu.result.add(@metric_without_graph) # metric w/out graph | ||
end | ||
|
@@ -67,7 +71,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 | ||
|
@@ -117,7 +122,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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we don't support ruby 1.8, there's no need to use multi_json. All 1.9 and higher have a json library. I'm okay having a metric_fu json dumper just for encapsulation purposes, but then just calls JSON.dump
(Also see intridea/multi_json#113 )
We can either require it in the Loader, or in the individual files that need it. (I prefer the latter, perhaps on activation)