From d2c34d17b7bd9be585b3e313ca129554009867d7 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Thu, 22 May 2014 11:06:19 -0400 Subject: [PATCH] Fix failing spec. Stubbing intermittently does not stub... --- app/models/color_scheme.rb | 6 +++++- spec/models/color_scheme_spec.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/color_scheme.rb b/app/models/color_scheme.rb index 5a5813e9c78..cf659b2ecf9 100644 --- a/app/models/color_scheme.rb +++ b/app/models/color_scheme.rb @@ -20,7 +20,7 @@ class ColorScheme < ActiveRecord::Base @mutex.synchronize do return @base_colors if @base_colors @base_colors = {} - File.readlines(BASE_COLORS_FILE).each do |line| + read_colors_file.each do |line| matches = /\$([\w]+):\s*#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})(?:[;]|\s)/.match(line.strip) @base_colors[matches[1]] = matches[2] if matches end @@ -28,6 +28,10 @@ class ColorScheme < ActiveRecord::Base @base_colors end + def self.read_colors_file + File.readlines(BASE_COLORS_FILE) + end + def self.enabled current_version.find_by(enabled: true) end diff --git a/spec/models/color_scheme_spec.rb b/spec/models/color_scheme_spec.rb index a1e32f450b5..90c409da668 100644 --- a/spec/models/color_scheme_spec.rb +++ b/spec/models/color_scheme_spec.rb @@ -4,7 +4,7 @@ describe ColorScheme do describe '#base_colors' do it 'parses the colors.scss file and returns a hash' do - File.stubs(:readlines).with(described_class::BASE_COLORS_FILE).returns([ + described_class.stubs(:read_colors_file).returns([ '$primary: #333333 !default;', '$secondary: #ffffff !default; ', '$highlight: #ffff4d;',