Created
December 13, 2011 16:31
-
-
Save daveworth/1472796 to your computer and use it in GitHub Desktop.
Country Fixture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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