Permalink
Browse files

Merge branch 'master' of github.com:mattetti/BubbleWrap

Conflicts:
	spec/http_spec.rb
  • Loading branch information...
2 parents 3578edc + 85bacf3 commit c8c1a5779435105c880b7568f2f972a25b0ff4f5 @supermarin supermarin committed Jun 5, 2012
Showing with 42 additions and 14 deletions.
  1. +5 −0 CHANGELOG.md
  2. +2 −2 lib/bubble-wrap/app.rb
  3. +1 −1 lib/bubble-wrap/http.rb
  4. +1 −1 lib/bubble-wrap/version.rb
  5. +15 −0 spec/app_spec.rb
  6. +18 −10 spec/http_spec.rb
View
@@ -1,3 +1,8 @@
+## 0.3.1
+
+* Added App.run_after(delay){ }
+* HTTP responses return true to ok? when the status code is 20x.
+
## 0.3.0
* Major refactoring preparing for 1.0: [List of commits](https://github.com/mattetti/BubbleWrap/compare/v0.2.1...v0.3.0)
@@ -39,11 +39,11 @@ def alert(msg,cancelButtonTitle='OK')
# Executes a block after a certain delay
# Usage example:
# App.run_after(0.5) { p "It's #{Time.now}" }
- def run_after(delay, user_info=nil, &block)
+ def run_after(delay,&block)
NSTimer.scheduledTimerWithTimeInterval( delay,
target: block,
selector: "call:",
- userInfo: user_info,
+ userInfo: nil,
repeats: false)
end
@@ -73,7 +73,7 @@ def update(values)
end
def ok?
- status_code == 200
+ status_code.to_s =~ /20\d/ ? true : false
end
end
@@ -1,3 +1,3 @@
module BubbleWrap
- VERSION = '0.3.0'
+ VERSION = '0.3.1'
end
View
@@ -80,4 +80,19 @@
BW::App.delegate.class.should == TestSuiteDelegate
end
end
+
+ describe '.run_after' do
+ class DelayedRunAfterTest; attr_accessor :test_value end
+
+ it 'should run a block after the provided delay' do
+ @test_obj = DelayedRunAfterTest.new
+
+ App.run_after(0.1){ @test_obj.test_value = true }
+ wait_for_change(@test_obj, 'test_value') do
+ @test_obj.test_value.should == true
+ end
+ end
+
+ end
+
end
View
@@ -1,6 +1,5 @@
describe "HTTP" do
-end
describe "HTTP::Response" do
@@ -13,10 +12,17 @@
@response.instance_variable_get(:@url).should == 'http://localhost'
end
- it "says OK only for status code 200" do
+
+ it "says OK status code 20x" do
@response.ok?.should.equal true
- BubbleWrap::HTTP::Response.new({status_code: 205}).ok?.should.not.equal true
+ (200..206).each do |code|
+ BubbleWrap::HTTP::Response.new({status_code: code}).ok?.should.be.true
+ end
+ [100..101, 300..307, 400..417, 500..505].inject([]){|codes, rg| codes += rg.to_a}.each do |code|
+ BubbleWrap::HTTP::Response.new({status_code: code}).ok?.should.be.false
+ end
end
+
it "has appropriate attributes" do
@response.should.respond_to :body
@@ -44,11 +50,11 @@
@leftover_option = 'trololo'
@headers = { 'User-Agent' => "Mozilla/5.0 (X11; Linux x86_64; rv:12.0) \n Gecko/20100101 Firefox/12.0" }
@options = { action: @action,
- payload: @payload,
- credentials: @credentials,
- headers: @headers,
- cache_policy: @cache_policy,
- leftover_option: @leftover_option
+ payload: @payload,
+ credentials: @credentials,
+ headers: @headers,
+ cache_policy: @cache_policy,
+ leftover_option: @leftover_option
}
@query = BubbleWrap::HTTP::Query.new( 'http://localhost' , :get, @options )
end
@@ -150,7 +156,7 @@
end
describe "initiate request" do
-
+
before do
@url_string = 'http://initiated-request.dev'
@@ -171,7 +177,7 @@
end
describe "Generating GET params" do
-
+
it "should create params with nested hashes with prefix[key]=value" do
expected_params = [
'user[name]=marin',
@@ -374,4 +380,6 @@ def initialize(status_code, headers, length)
end
end
+end
+
end

0 comments on commit c8c1a57

Please sign in to comment.