Skip to content

Instantly share code, notes, and snippets.

@daveworth
Created December 13, 2011 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daveworth/1472796 to your computer and use it in GitHub Desktop.
Save daveworth/1472796 to your computer and use it in GitHub Desktop.
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