Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Country Fixture
require 'spec_helper'
describe AnotherModel do
it "should process a fixture" do
expected = ["Zimbabwe", "Tibet", "Equador"]
index = 0
country_fixture.each_line do |line|
line.should match expected[index]
index += 1
end
end
def method_missing(method, *args, &block)
if /^(?<filename>\w+?)_fixture$/ =~ method
# call the other method missing filter
path = self.send("#{method}_path".to_sym)
File.open(path).read
elsif /^(?<filename>\w+?)_fixture_path$/ =~ method
"spec/fixtures/#{filename}"
else
super
end
end
end
Zimbabwe is in Africa
Tibet is in Asia
Equador is in Latin America
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment