Module: Pione::TestHelper::Location

Defined in:
lib/pione/test-helper/location-helper.rb

Class Method Summary collapse

Class Method Details

.test_scheme(path) ⇒ Object

Test location scheme.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pione/test-helper/location-helper.rb', line 5

def self.test_scheme(path)
  dir = File.dirname(path)
  name = File.basename(path, ".rb").sub("spec_", "")
  yml_path = File.join(dir, 'data', '%s.yml' % name)

  describe "location scheme test" do
    YAML.load_file(yml_path).each do |testcase|
      if uri = testcase.keys.first
        testcase[uri].keys.each do |name|
          # expectation
          expectation = testcase[uri][name]
          expectation = nil if expectation == "nil"

          # test
          URI.parse(uri).__send__(name).should == expectation
        end
      end
    end
  end
end