caviidae 0.0.4 → 0.0.5

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/README.md CHANGED
@@ -18,20 +18,17 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install caviidae
20
20
 
21
- ## Usage
21
+ ## RSpec Usage
22
22
 
23
23
  Include the following in your `spec_helper.rb`:
24
24
 
25
25
  ```ruby
26
- require "bundler"
27
- Bundler.require :default, :development
28
- require "pp"
29
26
  require "capybara"
30
27
  require "capybara/dsl"
31
28
  require "capybara/rspec"
32
29
  require "caviidae/rspec"
33
30
 
34
- Capybara.app_host = 'https://www.google.com'
31
+ Capybara.app_host = 'http://myapp.com'
35
32
 
36
33
  Caviidae.configure do |config|
37
34
  config.client_id = ENV['SFDC_CLIENT_ID']
@@ -39,6 +36,8 @@ Caviidae.configure do |config|
39
36
  config.username = ENV['SFDC_USERNAME']
40
37
  config.password = ENV['SFDC_PASSWORD']
41
38
  config.security_token = ENV['SFDC_SECURITY_TOKEN']
39
+ # Specify any sObjects that should be materialized before running any tests.
40
+ config.materialize = ['User', 'Account']
42
41
  end
43
42
  ```
44
43
 
@@ -49,8 +48,6 @@ require 'spec_helper'
49
48
 
50
49
  describe "My App", :type => :request do
51
50
  let(:account) do
52
- db.materialize('User')
53
- db.materialize('Account')
54
51
  Account.new(:Name => 'test', :OwnerId => User.first.Id).save
55
52
  end
56
53
 
@@ -62,6 +59,24 @@ describe "My App", :type => :request do
62
59
  end
63
60
  ```
64
61
 
62
+ Any records that get created from the frontend will need to be manually
63
+ deleted. Something like this should work well enough:
64
+
65
+ ```ruby
66
+ it "creates an order" do
67
+ visit '/create_order'
68
+ within('#form') do
69
+ fill_in 'First name', :with => "TestXXX_First"
70
+ fill_in 'Amount', :with => 1
71
+ end
72
+ click_on 'Submit'
73
+ order = Order.last
74
+ order.FirstName__c.should eq("TestXXX_First")
75
+ order.delete
76
+ end
77
+
78
+ ```
79
+
65
80
 
66
81
  ## Contributing
67
82
 
@@ -6,6 +6,12 @@ module Caviidae
6
6
 
7
7
  class << self
8
8
 
9
+ def materialize
10
+ Caviidae.configuration.materialize.each do |sobject|
11
+ db.materialize(sobject)
12
+ end
13
+ end
14
+
9
15
  def db
10
16
  unless @client
11
17
  @client = Databasedotcom::Client.new :client_id => configuration.client_id, :client_secret => configuration.client_secret, :host => configuration.host
@@ -25,9 +25,12 @@ module Caviidae
25
25
  attr_accessor :security_token
26
26
  # Login host. Defaults to login.salesforce.com
27
27
  attr_accessor :host
28
+ # An array of sobjects to materialize at the start
29
+ attr_accessor :materialize
28
30
 
29
31
  def initialize
30
32
  @security_token = "login.salesforce.com"
33
+ @materialize = []
31
34
  end
32
35
  end
33
36
  end
@@ -3,5 +3,6 @@ require 'caviidae/rspec/helpers'
3
3
 
4
4
  RSpec.configure do |config|
5
5
  config.after(:each) { Caviidae.db.cleanup }
6
+ config.before(:all) { Caviidae.materialize }
6
7
  config.include Caviidae::RSpec::Helpers
7
8
  end
@@ -10,6 +10,10 @@ module Caviidae
10
10
  @sobject_types = db.list_sobjects unless @sobject_types
11
11
  @sobject_types
12
12
  end
13
+
14
+ def current_user
15
+ User.find_by_Username(Caviidae.configuration.username)
16
+ end
13
17
 
14
18
  end
15
19
  end
@@ -1,3 +1,3 @@
1
1
  module Caviidae
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -2,9 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Databasedotcom do
4
4
  let(:account) do
5
- db.materialize('User')
6
- db.materialize('Account')
7
- Account.new(:Name => 'test', :OwnerId => User.first.Id).save
5
+ Account.new(:Name => 'test', :OwnerId => current_user.Id).save
8
6
  end
9
7
 
10
8
  it "does something" do
@@ -23,4 +23,5 @@ Caviidae.configure do |config|
23
23
  config.username = ENV['SFDC_USERNAME']
24
24
  config.password = ENV['SFDC_PASSWORD']
25
25
  config.security_token = ENV['SFDC_SECURITY_TOKEN']
26
+ config.materialize = ['User', 'Account']
26
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caviidae
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capybara
16
- requirement: &2162057500 !ruby/object:Gem::Requirement
16
+ requirement: &2160841960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2162057500
24
+ version_requirements: *2160841960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: databasedotcom
27
- requirement: &2162056600 !ruby/object:Gem::Requirement
27
+ requirement: &2160841380 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - =
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.3.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2162056600
35
+ version_requirements: *2160841380
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2162055340 !ruby/object:Gem::Requirement
38
+ requirement: &2160840420 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2162055340
46
+ version_requirements: *2160840420
47
47
  description: Gem to help with integration testing of visualforce apps with capybara
48
48
  email:
49
49
  - eric@ejholmes.net