skink 0.4.1 → 0.5.0

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/lib/skink/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Skink
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -95,6 +95,20 @@ shared_examples "a REST API test language" do
95
95
  response.should_not have_header(content_type: %r{json})
96
96
  end
97
97
 
98
+ it "is able to test for content in the response body" do
99
+ get "/"
100
+ response.should have_content "Hello, world!"
101
+ response.should have_content(/hello.*world/i)
102
+ end
103
+
104
+ it "has a helpful error message for have_content" do
105
+ get "/"
106
+ expect {response.should have_content "Foo!"}.to raise_error("expected Hello, world! to equal \"Foo!\"")
107
+ expect {response.should have_content(/foo/)}.to raise_error("expected Hello, world! to match /foo/")
108
+ expect {response.should_not have_content "Hello, world!"}.to raise_error("expected Hello, world! to not equal \"Hello, world!\"")
109
+ expect {response.should_not have_content(/world/)}.to raise_error("expected Hello, world! to not match /world/")
110
+ end
111
+
98
112
  it "is able to test for the presence of xml elements in the response body" do
99
113
  with_accept_header "application/xml"
100
114
  get "/xml_doc"
@@ -37,6 +37,20 @@ RSpec::Matchers.define :have_header do |expected|
37
37
  end
38
38
  end
39
39
 
40
+ RSpec::Matchers.define :have_content do |expected|
41
+ match do |response|
42
+ expected === response.body
43
+ end
44
+
45
+ failure_message_for_should do |response|
46
+ "expected #{response.body} to #{expected.is_a?(Regexp) ? "match" : "equal"} #{expected.inspect}"
47
+ end
48
+
49
+ failure_message_for_should_not do |response|
50
+ "expected #{response.body} to not #{expected.is_a?(Regexp) ? "match" : "equal"} #{expected.inspect}"
51
+ end
52
+ end
53
+
40
54
  RSpec::Matchers.define :have_xpath do |xpath, value|
41
55
  match do |response|
42
56
  response.has_xpath? xpath, value
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skink
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-01 00:00:00.000000000 Z
12
+ date: 2012-10-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack-test