sham_rack 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,27 @@
1
+ ## 08-Jul-2010 [jyurek@thoughtbot.com]
2
+
3
+ * Add support for Mechanize.
4
+
5
+ ## 11-Mar-2010 [mdub@dogbiscuit.org]
6
+
7
+ * Added generic `StubWebService`.
8
+
1
9
  ## 15-Jan-2010 [jeremy.burks@gmail.com]
2
10
 
3
11
  * Fix an incompatibility with rest-client 1.2.0.
4
12
 
5
13
  ## 27-Nov-2009 [mdub@dogbiscuit.org]
6
14
 
7
- * Change of approach: extend rather than reimplement Net:HTTP. This should improve coverage of all the weird and wonderful ways of using the Net:HTTP API.
15
+ * Change of approach: extend rather than reimplement `Net:HTTP`. This should improve coverage of all the weird and wonderful ways of using the `Net:HTTP` API.
8
16
 
9
17
  ## 5-Jun-2009 [mdub@dogbiscuit.org]
10
18
 
11
- * Add support for Net::HTTP.get_response.
12
- * Pass back headers provided by Rack app in the HTTPResponse.
19
+ * Add support for `Net::HTTP.get_response`.
20
+ * Pass back headers provided by Rack app in the `HTTPResponse`.
13
21
 
14
22
  ## 3-Jun-2009 [mdub@dogbiscuit.org]
15
23
 
16
- * Introduced ShamRack#at to simplify registration of apps.
24
+ * Introduced `ShamRack#at` to simplify registration of apps.
17
25
 
18
26
  ## 13-May-2009 [mdub@dogbiscuit.org]
19
27
 
@@ -60,14 +60,13 @@ Using it
60
60
  ### General-purpose stubbing
61
61
 
62
62
  @stub_app = ShamRack.at("stubbed.com").stub
63
-
64
- open("http://stubbed.com/greeting").read #=> OpenURI::HTTPError: 404
65
-
66
63
  @stub_app.register_resource("/greeting", "Hello, world!", "text/plain")
67
-
64
+
68
65
  open("http://stubbed.com/greeting").read #=> "Hello, world!"
69
66
  @stub_app.last_request.path #=> "/greeting"
70
67
 
68
+ Or, just use Sinatra, as described above ... it's almost as succinct, and heaps more powerful.
69
+
71
70
  What's the catch?
72
71
  -----------------
73
72
 
data/Rakefile CHANGED
@@ -1,8 +1,6 @@
1
1
  require "rubygems"
2
2
  require "rake"
3
3
 
4
- require File.dirname(__FILE__) + "/lib/sham_rack/version.rb"
5
-
6
4
  require "spec/rake/spectask"
7
5
 
8
6
  task "default" => "spec"
@@ -11,41 +9,3 @@ Spec::Rake::SpecTask.new do |t|
11
9
  t.spec_opts = ["--colour", "--format", "progress"]
12
10
  t.spec_files = FileList['spec/**/*_spec.rb']
13
11
  end
14
-
15
- require 'rake/rdoctask'
16
-
17
- Rake::RDocTask.new do |rdoc|
18
- rdoc.rdoc_dir = 'rdoc'
19
- rdoc.title = "ShamRack #{ShamRack::VERSION}"
20
- rdoc.main = "ShamRack"
21
- rdoc.rdoc_files.include('lib/**/*.rb')
22
- end
23
-
24
- def after_requiring(lib, options = {})
25
- begin
26
- require(lib)
27
- rescue LoadError
28
- gem_name = options[:gem] || lib
29
- $stderr.puts "WARNING: can't load #{lib}. Install it with: sudo gem install #{gem_name}"
30
- return false
31
- end
32
- yield
33
- end
34
-
35
- after_requiring "jeweler" do
36
-
37
- Jeweler::Tasks.new do |g|
38
- g.name = "sham_rack"
39
- g.version = ShamRack::VERSION
40
- g.summary = "Net::HTTP-to-Rack plumbing"
41
- g.email = "mdub@dogbiscuit.org"
42
- g.homepage = "http://github.com/mdub/sham_rack"
43
- g.description = "ShamRack plumbs Net::HTTP directly into Rack, for quick and easy HTTP testing."
44
- g.authors = ["Mike Williams"]
45
- g.rubyforge_project = "shamrack"
46
- end
47
-
48
- Jeweler::GemcutterTasks.new
49
- # Jeweler::RubyforgeTasks.new
50
-
51
- end
@@ -7,7 +7,11 @@ module ShamRack
7
7
  attr_accessor :rack_app
8
8
 
9
9
  def start
10
- yield self
10
+ if block_given?
11
+ yield self
12
+ else
13
+ self
14
+ end
11
15
  end
12
16
 
13
17
  def request(req, body = nil)
@@ -1,3 +1,3 @@
1
1
  module ShamRack
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.1".freeze
3
3
  end
@@ -3,6 +3,7 @@ require "spec_helper"
3
3
  require "sham_rack"
4
4
  require "open-uri"
5
5
  require "restclient"
6
+ require "mechanize"
6
7
  require "rack"
7
8
 
8
9
  class PlainTextApp
@@ -92,6 +93,11 @@ describe ShamRack do
92
93
  response.to_s.should == "Hello, world"
93
94
  end
94
95
 
96
+ it "can be accessed using WWW::Mechanize" do
97
+ response = Mechanize.new.get("http://www.test.xyz")
98
+ response.body.should == "Hello, world"
99
+ end
100
+
95
101
  end
96
102
 
97
103
  describe "response" do
@@ -1,7 +1,6 @@
1
1
  require "rubygems"
2
2
  require "spec"
3
3
  require "rr"
4
- require "ruby-debug"
5
4
 
6
5
  project_root = File.expand_path("#{__FILE__}/../..")
7
6
  $LOAD_PATH << "#{project_root}/lib"
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sham_rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 3
8
+ - 1
9
+ version: 1.3.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - Mike Williams
@@ -9,7 +14,7 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-11 00:00:00 +11:00
17
+ date: 2010-07-12 00:00:00 +10:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
@@ -19,50 +24,44 @@ executables: []
19
24
 
20
25
  extensions: []
21
26
 
22
- extra_rdoc_files:
23
- - README.markdown
27
+ extra_rdoc_files: []
28
+
24
29
  files:
25
- - .gitignore
26
- - CHANGES.markdown
27
- - README.markdown
28
- - Rakefile
29
- - benchmark/benchmark.rb
30
- - benchmark/hello_app.rb
31
- - lib/sham_rack.rb
32
30
  - lib/sham_rack/core_ext/net/http.rb
33
31
  - lib/sham_rack/http.rb
34
32
  - lib/sham_rack/registry.rb
35
33
  - lib/sham_rack/stub_web_service.rb
36
34
  - lib/sham_rack/version.rb
37
- - sham_rack.gemspec
38
- - spec/sham_rack/stub_web_service_spec.rb
39
- - spec/sham_rack_spec.rb
40
- - spec/spec_helper.rb
35
+ - lib/sham_rack.rb
36
+ - README.markdown
37
+ - CHANGES.markdown
41
38
  has_rdoc: true
42
39
  homepage: http://github.com/mdub/sham_rack
43
40
  licenses: []
44
41
 
45
42
  post_install_message:
46
- rdoc_options:
47
- - --charset=UTF-8
43
+ rdoc_options: []
44
+
48
45
  require_paths:
49
46
  - lib
50
47
  required_ruby_version: !ruby/object:Gem::Requirement
51
48
  requirements:
52
49
  - - ">="
53
50
  - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
54
53
  version: "0"
55
- version:
56
54
  required_rubygems_version: !ruby/object:Gem::Requirement
57
55
  requirements:
58
56
  - - ">="
59
57
  - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
60
60
  version: "0"
61
- version:
62
61
  requirements: []
63
62
 
64
63
  rubyforge_project: shamrack
65
- rubygems_version: 1.3.5
64
+ rubygems_version: 1.3.6
66
65
  signing_key:
67
66
  specification_version: 3
68
67
  summary: Net::HTTP-to-Rack plumbing
@@ -70,3 +69,6 @@ test_files:
70
69
  - spec/sham_rack/stub_web_service_spec.rb
71
70
  - spec/sham_rack_spec.rb
72
71
  - spec/spec_helper.rb
72
+ - Rakefile
73
+ - benchmark/benchmark.rb
74
+ - benchmark/hello_app.rb
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- pkg
2
- rdoc
@@ -1,58 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{sham_rack}
8
- s.version = "1.3.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Mike Williams"]
12
- s.date = %q{2010-03-11}
13
- s.description = %q{ShamRack plumbs Net::HTTP directly into Rack, for quick and easy HTTP testing.}
14
- s.email = %q{mdub@dogbiscuit.org}
15
- s.extra_rdoc_files = [
16
- "README.markdown"
17
- ]
18
- s.files = [
19
- ".gitignore",
20
- "CHANGES.markdown",
21
- "README.markdown",
22
- "Rakefile",
23
- "benchmark/benchmark.rb",
24
- "benchmark/hello_app.rb",
25
- "lib/sham_rack.rb",
26
- "lib/sham_rack/core_ext/net/http.rb",
27
- "lib/sham_rack/http.rb",
28
- "lib/sham_rack/registry.rb",
29
- "lib/sham_rack/stub_web_service.rb",
30
- "lib/sham_rack/version.rb",
31
- "sham_rack.gemspec",
32
- "spec/sham_rack/stub_web_service_spec.rb",
33
- "spec/sham_rack_spec.rb",
34
- "spec/spec_helper.rb"
35
- ]
36
- s.homepage = %q{http://github.com/mdub/sham_rack}
37
- s.rdoc_options = ["--charset=UTF-8"]
38
- s.require_paths = ["lib"]
39
- s.rubyforge_project = %q{shamrack}
40
- s.rubygems_version = %q{1.3.5}
41
- s.summary = %q{Net::HTTP-to-Rack plumbing}
42
- s.test_files = [
43
- "spec/sham_rack/stub_web_service_spec.rb",
44
- "spec/sham_rack_spec.rb",
45
- "spec/spec_helper.rb"
46
- ]
47
-
48
- if s.respond_to? :specification_version then
49
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
- s.specification_version = 3
51
-
52
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
53
- else
54
- end
55
- else
56
- end
57
- end
58
-