cucumber-api-steps 0.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.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ree@cucumber-api-steps
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cuke-api-steps.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'bueller'
5
+ Bueller::Tasks.new
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "cucumber/api_steps/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "cucumber-api-steps"
7
+ s.version = Cucumber::ApiSteps::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Jay Zeschin"]
10
+ s.email = ["jay.zeschin@factorylabs.com"]
11
+ s.homepage = "http://github.com/jayzes/cucumber-api-steps"
12
+ s.summary = %q{Cucumber steps to easily test REST-based XML and JSON APIs}
13
+ s.description = %q{Cucumber steps to easily test REST-based XML and JSON APIs}
14
+
15
+ s.add_dependency 'jsonpath', '>= 0.1.2'
16
+ s.add_dependency 'cucumber', '>= 0.8.3'
17
+ s.add_development_dependency 'bueller'
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,60 @@
1
+ World(Rack::Test::Methods)
2
+
3
+ Given /^I send and accept XML$/ do
4
+ page.driver.header 'Accept', 'text/xml'
5
+ page.driver.header 'Content-Type', 'text/xml'
6
+ end
7
+
8
+ Given /^I send and accept JSON$/ do
9
+ page.driver.header 'Accept', 'application/json'
10
+ page.driver.header 'Content-Type', 'application/json'
11
+ end
12
+
13
+ When /^I authenticate as the user "([^\"]*)" with the password "([^\"]*)"$/ do |user, pass|
14
+ page.driver.authorize(user, pass)
15
+ end
16
+
17
+ When /^I send a GET request (?:for|to) "([^\"]*)"$/ do |path|
18
+ page.driver.get path
19
+ end
20
+
21
+ When /^I send a POST request to "([^\"]*)"$/ do |path|
22
+ page.driver.post path
23
+ end
24
+
25
+ When /^I send a POST request to "([^\"]*)" with the following:$/ do |path, body|
26
+ page.driver.post path, body
27
+ end
28
+
29
+ When /^I send a PUT request to "([^\"]*)" with the following:$/ do |path, body|
30
+ page.driver.put path, body
31
+ end
32
+
33
+ When /^I send a DELETE request to "([^\"]*)"$/ do |path|
34
+ page.driver.delete path
35
+ end
36
+
37
+ Then /^show me the response$/ do
38
+ p page.driver.last_response
39
+ end
40
+
41
+ Then /^the response status should be "([^\"]*)"$/ do |status|
42
+ page.driver.last_response.status.should == status.to_i
43
+ end
44
+
45
+ Then /^the JSON response should have "([^\"]*)" with the text "([^\"]*)"$/ do |json_path, text|
46
+ json = JSON.parse(page.driver.last_response.body)
47
+ JsonPath.new(json_path).on(json).to_a.map(&:to_s).should include(text)
48
+ end
49
+
50
+ Then /^the JSON response should not have "([^\"]*)" with the text "([^\"]*)"$/ do |json_path, text|
51
+ json = JSON.parse(page.driver.last_response.body)
52
+ JsonPath.new(json_path).on(json).to_a.map(&:to_s).should_not include(text)
53
+ end
54
+
55
+ Then /^the XML response should have "([^\"]*)" with the text "([^\"]*)"$/ do |xpath, text|
56
+ parsed_response = Nokogiri::XML(last_response.body)
57
+ elements = parsed_response.xpath(xpath)
58
+ elements.should_not be_empty, "could not find #{xpath} in:\n#{last_response.body}"
59
+ elements.find { |e| e.text == text }.should_not be_nil, "found elements but could not find #{text} in:\n#{elements.inspect}"
60
+ end
@@ -0,0 +1,5 @@
1
+ module Cucumber
2
+ module ApiSteps
3
+ VERSION = "0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cucumber-api-steps
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.1"
10
+ platform: ruby
11
+ authors:
12
+ - Jay Zeschin
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-04-12 00:00:00 -06:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: jsonpath
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 31
29
+ segments:
30
+ - 0
31
+ - 1
32
+ - 2
33
+ version: 0.1.2
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: cucumber
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 57
45
+ segments:
46
+ - 0
47
+ - 8
48
+ - 3
49
+ version: 0.8.3
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: bueller
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ type: :development
65
+ version_requirements: *id003
66
+ description: Cucumber steps to easily test REST-based XML and JSON APIs
67
+ email:
68
+ - jay.zeschin@factorylabs.com
69
+ executables: []
70
+
71
+ extensions: []
72
+
73
+ extra_rdoc_files: []
74
+
75
+ files:
76
+ - .gitignore
77
+ - .rvmrc
78
+ - Gemfile
79
+ - Rakefile
80
+ - cucumber-api-steps.gemspec
81
+ - lib/cucumber/api_steps.rb
82
+ - lib/cucumber/api_steps/version.rb
83
+ has_rdoc: true
84
+ homepage: http://github.com/jayzes/cucumber-api-steps
85
+ licenses: []
86
+
87
+ post_install_message:
88
+ rdoc_options: []
89
+
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 3
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ requirements: []
111
+
112
+ rubyforge_project:
113
+ rubygems_version: 1.4.2
114
+ signing_key:
115
+ specification_version: 3
116
+ summary: Cucumber steps to easily test REST-based XML and JSON APIs
117
+ test_files: []
118
+