class FeatureStorageService
FEATURES = YAML.load_file(Rails.root.join("config/features.yml"))
end
The test
describe FeatureStorageService do
let!(:yaml) { YAML.load_file(Rails.root.join("spec/factories/files/features.yml")) }
before do
allow(YAML).to receive(:load_file).and_call_original
allow(YAML).to receive(:load_file).with(Rails.root.join("config/features.yml")).and_return(yaml)
end
end
The spec doesn't load the file at "spec/factories/files/features.yml" instead loads the original one.
I have cross checked the syntax so many times.
Also, the stubbing works fine for my controller spec which is accessing the same service(class shown here) with the same syntax.
Here's a snippet
The class where I'm loading YAML file
The test
The spec doesn't load the file at "spec/factories/files/features.yml" instead loads the original one. I have cross checked the syntax so many times.
Also, the stubbing works fine for my controller spec which is accessing the same service(class shown here) with the same syntax.
Dependencies: gem 'rspec-rails', '~> 3.4.2' gem 'rails', '4.2.7'