This file contains hidden or 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
class Renderer | |
def render(text_object) | |
text = text_object.text | |
colour = text_object.colour | |
size = text_object.size_inches | |
# render the text here | |
end | |
end |
This file contains hidden or 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
class TextObject | |
attr_accessor :text, :colour, :size_inches | |
def initialize(text,colour,size_inches) | |
@text = text | |
@colour = colour | |
@size_inches = size_inches | |
end | |
end |
This file contains hidden or 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
class DifferentTextObject | |
attr_accessor :string, :color, :size_mm | |
def initialize(string,color,size_mm) | |
@string= string | |
@color = color | |
@size_mm = size_mm | |
end | |
end |
This file contains hidden or 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
class TextObjectAdapter | |
def initialize(different_text_object) | |
@different_text_obj = different_text_object | |
end | |
def text | |
@different_text_obj.string | |
end |
This file contains hidden or 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
diff_text_obj = DifferentTextObject.new(‘test’,’red’,10) | |
class << diff_text_obj | |
def text | |
@diff_text_obj.string | |
end | |
def colour | |
@diff_text_obj.color | |
end |
This file contains hidden or 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
before :each do | |
@url = 'http://sns.us-east-1.amazonaws.com:80/?Action=ListTopics&Signature=ItTAjeexIPC43pHMZLCL7utnpK8j8AbTUZ3KGUSMzNc%3D&AWSAccessKeyId=123456&Timestamp=123&SignatureVersion=2&SignatureMethod=HmacSHA256' | |
EventMachine::MockHttpRequest.reset_registry! | |
EventMachine::MockHttpRequest.reset_counts! | |
EventMachine::MockHttpRequest.pass_through_requests = false #set to false to not hit the actual API endpoint | |
end | |
it 'should be able to access the API endpoint' do |
This file contains hidden or 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
describe 'making requests to SNS API' do | |
before :each do | |
AmazeSNS.akey = '123456' | |
AmazeSNS.skey = '123456' | |
@time_stub = stub("Time") | |
WebMock.reset! | |
WebMock.disable_net_connect! | |
This file contains hidden or 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
@httpresponse ||= http_class.new("http://#{AmazeSNS.host}/?").get({ | |
:query => querystring2, :timeout => 2 | |
}) | |
@httpresponse.callback{ | |
begin | |
success_callback | |
deferrable.succeed | |
rescue => e | |
deferrable.fail(e) | |
end |
This file contains hidden or 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
# method for clearing out instance variables from code blocks | |
# usage: | |
Spec::Runner.configure do |config| | |
..... | |
config.after(:each) do | |
scrub_instance_variables | |
end | |
end |
This file contains hidden or 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
# delay the GC - usage as below | |
# Spec::Runner.configure do |config| | |
..... | |
# config.before(:each) do | |
# begin_gc_deferment | |
# end | |
# config.after(:each) do |