web_translate_it 2.0.0.rc2 → 2.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,7 @@ describe WebTranslateIt::Term do
6
6
 
7
7
  describe "#initialize" do
8
8
  it "should assign api_key and many parameters" do
9
- term = WebTranslateIt::Term.new(api_key, { "id" => 1234, "text" => "bacon"})
10
- term.api_key.should == api_key
9
+ term = WebTranslateIt::Term.new({ "id" => 1234, "text" => "bacon"})
11
10
  term.id.should == 1234
12
11
  term.text.should == "bacon"
13
12
  end
@@ -15,78 +14,78 @@ describe WebTranslateIt::Term do
15
14
 
16
15
  describe "#save" do
17
16
  it "should create a new Term" do
18
- WebTranslateIt::Util.http_connection do |connection|
19
- term = WebTranslateIt::Term.new(api_key, { "text" => "Term", "description" => "A description" })
20
- term.save(connection)
17
+ WebTranslateIt::Connection.new(api_key) do
18
+ term = WebTranslateIt::Term.new({ "text" => "Term", "description" => "A description" })
19
+ term.save
21
20
  term.id.should_not be_nil
22
- term_fetched = WebTranslateIt::Term.find(connection, api_key, term.id)
21
+ term_fetched = WebTranslateIt::Term.find(term.id)
23
22
  term_fetched.should_not be_nil
24
23
  term_fetched.should be_a(WebTranslateIt::Term)
25
24
  term_fetched.id.should == term.id
26
- term.delete(connection)
25
+ term.delete
27
26
  end
28
27
  end
29
28
 
30
29
  it "should update an existing Term" do
31
- WebTranslateIt::Util.http_connection do |connection|
32
- term = WebTranslateIt::Term.new(api_key, { "text" => "Term", "description" => "A description" })
33
- term.save(connection)
30
+ WebTranslateIt::Connection.new(api_key) do
31
+ term = WebTranslateIt::Term.new({ "text" => "Term", "description" => "A description" })
32
+ term.save
34
33
  term.text = "A Term"
35
- term.save(connection)
36
- term_fetched = WebTranslateIt::Term.find(connection, api_key, term.id)
34
+ term.save
35
+ term_fetched = WebTranslateIt::Term.find(term.id)
37
36
  term_fetched.text.should == "A Term"
38
- term.delete(connection)
37
+ term.delete
39
38
  end
40
39
  end
41
40
 
42
41
  it "should create a new Term with a TermTranslation" do
43
- translation1 = WebTranslateIt::TermTranslation.new(api_key, { "locale" => "fr", "text" => "Bonjour" })
44
- translation2 = WebTranslateIt::TermTranslation.new(api_key, { "locale" => "fr", "text" => "Salut" })
42
+ translation1 = WebTranslateIt::TermTranslation.new({ "locale" => "fr", "text" => "Bonjour" })
43
+ translation2 = WebTranslateIt::TermTranslation.new({ "locale" => "fr", "text" => "Salut" })
45
44
 
46
- term = WebTranslateIt::Term.new(api_key, { "text" => "Hello", "translations" => [translation1, translation2] })
47
- WebTranslateIt::Util.http_connection do |connection|
48
- term.save(connection)
49
- term_fetched = WebTranslateIt::Term.find(connection, api_key, term.id)
50
- term_fetched.translation_for(connection, "fr").should_not be_nil
51
- term_fetched.translation_for(connection, "fr")[0].text.should == "Bonjour"
52
- term_fetched.translation_for(connection, "fr")[1].text.should == "Salut"
53
- term_fetched.translation_for(connection, "es").should be_nil
54
- term.delete(connection)
45
+ term = WebTranslateIt::Term.new({ "text" => "Hello", "translations" => [translation1, translation2] })
46
+ WebTranslateIt::Connection.new(api_key) do
47
+ term.save
48
+ term_fetched = WebTranslateIt::Term.find(term.id)
49
+ term_fetched.translation_for("fr").should_not be_nil
50
+ term_fetched.translation_for("fr")[0].text.should == "Bonjour"
51
+ term_fetched.translation_for("fr")[1].text.should == "Salut"
52
+ term_fetched.translation_for("es").should be_nil
53
+ term.delete
55
54
  end
56
55
  end
57
56
 
58
57
  it "should update a Term and save its Translation" do
59
- translation1 = WebTranslateIt::TermTranslation.new(api_key, { "locale" => "fr", "text" => "Bonjour" })
60
- translation2 = WebTranslateIt::TermTranslation.new(api_key, { "locale" => "fr", "text" => "Salut" })
58
+ translation1 = WebTranslateIt::TermTranslation.new({ "locale" => "fr", "text" => "Bonjour" })
59
+ translation2 = WebTranslateIt::TermTranslation.new({ "locale" => "fr", "text" => "Salut" })
61
60
 
62
- term = WebTranslateIt::Term.new(api_key, { "text" => "Hi!" })
63
- WebTranslateIt::Util.http_connection do |connection|
64
- term.save(connection)
65
- term_fetched = WebTranslateIt::Term.find(connection, api_key, term.id)
66
- term_fetched.translation_for(connection, "fr").should be_nil
61
+ term = WebTranslateIt::Term.new({ "text" => "Hi!" })
62
+ WebTranslateIt::Connection.new(api_key) do
63
+ term.save
64
+ term_fetched = WebTranslateIt::Term.find(term.id)
65
+ term_fetched.translation_for("fr").should be_nil
67
66
 
68
67
  term_fetched.translations = [translation1, translation2]
69
- term_fetched.save(connection)
68
+ term_fetched.save
70
69
 
71
- term_fetched = WebTranslateIt::Term.find(connection, api_key, term.id)
72
- term_fetched.translation_for(connection, "fr").should_not be_nil
73
- term_fetched.translation_for(connection, "fr")[0].text.should == "Bonjour"
74
- term_fetched.translation_for(connection, "fr")[1].text.should == "Salut"
75
- term.delete(connection)
70
+ term_fetched = WebTranslateIt::Term.find(term.id)
71
+ term_fetched.translation_for("fr").should_not be_nil
72
+ term_fetched.translation_for("fr")[0].text.should == "Bonjour"
73
+ term_fetched.translation_for("fr")[1].text.should == "Salut"
74
+ term.delete
76
75
  end
77
76
  end
78
77
  end
79
78
 
80
79
  describe "#delete" do
81
80
  it "should delete a Term" do
82
- term = WebTranslateIt::Term.new(api_key, { "text" => "bacon" })
83
- WebTranslateIt::Util.http_connection do |connection|
84
- term.save(connection)
85
- term_fetched = WebTranslateIt::Term.find(connection, api_key, term.id)
81
+ term = WebTranslateIt::Term.new({ "text" => "bacon" })
82
+ WebTranslateIt::Connection.new(api_key) do
83
+ term.save
84
+ term_fetched = WebTranslateIt::Term.find(term.id)
86
85
  term_fetched.should_not be_nil
87
86
 
88
- term_fetched.delete(connection)
89
- term_fetched = WebTranslateIt::Term.find(connection, api_key, term.id)
87
+ term_fetched.delete
88
+ term_fetched = WebTranslateIt::Term.find(term.id)
90
89
  term_fetched.should be_nil
91
90
  end
92
91
  end
@@ -94,20 +93,20 @@ describe WebTranslateIt::Term do
94
93
 
95
94
  describe "#find_all" do
96
95
  it "should fetch many terms" do
97
- WebTranslateIt::Util.http_connection do |connection|
98
- term1 = WebTranslateIt::Term.new(api_key, { "text" => "bacon" })
99
- term1.save(connection)
100
- term2 = WebTranslateIt::Term.new(api_key, { "text" => "tart" })
101
- term2.save(connection)
102
- term3 = WebTranslateIt::Term.new(api_key, { "text" => "bacon tart" })
103
- term3.save(connection)
96
+ WebTranslateIt::Connection.new(api_key) do
97
+ term1 = WebTranslateIt::Term.new({ "text" => "bacon" })
98
+ term1.save
99
+ term2 = WebTranslateIt::Term.new({ "text" => "tart" })
100
+ term2.save
101
+ term3 = WebTranslateIt::Term.new({ "text" => "bacon tart" })
102
+ term3.save
104
103
 
105
- terms = WebTranslateIt::Term.find_all(connection, api_key)
104
+ terms = WebTranslateIt::Term.find_all
106
105
  terms.count.should == 3
107
106
 
108
- term1.delete(connection)
109
- term2.delete(connection)
110
- term3.delete(connection)
107
+ term1.delete
108
+ term2.delete
109
+ term3.delete
111
110
  end
112
111
  end
113
112
  end
data/version CHANGED
@@ -1 +1 @@
1
- 2.0.0.rc2
1
+ 2.0.0.rc3
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_translate_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc2
4
+ version: 2.0.0.rc3
5
5
  prerelease: 6
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-04-17 00:00:00.000000000 Z
12
+ date: 2012-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multipart-post
@@ -110,6 +110,7 @@ files:
110
110
  - lib/web_translate_it/cacert.pem
111
111
  - lib/web_translate_it/command_line.rb
112
112
  - lib/web_translate_it/configuration.rb
113
+ - lib/web_translate_it/connection.rb
113
114
  - lib/web_translate_it/project.rb
114
115
  - lib/web_translate_it/string.rb
115
116
  - lib/web_translate_it/term.rb