Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
39 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ def html_id | |
"#{@prefix}_#{name}" | ||
end | ||
|
||
def string_value | ||
def to_s | ||
@value.to_s | ||
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
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,15 @@ | ||
module Semiformal | ||
class TextValue | ||
def initialize(value) | ||
@value = value | ||
end | ||
|
||
def to_s | ||
@value.to_s | ||
end | ||
|
||
def ==(other) | ||
to_s == other.to_s | ||
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
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,17 @@ | ||
require 'spec_helper' | ||
require 'semiformal/text_value' | ||
|
||
describe Semiformal::TextValue do | ||
it "converts #to_s" do | ||
value = Semiformal::TextValue.new(:value) | ||
value.to_s.should == "value" | ||
end | ||
|
||
it "is #== with the same value" do | ||
Semiformal::TextValue.new("test").should == Semiformal::TextValue.new("test") | ||
end | ||
|
||
it "isn't #== with a different value" do | ||
Semiformal::TextValue.new("test").should_not == Semiformal::TextValue.new("other") | ||
end | ||
end |