caviidae 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Luminosity Group
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,71 @@
1
+ # Caviidae
2
+
3
+ This is a gem that provides helpers for integration testing Visualforce apps
4
+ with Capybara, RSpec and the Databasedotcom gem. It makes use of the databasedotcom gem to allow you to use
5
+ fixtures that are automatically cleaned up between specs.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'caviidae'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install caviidae
20
+
21
+ ## Usage
22
+
23
+ Include the following in your `spec_helper.rb`:
24
+
25
+ ```ruby
26
+ require "bundler"
27
+ Bundler.require :default, :development
28
+ require "pp"
29
+ require "capybara"
30
+ require "capybara/dsl"
31
+ require "capybara/rspec"
32
+
33
+ Capybara.app_host = 'https://www.google.com'
34
+
35
+ Caviidae.configure do |config|
36
+ config.client_id = ENV['SFDC_CLIENT_ID']
37
+ config.client_secret = ENV['SFDC_CLIENT_SECRET']
38
+ config.username = ENV['SFDC_USERNAME']
39
+ config.password = ENV['SFDC_PASSWORD']
40
+ config.security_token = ENV['SFDC_SECURITY_TOKEN']
41
+ end
42
+ ```
43
+
44
+ Then create your request specs:
45
+
46
+ ```ruby
47
+ require 'spec_helper'
48
+
49
+ describe "My App", :type => :request do
50
+ let(:account) do
51
+ db.materialize('User')
52
+ db.materialize('Account')
53
+ Account.new(:Name => 'test', :OwnerId => User.first.Id).save
54
+ end
55
+
56
+ # After each test runs, any created sobjects will be removed.
57
+ it "does something with the account" do
58
+ visit '/'
59
+ page.should have_content(account.Name)
60
+ end
61
+ end
62
+ ```
63
+
64
+
65
+ ## Contributing
66
+
67
+ 1. Fork it
68
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
69
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
70
+ 4. Push to the branch (`git push origin my-new-feature`)
71
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/caviidae/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Eric J. Holmes"]
6
+ gem.email = ["eric@ejholmes.net"]
7
+ gem.description = %q{Gem to help with integration testing of visualforce apps with capybara}
8
+ gem.summary = %q{Gem to help with integration testing of visualforce apps with capybara}
9
+ gem.homepage = ""
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "caviidae"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Caviidae::VERSION
17
+
18
+ gem.add_dependency "capybara"
19
+ gem.add_dependency "databasedotcom", "1.3.0"
20
+
21
+ gem.add_development_dependency "rspec"
22
+ end
@@ -0,0 +1,21 @@
1
+ require "caviidae/databasedotcom"
2
+ require "caviidae/version"
3
+ require "caviidae/config"
4
+
5
+ module Caviidae
6
+
7
+ class << self
8
+
9
+ def db
10
+ @client
11
+ end
12
+
13
+ def connect
14
+ client = Databasedotcom::Client.new :client_id => configuration.client_id, :client_secret => configuration.client_secret, :host => configuration.host
15
+ client.authenticate :username => configuration.username, :password => "#{CGI::escape(configuration.password)}#{configuration.security_token}"
16
+ @client = client
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,43 @@
1
+ require 'caviidae/databasedotcom'
2
+ require 'caviidae/rspec'
3
+ require 'rspec'
4
+
5
+ module Caviidae
6
+ class << self
7
+ def configuration
8
+ @configuration ||= Configuration.new
9
+ end
10
+
11
+ # Pass in a block to configure
12
+ def configure
13
+ yield configuration
14
+ ::RSpec.configure do |config|
15
+ config.after(:each) { Caviidae.db.cleanup }
16
+ config.include ::Caviidae::RSpec::Helpers
17
+ end if configuration.rspec
18
+ end
19
+ end
20
+
21
+ class Configuration
22
+ # OAuth client id
23
+ attr_accessor :client_id
24
+ # OAuth client secret
25
+ attr_accessor :client_secret
26
+ # SFDC username
27
+ attr_accessor :username
28
+ # SFDC password
29
+ attr_accessor :password
30
+ # SFDC security token
31
+ attr_accessor :security_token
32
+ # Login host. Defaults to login.salesforce.com
33
+ attr_accessor :host
34
+
35
+ # Auto config rspec
36
+ attr_accessor :rspec
37
+
38
+ def initialize
39
+ @security_token = "login.salesforce.com"
40
+ @rspec = true
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,2 @@
1
+ require 'databasedotcom'
2
+ require 'caviidae/databasedotcom/client'
@@ -0,0 +1,39 @@
1
+ require 'databasedotcom'
2
+
3
+ module Databasedotcom
4
+ class Client
5
+
6
+ # Maybe there's a better way to do this but overriding the method should
7
+ # work
8
+ def create(class_or_classname, object_attrs)
9
+ class_or_classname = find_or_materialize(class_or_classname)
10
+ json_for_assignment = coerced_json(object_attrs, class_or_classname)
11
+ result = http_post("/services/data/v#{self.version}/sobjects/#{class_or_classname.sobject_name}", json_for_assignment)
12
+ new_object = class_or_classname.new
13
+ JSON.parse(json_for_assignment).each do |property, value|
14
+ set_value(new_object, property, value, class_or_classname.type_map[property][:type])
15
+ end
16
+ id = JSON.parse(result.body)["id"]
17
+ set_value(new_object, "Id", id, "id")
18
+ store(new_object)
19
+ new_object
20
+ end
21
+
22
+ def store(sobject)
23
+ created << sobject
24
+ end
25
+
26
+ def cleanup
27
+ created.each do |sobject|
28
+ sobject.delete
29
+ sobject = nil
30
+ end
31
+ @created = []
32
+ end
33
+
34
+ def created
35
+ @created ||= []
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,11 @@
1
+ module Caviidae
2
+ module RSpec
3
+ module Helpers
4
+
5
+ def db
6
+ ::Caviidae.db
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Caviidae
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Databasedotcom do
4
+ let(:account) do
5
+ db.materialize('User')
6
+ db.materialize('Account')
7
+ Account.new(:Name => 'test', :OwnerId => User.first.Id).save
8
+ end
9
+
10
+ it "does something" do
11
+ puts account
12
+ end
13
+
14
+ it "does it again" do
15
+ puts account
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Google", :type => :request do
4
+ it "goes to google" do
5
+ visit '/'
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ require "bundler"
2
+ Bundler.require :default, :development
3
+ require "pp"
4
+ require "capybara"
5
+ require "capybara/dsl"
6
+ require "capybara/rspec"
7
+
8
+ Capybara.register_driver :firefox_no_ssl do |app|
9
+ require 'selenium/webdriver'
10
+ profile = Selenium::WebDriver::Firefox::Profile.new
11
+ profile.assume_untrusted_certificate_issuer = false
12
+
13
+ Capybara::Selenium::Driver.new(app, :profile => profile)
14
+ end
15
+
16
+ Capybara.default_driver = :firefox_no_ssl
17
+ Capybara.app_host = 'https://www.google.com'
18
+
19
+ Caviidae.configure do |config|
20
+ config.client_id = ENV['SFDC_CLIENT_ID']
21
+ config.client_secret = ENV['SFDC_CLIENT_SECRET']
22
+ config.username = ENV['SFDC_USERNAME']
23
+ config.password = ENV['SFDC_PASSWORD']
24
+ config.security_token = ENV['SFDC_SECURITY_TOKEN']
25
+ end
26
+
27
+ Caviidae.connect
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: caviidae
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Eric J. Holmes
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capybara
16
+ requirement: &2161177140 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2161177140
25
+ - !ruby/object:Gem::Dependency
26
+ name: databasedotcom
27
+ requirement: &2161176360 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - =
31
+ - !ruby/object:Gem::Version
32
+ version: 1.3.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2161176360
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &2161175560 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2161175560
47
+ description: Gem to help with integration testing of visualforce apps with capybara
48
+ email:
49
+ - eric@ejholmes.net
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE
57
+ - README.md
58
+ - Rakefile
59
+ - caviidae.gemspec
60
+ - lib/caviidae.rb
61
+ - lib/caviidae/config.rb
62
+ - lib/caviidae/databasedotcom.rb
63
+ - lib/caviidae/databasedotcom/client.rb
64
+ - lib/caviidae/rspec.rb
65
+ - lib/caviidae/version.rb
66
+ - spec/lib/databasedotcom/client_spec.rb
67
+ - spec/requests/google_spec.rb
68
+ - spec/spec_helper.rb
69
+ homepage: ''
70
+ licenses: []
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 1.8.11
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Gem to help with integration testing of visualforce apps with capybara
93
+ test_files:
94
+ - spec/lib/databasedotcom/client_spec.rb
95
+ - spec/requests/google_spec.rb
96
+ - spec/spec_helper.rb
97
+ has_rdoc: