Skip to content

Commit e6c37c3

Browse files
committed
Rspec
1 parent d03d582 commit e6c37c3

File tree

10 files changed

+77
-77
lines changed

10 files changed

+77
-77
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
rvm:
22
- 1.9.3
3+
script: bundle exec rspec spec

Guardfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
guard 'rspec' do
2+
watch(%r{^spec/.+_spec\.rb$})
3+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4+
watch('spec/spec_helper.rb') { "spec" }
5+
end
6+

Rakefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@ require "rake/testtask"
33

44
require_relative "lib/sy18nc"
55

6-
Rake::TestTask.new(:spec) do |t|
7-
t.libs.push "lib"
8-
t.test_files = FileList["spec/*_spec.rb"]
9-
t.verbose = true
10-
end
11-
12-
task :default => [:spec]
13-
146
desc "Open an irb session preloaded with this library"
157
task :console do
168
sh "irb -rubygems -I lib -I extra -r ./lib/sy18nc.rb"

lib/sy18nc/locale.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ def initialize(file)
88
@name = File.basename(file,".*")
99

1010
file = replace_fixmes(file)
11-
1211
begin
1312
@hash = YAML.load(file)
1413
rescue Exception => e

spec/ext_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
describe Array do
44
it "extracts options" do
55
a = [1, 2, 3, 4, { option: true, option2: false }]
6-
a.sy18nc_extract_options!.must_equal({ option: true, option2: false })
7-
a.must_equal([1,2,3,4])
6+
a.sy18nc_extract_options!.should eql({ option: true, option2: false })
7+
a.should eql([1,2,3,4])
88

9-
a.sy18nc_extract_options!.must_equal({})
10-
a.must_equal([1,2,3,4])
9+
a.sy18nc_extract_options!.should eql({})
10+
a.should eql([1,2,3,4])
1111
end
1212

1313
it "appends" do
1414
a = ["hello", "world"]
1515

1616
a.sy18nc_append!("appended_string")
1717

18-
a.must_equal ["helloappended_string", "worldappended_string"]
18+
a.should eql(["helloappended_string", "worldappended_string"])
1919
end
2020
end
2121

@@ -57,7 +57,7 @@
5757
}
5858
}
5959

60-
@hash.sy18nc_append!("appended_string").must_equal appended_hash
60+
@hash.sy18nc_append!("appended_string").should eql(appended_hash)
6161

6262
hash2 = {
6363
:key1 => "helloworld",
@@ -77,7 +77,7 @@
7777
]
7878
}
7979

80-
hash2.sy18nc_append!("appended_string").must_equal appended_hash2
80+
hash2.sy18nc_append!("appended_string").should eql(appended_hash2)
8181
end
8282

8383
it "deep marks fixme" do
@@ -99,7 +99,7 @@
9999
}
100100

101101
@hash.sy18nc_mark_fixme!
102-
@hash.must_equal fixme_hash
102+
@hash.should eql(fixme_hash)
103103
end
104104

105105
it "deep merges and marks fixme" do
@@ -131,19 +131,19 @@
131131
}
132132
}
133133

134-
other_hash.sy18nc_deep_merge!(@hash).must_equal result
134+
other_hash.sy18nc_deep_merge!(@hash).should eql(result)
135135
end
136136

137137
it "deep merges hashes with nested arrays" do
138138
end
139139

140140
describe String do
141141
it "marks fixme" do
142-
"Hello".sy18nc_mark_fixme!.must_equal("Hello g FIXME")
142+
"Hello".sy18nc_mark_fixme!.should eql("Hello g FIXME")
143143

144-
"Hello g FIXME".sy18nc_mark_fixme!.must_equal("Hello g FIXME")
144+
"Hello g FIXME".sy18nc_mark_fixme!.should eql("Hello g FIXME")
145145

146-
"*hello_world".sy18nc_mark_fixme!.must_equal("*hello_world")
146+
"*hello_world".sy18nc_mark_fixme!.should eql("*hello_world")
147147
end
148148
end
149149
end

spec/locale_spec.rb

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,80 +6,78 @@
66
end
77

88
it "loads the yaml" do
9-
@locale.hash.wont_be_empty
10-
@locale.hash.must_be_kind_of Hash
9+
@locale.hash.should_not be_empty
10+
@locale.hash.should be_a_kind_of(Hash)
1111

1212
locale = Sy18nc::Locale.new("spec/fixtures/devise.tr.yml")
13-
locale.hash.wont_be_empty
14-
locale.hash.must_be_kind_of Hash
15-
assert locale.synchronizable?
13+
locale.hash.should_not be_empty
14+
locale.hash.should be_a_kind_of(Hash)
15+
locale.synchronizable?.should be_true
1616
end
1717

1818
it "is not synchronizable when YAML is not valid" do
1919
t = Sy18nc::Locale.new("spec/fixtures/not_valid.yml")
20-
refute t.synchronizable?
20+
t.synchronizable?.should be_false
2121
end
2222

2323
it "fetches the locale body" do
24-
@locale.body.wont_equal "en"
25-
@locale.body.must_be_kind_of Hash
24+
@locale.body.should_not eql("en")
25+
@locale.body.should be_a_kind_of(Hash)
2626

2727
locale = Sy18nc::Locale.new("spec/fixtures/devise.tr.yml")
28-
locale.body.wont_be_empty
29-
locale.body.must_be_kind_of Hash
28+
locale.body.should_not be_empty
29+
locale.body.should be_a_kind_of(Hash)
3030
end
3131

3232
it "writes the locale to file" do
33-
refute File.exists?("en.yml")
33+
File.exists?("en.yml").should be_false
3434
@locale.save
35-
assert File.exists?("en.yml")
35+
File.exists?("en.yml").should be_true
3636

37-
refute File.exists?("en.yml.bak")
37+
File.exists?("en.yml.bak").should be_false
3838
@locale.save(backup: true)
39-
assert File.exists?("en.yml.bak")
39+
File.exists?("en.yml.bak").should be_true
4040

41-
refute File.exists?("locale_file.yml")
41+
File.exists?("locale_file.yml").should be_false
4242
@locale.save(filename: "locale_file")
43-
assert File.exists?("locale_file.yml")
43+
File.exists?("locale_file.yml").should be_true
4444

45-
refute File.exists?("locale_file.yml.bak")
45+
File.exists?("locale_file.yml.bak").should be_false
4646
@locale.save(filename: "locale_file", backup: true)
47-
assert File.exists?("locale_file.yml.bak")
47+
File.exists?("locale_file.yml.bak").should be_true
4848

4949
cleanup
5050
end
5151

5252
it "converts locale to yml" do
53-
@locale.to_yaml.wont_be_empty
54-
@locale.to_yaml.must_be_kind_of String
55-
@locale.to_yaml.must_equal %q[---
53+
@locale.to_yaml.should_not be_empty
54+
@locale.to_yaml.should be_a_kind_of(String)
55+
@locale.to_yaml.should eql(%q[---
5656
en:
5757
promo:
5858
link1: "Hello"
5959
link2: "Hello"
60-
]
60+
])
6161
end
6262

6363
it "synchronizes locales" do
6464
russian_locale = Sy18nc::Locale.new("spec/fixtures/ru.yml")
6565
russian_locale.synchronize(@locale)
66-
russian_locale.to_yaml.must_equal %q[---
66+
russian_locale.to_yaml.should eql(%q[---
6767
ru:
6868
promo:
6969
link1: "Birbevoon"
7070
link2: "Hello" # FIXME
71-
]
72-
@locale.to_yaml.lines.count.must_equal russian_locale.to_yaml.lines.count
71+
])
72+
@locale.to_yaml.lines.count.should eql(russian_locale.to_yaml.lines.count)
7373

7474
devise_en = Sy18nc::Locale.new("spec/fixtures/devise.en.yml")
7575
devise_tr = Sy18nc::Locale.new("spec/fixtures/devise.tr.yml")
76-
devise_en.to_yaml.lines.count.wont_equal devise_tr.to_yaml.lines.count
76+
devise_en.to_yaml.lines.count.should_not eql(devise_tr.to_yaml.lines.count)
7777

7878
devise_tr.synchronize(devise_en)
79-
devise_tr.to_yaml.lines.count.must_equal devise_en.to_yaml.lines.count
80-
devise_tr.to_yaml.must_equal(File.read(File.expand_path("spec/fixtures/results/devise.tr.yml")))
81-
82-
79+
devise_tr.to_yaml.lines.count.should eql(devise_en.to_yaml.lines.count)
80+
devise_tr.to_yaml.should eql(File.read(File.expand_path("spec/fixtures/results/devise.tr.yml")))
8381
end
8482

8583
def cleanup

spec/spec_helper.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
require 'simplecov'
22
SimpleCov.start 'rails'
33

4-
require 'minitest/autorun'
5-
require 'minitest/spec'
6-
require 'turn/autorun'
7-
84
require_relative '../lib/sy18nc.rb'
5+
6+
RSpec.configure do |config|
7+
config.failure_color = :magenta
8+
config.tty = true
9+
config.color = true
10+
end

spec/sy18nc_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
describe Sy18nc do
44
it "is configurable" do
5-
Sy18nc.config.base_locale.must_equal "en"
6-
Sy18nc.config.locales_dir.must_equal "#{Dir.pwd}/config/locales"
7-
Sy18nc.config.files.must_equal []
8-
Sy18nc.config.locales.must_equal []
5+
Sy18nc.config.base_locale.should eql("en")
6+
Sy18nc.config.locales_dir.should eql("#{Dir.pwd}/config/locales")
7+
Sy18nc.config.files.should eql([])
8+
Sy18nc.config.locales.should eql([])
99

1010
Sy18nc.configure do |c|
1111
c.base_locale = "ru"
@@ -15,10 +15,10 @@
1515
c.locales = ["en", "es", "fr", "de"]
1616
end
1717

18-
Sy18nc.config.base_locale.must_equal "ru"
19-
Sy18nc.config.locales_dir.must_equal "spec/fixtures"
20-
Sy18nc.config.backup.must_equal true
21-
Sy18nc.config.files.must_equal ["code", "devise", "doorkeeper"]
22-
Sy18nc.config.locales.must_equal ["en", "es", "fr", "de"]
18+
Sy18nc.config.base_locale.should eql("ru")
19+
Sy18nc.config.locales_dir.should eql("spec/fixtures")
20+
Sy18nc.config.backup.should eql(true)
21+
Sy18nc.config.files.should eql(["code", "devise", "doorkeeper"])
22+
Sy18nc.config.locales.should eql(["en", "es", "fr", "de"])
2323
end
2424
end

spec/sychronizer_spec.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
require_relative 'spec_helper'
22

33
describe Sy18nc::Synchronizer do
4-
def setup
4+
before do
55
@synchronizer = Sy18nc::Synchronizer.new("spec/fixtures/", "en.yml" ,"ru.yml", backup: true)
66
end
77

8-
def teardown
8+
after do
99
%x[rm spec/fixtures/*.bak]
1010
end
1111

@@ -16,13 +16,13 @@ def teardown
1616
synchronizer.synchronize_all
1717
after = File.read(File.expand_path("spec/fixtures/en.yml"))
1818

19-
after.must_equal before
19+
after.should eq before
2020
end
2121

2222
it "synchronizes translation only once" do
2323
3.times do
2424
@synchronizer.synchronize_all
25-
File.read(File.expand_path("spec/fixtures/ru.yml.bak")).must_equal %q[---
25+
File.read(File.expand_path("spec/fixtures/ru.yml.bak")).should eq %q[---
2626
ru:
2727
promo:
2828
link1: "Birbevoon"
@@ -33,25 +33,25 @@ def teardown
3333
4.times do
3434
synchronizer = Sy18nc::Synchronizer.new("spec/fixtures/", "devise.en.yml", "devise.tr.yml", backup: true)
3535
synchronizer.synchronize_all
36-
File.read(File.expand_path("spec/fixtures/devise.tr.yml.bak")).must_equal(File.read(File.expand_path("spec/fixtures/results/devise.tr.yml")))
36+
File.read(File.expand_path("spec/fixtures/devise.tr.yml.bak")).should eq(File.read(File.expand_path("spec/fixtures/results/devise.tr.yml")))
3737
end
3838
end
3939

4040
it "when backup option is set to true saves as a backup file and does not modify original files" do
41-
refute File.exists?(File.expand_path("spec/fixtures/ru.yml.bak"))
41+
File.exists?(File.expand_path("spec/fixtures/ru.yml.bak")).should be_false
4242
@synchronizer.synchronize_all
43-
assert File.exists?(File.expand_path("spec/fixtures/ru.yml.bak"))
44-
File.read(File.expand_path("spec/fixtures/ru.yml.bak")).must_equal %q[---
43+
File.exists?(File.expand_path("spec/fixtures/ru.yml.bak")).should be_true
44+
File.read(File.expand_path("spec/fixtures/ru.yml.bak")).should eq %q[---
4545
ru:
4646
promo:
4747
link1: "Birbevoon"
4848
link2: "Hello" # FIXME
4949
]
5050

51-
refute File.exists?(File.expand_path("spec/fixtures/devise.tr.yml.bak"))
51+
File.exists?(File.expand_path("spec/fixtures/devise.tr.yml.bak")).should be_false
5252
synchronizer = Sy18nc::Synchronizer.new("spec/fixtures/", "devise.en.yml", "devise.tr.yml", backup: true)
5353
synchronizer.synchronize_all
54-
assert File.exists?(File.expand_path("spec/fixtures/devise.tr.yml.bak"))
55-
File.read(File.expand_path("spec/fixtures/devise.tr.yml.bak")).must_equal(File.read(File.expand_path("spec/fixtures/results/devise.tr.yml")))
54+
File.exists?(File.expand_path("spec/fixtures/devise.tr.yml.bak")).should be_true
55+
File.read(File.expand_path("spec/fixtures/devise.tr.yml.bak")).should eq(File.read(File.expand_path("spec/fixtures/results/devise.tr.yml")))
5656
end
5757
end

sy18nc.gemspec

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ Gem::Specification.new do |spec|
2121
spec.add_dependency "psych", "~> 2.0.1"
2222

2323
spec.add_development_dependency "bundler", "~> 1.3"
24-
spec.add_development_dependency "rake"
25-
spec.add_development_dependency "turn", "~> 0.9.6"
24+
spec.add_development_dependency "rake", '~> 10.1.0'
2625
spec.add_development_dependency "simplecov", "~> 0.7.1"
26+
spec.add_development_dependency "rspec", "~> 2.14"
27+
spec.add_development_dependency "guard"
28+
spec.add_development_dependency "guard-rspec"
2729
end

0 commit comments

Comments
 (0)