spec/at_spec.rb in at-0.1.4 vs spec/at_spec.rb in at-0.2.0
- old
+ new
@@ -1,23 +1,29 @@
require 'spec_helper'
+# TODO: Move classes to spec/support
+
class Configuration
attr_reader :configuration
def initialize
@configuration = "default"
end
end
describe Configuration do
+
describe "#configuration" do
+
it "should return the @configuration instance variable" do
subject.configuration.should == "default"
subject.at.configuration = "the result"
subject.configuration.should == "the result"
end
+
end
+
end
#===-----------------------------------------------------------------------===#
class User
@@ -29,10 +35,11 @@
[@first_name, @last_name].compact.join(" ")
end
end
describe User do
+
describe "#initialize" do
subject { User.new("John", "Doe") }
it "should correctly set the instance variables on the User instance" do
subject.at.first_name.should == "John"
@@ -58,10 +65,11 @@
describe "#last_name" do
it "should raise a NoMethodError" do
Proc.new { subject.last_name }.should raise_error(NoMethodError)
end
end
+
end
#===-----------------------------------------------------------------------===#
require 'net/http'
@@ -100,6 +108,71 @@
Net::HTTP.should_receive(:get_print).never
Twitter.search(:q => "test").should == "{'some':'json response'}"
end
end
-end
+end
+
+#===-----------------------------------------------------------------------===#
+
+# This class has it's own `at` method
+class Event
+
+ attr_reader :at
+
+end
+
+describe Event do
+
+ let(:event_at) { DateTime.now }
+
+ before(:all) { subject._at.at = event_at }
+
+ describe "#at" do
+
+ it 'should return the DateTime the Event is happening' do
+ subject.at.should == event_at
+ end
+
+ end
+
+end
+
+
+
+
+
+
+
+
+
+# class Application
+#
+# class Config
+# attr_reader :hostname, :port
+# end
+#
+# attr_reader :config
+#
+# def initialize(&block)
+# @config = Config.new
+#
+# configure(&block) if block_given?
+# end
+#
+# def configure(&block)
+# raise ArgumentError, 'block must be supplied' unless block_given?
+# delegator = At::InstanceVariableDelegator.new(@config)
+#
+# block.call(delegator)
+# end
+#
+# end
+#
+# app = Application.new
+# app.configure do |c|
+# c.hostname = 'example.com'
+# c.port = 8080
+# end
+#
+# p app.config.hostname # => 'example.com'
+# p app.config.port # => 8080
\ No newline at end of file