Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into new-views
- Loading branch information
Showing
14 changed files
with
176 additions
and
46 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Module.module_eval do | ||
|
||
def self.clear_nsurls | ||
@@nsurls = {} | ||
end | ||
def self.find_by_nsurl(url) | ||
@@nsurls[url] | ||
end | ||
|
||
def nsurl(url = nil) | ||
return @nsurl unless url | ||
@@nsurls ||= {} | ||
mod = @@nsurls[url] | ||
raise ArgumentError, "nsurl #{url.inspect} is already referenced by #{mod.inspect} module" if mod && mod != self | ||
@@nsurls.delete(url) | ||
@@nsurls[url] = self | ||
@nsurl = url | ||
end | ||
|
||
end | ||
|
||
Module.nsurl '' | ||
StrokeDB.nsurl StrokeDB::STROKEDB_NSURL |
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
require File.dirname(__FILE__) + '/spec_helper' | ||
|
||
describe "Some", Module do | ||
|
||
before(:each) do | ||
@module = Module.new | ||
Module.clear_nsurls | ||
end | ||
|
||
it "should have nil nsurl by default" do | ||
@module.nsurl.should be_nil | ||
end | ||
|
||
it "should be able to change nsurl" do | ||
@module.nsurl 'http://some.url' | ||
@module.nsurl.should == 'http://some.url' | ||
end | ||
|
||
it "should be findable by nsurl" do | ||
@module.nsurl 'http://some.url' | ||
Module.find_by_nsurl(@module.nsurl).should == @module | ||
end | ||
|
||
it "should be able to change nsurl to the same value" do | ||
@module.nsurl 'http://some.url' | ||
lambda { @module.nsurl 'http://some.url' }.should_not raise_error(ArgumentError) | ||
end | ||
|
||
it "should not be able to change nsurl to the value already assigned to some module" do | ||
@some_module = Module.new | ||
@some_module.nsurl 'http://some.url' | ||
lambda { @module.nsurl 'http://some.url' }.should raise_error(ArgumentError) | ||
end | ||
|
||
end | ||
|
||
describe Module do | ||
|
||
|
||
before(:each) do | ||
Module.clear_nsurls | ||
end | ||
|
||
it "should have empty nsurl by default" do | ||
Module.nsurl.should be_empty | ||
end | ||
|
||
end | ||
|
||
describe StrokeDB do | ||
|
||
before(:each) do | ||
Module.clear_nsurls | ||
end | ||
|
||
it "should have #{STROKEDB_NSURL} nsurl by default" do | ||
StrokeDB.nsurl.should == STROKEDB_NSURL | ||
end | ||
|
||
end |