rspec-integration 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,67 @@
1
+ ### RSpec Integration ###
2
+
3
+ RSpec Integration adds an integration example group to rspec-rails that incorporates capybara for integration testing.
4
+
5
+ ### Installation ###
6
+
7
+ Add this to your gemfile.
8
+
9
+ `gem 'rspec-integration'`
10
+
11
+ It will automatically include rspec-rails and capybara so you do not need any additional inclusions.
12
+
13
+ Add the require in `spec/support/integration.rb`
14
+
15
+ `require 'rspec/rails/example/integration_example_group.rb'`
16
+
17
+ Create a folder for integration specs.
18
+
19
+ `spec/integration`
20
+
21
+ Start writing integration specs with Capybara!
22
+
23
+ ### Usage ###
24
+
25
+ Example file: `spec/integration/user_signs_in_spec.rb`
26
+
27
+ describe "User Signs In" do
28
+
29
+ context "As a guest on the sign in page"
30
+
31
+ let!(:user) { Fabricate(:confirmed_user, :email => "joe@example.com") }
32
+
33
+ before do
34
+ visit new_user_session_path
35
+ end
36
+
37
+ context "Filling in the form with valid credentials" do
38
+
39
+ before do
40
+ fill_in "Email", :with => "joe@example.com"
41
+ fill_in "Password", :with => "password"
42
+ click_button "Submit"
43
+ end
44
+
45
+ it "Logs me in" do
46
+ page.should have_content("Signed in successfully")
47
+ end
48
+
49
+ end
50
+
51
+ context "Filling in the form with invalid credentials" do
52
+
53
+ before do
54
+ fill_in "Email", :with => "bad email"
55
+ fill_in "Password", :with => "bad password"
56
+ click_button "Submit"
57
+ end
58
+
59
+ it "Logs me in" do
60
+ page.should have_content("Unable to sign in")
61
+ end
62
+
63
+ end
64
+
65
+ end
66
+
67
+ end
File without changes
@@ -0,0 +1,37 @@
1
+ require 'action_dispatch'
2
+ require 'capybara/rails'
3
+ require 'capybara/dsl'
4
+
5
+ module RSpec::Rails
6
+ module IntegrationExampleGroup
7
+ extend ActiveSupport::Concern
8
+
9
+ include ActionDispatch::Integration::Runner
10
+ include RSpec::Rails::TestUnitAssertionAdapter
11
+ include ActionDispatch::Assertions
12
+ include Capybara
13
+ include RSpec::Matchers
14
+
15
+ module InstanceMethods
16
+ def app
17
+ ::Rails.application
18
+ end
19
+
20
+ def last_response
21
+ page
22
+ end
23
+ end
24
+
25
+ included do
26
+ metadata[:type] = :integration
27
+
28
+ before do
29
+ @router = ::Rails.application.routes
30
+ end
31
+ end
32
+
33
+ RSpec.configure do |c|
34
+ c.include self, :example_group => { :file_path => /\bspec\/integration\// }
35
+ end
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-integration
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Paul Elliott
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-21 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec-rails
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 62196417
30
+ segments:
31
+ - 2
32
+ - 0
33
+ - 0
34
+ - beta
35
+ - 17
36
+ version: 2.0.0.beta.17
37
+ type: :runtime
38
+ version_requirements: *id001
39
+ - !ruby/object:Gem::Dependency
40
+ name: capybara
41
+ prerelease: false
42
+ requirement: &id002 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ hash: 1
48
+ segments:
49
+ - 0
50
+ - 3
51
+ - 9
52
+ version: 0.3.9
53
+ type: :runtime
54
+ version_requirements: *id002
55
+ description: Adds a capybara integration test group to RSpec 2.
56
+ email:
57
+ - paul@hashrocket.com
58
+ executables: []
59
+
60
+ extensions: []
61
+
62
+ extra_rdoc_files: []
63
+
64
+ files:
65
+ - lib/rspec/rails/example/integration_example_group.rb
66
+ - lib/rspec-integration.rb
67
+ - README.markdown
68
+ has_rdoc: true
69
+ homepage: http://github.com/paulelliott/rspec-integration
70
+ licenses: []
71
+
72
+ post_install_message:
73
+ rdoc_options: []
74
+
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ requirements: []
96
+
97
+ rubyforge_project:
98
+ rubygems_version: 1.3.7
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Adds capybara integration test group to RSpec 2.
102
+ test_files: []
103
+