riot-gear 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,14 +2,16 @@
2
2
 
3
3
  Real HTTP-based smoke testing with a real testing framework; [Riot](http://thumblemonks.github.com/riot) + [HTTParty]().
4
4
 
5
- require 'testsrap'
5
+ require 'teststrap'
6
6
 
7
7
  context "Logging into Example.com as foo" do
8
8
  base_uri "http://example.com"
9
- post "/session/new", :body => {:username => "foo", :password => "password"}
9
+ get "/session/new?username=foo&password=password"
10
10
 
11
11
  asserts_status.equals(200)
12
12
  asserts_header("Content-Type").equals("application/json;charset=utf-8")
13
- end # Logging into BrightTag as bgrande
13
+
14
+ # ... more stuff
15
+ end
14
16
 
15
17
  Lots lots more to come soon.
data/Rakefile CHANGED
@@ -1,5 +1,30 @@
1
1
  require 'rubygems'
2
+
2
3
  require 'rake'
4
+ require 'rake/testtask'
5
+
6
+ #
7
+ # Other rake tasks
8
+
9
+ Dir[File.dirname(__FILE__) + "/lib/tasks/*.rake"].each { |rake_task| load rake_task }
10
+
11
+ #
12
+ # Console!
13
+
14
+ task(:console) { exec "irb -r boot" }
15
+
16
+ #
17
+ # Testing
18
+
19
+ Rake::TestTask.new("test") do |t|
20
+ t.libs << "test"
21
+ t.pattern = "test/**/*_test.rb"
22
+ t.verbose = false
23
+ end
24
+ Rake::Task["test"].instance_variable_set(:@full_comment, nil) # Dumb dumb dumb
25
+ Rake::Task["test"].comment = "Run the tests!"
26
+
27
+ task :default => :test
3
28
 
4
29
  #
5
30
  # Some monks like diamonds. I like gems.
@@ -15,6 +40,7 @@ begin
15
40
  gem.authors = ["Justin 'Gus' Knowlden"]
16
41
  gem.add_dependency 'riot'
17
42
  gem.add_dependency 'httparty'
43
+ gem.add_development_dependency 'webmock'
18
44
  end
19
45
  Jeweler::GemcutterTasks.new
20
46
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -1,15 +1,15 @@
1
1
  require 'open-uri'
2
2
 
3
- module SmokeMonster
4
- module Riot
3
+ module Riot
4
+ module Gear
5
5
  module AssertsHeader
6
6
 
7
7
  def asserts_header(header_key)
8
8
  asserts("header variable #{header_key}") { response.headers[header_key] }
9
9
  end
10
10
 
11
- end # Context
12
- end # Riot
13
- end # SmokeMonster
11
+ end # AssertsHeader
12
+ end # Gear
13
+ end # Riot
14
14
 
15
- Riot::Context.instance_eval { include SmokeMonster::Riot::AssertsHeader }
15
+ Riot::Context.instance_eval { include Riot::Gear::AssertsHeader }
@@ -1,7 +1,7 @@
1
1
  require 'open-uri'
2
2
 
3
- module SmokeMonster
4
- module Riot
3
+ module Riot
4
+ module Gear
5
5
  module AssertsJson
6
6
 
7
7
  def asserts_json(json_path)
@@ -9,8 +9,8 @@ module SmokeMonster
9
9
  json_path(response, json_path)
10
10
  end
11
11
  end
12
- end # Context
13
- end # Riot
14
- end # SmokeMonster
12
+ end # AssertsJson
13
+ end # Gear
14
+ end # Riot
15
15
 
16
- Riot::Context.instance_eval { include SmokeMonster::Riot::AssertsJson }
16
+ Riot::Context.instance_eval { include Riot::Gear::AssertsJson }
@@ -1,15 +1,15 @@
1
1
  require 'open-uri'
2
2
 
3
- module SmokeMonster
4
- module Riot
3
+ module Riot
4
+ module Gear
5
5
  module AssertsStatus
6
6
 
7
7
  def asserts_status
8
8
  asserts("status code") { response.code }
9
9
  end
10
10
 
11
- end # Context
12
- end # Riot
13
- end # SmokeMonster
11
+ end # AssertsStatus
12
+ end # Gear
13
+ end # Riot
14
14
 
15
- Riot::Context.instance_eval { include SmokeMonster::Riot::AssertsStatus }
15
+ Riot::Context.instance_eval { include Riot::Gear::AssertsStatus }
@@ -1,8 +1,8 @@
1
1
  require 'open-uri'
2
2
  require 'httparty'
3
3
 
4
- module SmokeMonster
5
- module Riot
4
+ module Riot
5
+ module Gear
6
6
  module Http
7
7
 
8
8
  # Setup the scenario via a GET requst to the provided path. Feel free to include a query string
@@ -15,8 +15,8 @@ module SmokeMonster
15
15
  topic.cookies({cookie_name => cookie_values[cookie_name]})
16
16
  end
17
17
  end
18
- end # Context
19
- end # Riot
20
- end # SmokeMonster
18
+ end # Http
19
+ end # Gear
20
+ end # Riot
21
21
 
22
- Riot::Context.instance_eval { include SmokeMonster::Riot::Http }
22
+ Riot::Context.instance_eval { include Riot::Gear::Http }
@@ -65,8 +65,9 @@ module Riot
65
65
  # => "bar"
66
66
  def helper_json_path(context)
67
67
  context.helper(:json_path) do |dictionary, path|
68
- path.scan(/\w+|\d+/).inject(dictionary) do |dict,key|
69
- dict[key =~ /^\d+$/ ? key.to_i : key]
68
+ return nil if path.to_s.empty?
69
+ path.scan(/[^\[\].'"]+/).inject(dictionary) do |dict,key|
70
+ dict[key =~ /^\d+$/ ? key.to_i : key.strip]
70
71
  end
71
72
  end
72
73
  end
data/riot-gear.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{riot-gear}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin 'Gus' Knowlden"]
12
- s.date = %q{2010-06-23}
12
+ s.date = %q{2010-06-24}
13
13
  s.description = %q{Riot + HTTParty smoke testing framework. You'd use it for integration testing with real HTTP requests and responses}
14
14
  s.email = %q{gus@gusg.us}
15
15
  s.extra_rdoc_files = [
@@ -28,13 +28,19 @@ Gem::Specification.new do |s|
28
28
  "lib/riot/gear/context/http.rb",
29
29
  "lib/riot/gear/middleware.rb",
30
30
  "lib/riot/gear/middleware/riotparty.rb",
31
- "riot-gear.gemspec"
31
+ "riot-gear.gemspec",
32
+ "test/helpers/json_path_test.rb",
33
+ "test/teststrap.rb"
32
34
  ]
33
35
  s.homepage = %q{http://github.com/thumblemonks/riot-gear}
34
36
  s.rdoc_options = ["--charset=UTF-8"]
35
37
  s.require_paths = ["lib"]
36
38
  s.rubygems_version = %q{1.3.6}
37
39
  s.summary = %q{Riot + HTTParty smoke testing framework}
40
+ s.test_files = [
41
+ "test/helpers/json_path_test.rb",
42
+ "test/teststrap.rb"
43
+ ]
38
44
 
39
45
  if s.respond_to? :specification_version then
40
46
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
@@ -43,13 +49,16 @@ Gem::Specification.new do |s|
43
49
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
44
50
  s.add_runtime_dependency(%q<riot>, [">= 0"])
45
51
  s.add_runtime_dependency(%q<httparty>, [">= 0"])
52
+ s.add_development_dependency(%q<webmock>, [">= 0"])
46
53
  else
47
54
  s.add_dependency(%q<riot>, [">= 0"])
48
55
  s.add_dependency(%q<httparty>, [">= 0"])
56
+ s.add_dependency(%q<webmock>, [">= 0"])
49
57
  end
50
58
  else
51
59
  s.add_dependency(%q<riot>, [">= 0"])
52
60
  s.add_dependency(%q<httparty>, [">= 0"])
61
+ s.add_dependency(%q<webmock>, [">= 0"])
53
62
  end
54
63
  end
55
64
 
@@ -0,0 +1,59 @@
1
+ require 'teststrap'
2
+
3
+ context "The json_path helper" do
4
+ asserts("providing a nil path") { json_path({"a" => "foo"}, nil) }.nil
5
+ asserts("providing a blank path") { json_path({"a" => "foo"}, "") }.nil
6
+ asserts("providing a non-existent path") { json_path({"a" => "foo"}, "b") }.nil
7
+
8
+ asserts("path of existing 'a'") { json_path({"a" => "foo"}, "a") }.equals("foo")
9
+ asserts("path of non-existent 'a.b'") { json_path({"a" => "foo"}, "a.b") }.nil
10
+
11
+ asserts("path of existing 'a.b'") { json_path({"a" => {"b" => "bar"}}, "a.b") }.equals("bar")
12
+ asserts("path of existing 'a.b.c'") { json_path({"a" => {"b" => {"c" => "car"}}}, "a.b.c") }.equals("car")
13
+
14
+ context "for hash based-lookups" do
15
+ asserts("path of existing '[a]'") do
16
+ json_path({"a" => {"b" => "bar"}}, '["a"]')
17
+ end.equals({"b" => "bar"})
18
+
19
+ asserts("path of existing 'a[\"b\"]'") do
20
+ json_path({"a" => {"b" => "bar"}}, 'a["b"]')
21
+ end.equals("bar")
22
+
23
+ asserts("path of existing 'a['b']'") do
24
+ json_path({"a" => {"b" => "bar"}}, "a['b']")
25
+ end.equals("bar")
26
+
27
+ asserts("path of existing 'a[b]'") do
28
+ json_path({"a" => {"b" => "bar"}}, "a[b]")
29
+ end.equals("bar")
30
+
31
+ asserts("path of existing 'a[ b ]'") do
32
+ json_path({"a" => {"b" => "bar"}}, "a[ b ]")
33
+ end.equals("bar")
34
+
35
+ asserts("path of existing 'a[b-ar]'") do
36
+ json_path({"a" => {"b" => "bar"}}, "a[b-ar]")
37
+ end.nil
38
+ end # for hash based-lookups
39
+
40
+ context "for index based-lookups" do
41
+ asserts("path of existing '[0]'") do
42
+ json_path(["foo", "bar"], '[0]')
43
+ end.equals("foo")
44
+
45
+ asserts("path of existing '[\"0\"]'") do
46
+ json_path(["foo", "bar"], '["0"]')
47
+ end.equals("foo")
48
+
49
+ asserts("path of existing 'a[1]'") do
50
+ json_path({"a" => ["foo", "bar"]}, 'a[1]')
51
+ end.equals("bar")
52
+ end # for index based-lookups
53
+
54
+ context "for mix of dot, hash, index based-lookups" do
55
+ asserts("path of existing '[a][1].c[0]'") do
56
+ json_path({"a" => [ {"b" => "nil"}, {"c" => ["foo", "bar"]} ]}, '[a][1].c[0]')
57
+ end.equals("foo")
58
+ end # for mix of hash and index based-lookups
59
+ end # The json_path helper
data/test/teststrap.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'riot'
3
+ require 'webmock'
4
+ require 'pathname'
5
+
6
+ require 'riot/gear'
7
+
8
+ Dir[Pathname(__FILE__).dirname + "/riot_macros/**/*.rb"].each { |l| require l }
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Justin 'Gus' Knowlden
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-23 00:00:00 -05:00
17
+ date: 2010-06-24 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -41,6 +41,18 @@ dependencies:
41
41
  version: "0"
42
42
  type: :runtime
43
43
  version_requirements: *id002
44
+ - !ruby/object:Gem::Dependency
45
+ name: webmock
46
+ prerelease: false
47
+ requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ type: :development
55
+ version_requirements: *id003
44
56
  description: Riot + HTTParty smoke testing framework. You'd use it for integration testing with real HTTP requests and responses
45
57
  email: gus@gusg.us
46
58
  executables: []
@@ -63,6 +75,8 @@ files:
63
75
  - lib/riot/gear/middleware.rb
64
76
  - lib/riot/gear/middleware/riotparty.rb
65
77
  - riot-gear.gemspec
78
+ - test/helpers/json_path_test.rb
79
+ - test/teststrap.rb
66
80
  has_rdoc: true
67
81
  homepage: http://github.com/thumblemonks/riot-gear
68
82
  licenses: []
@@ -93,5 +107,6 @@ rubygems_version: 1.3.6
93
107
  signing_key:
94
108
  specification_version: 3
95
109
  summary: Riot + HTTParty smoke testing framework
96
- test_files: []
97
-
110
+ test_files:
111
+ - test/helpers/json_path_test.rb
112
+ - test/teststrap.rb