quick_shoulda 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -0
- data/README.rdoc +1 -1
- data/lib/quick_shoulda/random_string/data.rb +31 -0
- data/lib/quick_shoulda/random_string.rb +5 -3
- data/lib/quick_shoulda/version.rb +1 -1
- data/spec/file_writer_spec.rb +4 -3
- data/spec/fixtures/user_spec.rb +2 -4
- data/spec/random_string_spec.rb +1 -0
- metadata +3 -2
- data/data/stored_strings.yml +0 -44
data/.travis.yml
ADDED
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= QuickShoulda
|
1
|
+
= QuickShoulda {<img src="https://badge.fury.io/rb/quick_shoulda.png" alt="Gem Version" />}[http://badge.fury.io/rb/quick_shoulda]{<img src="https://travis-ci.org/nqtien310/quick_shoulda.png?branch=master" alt="Build Status" />}[https://travis-ci.org/nqtien310/quick_shoulda]
|
2
2
|
|
3
3
|
A Rails generator which automatically generates Shoulda test cases ,
|
4
4
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module QuickShoulda
|
2
|
+
module RandomString
|
3
|
+
module Data
|
4
|
+
StoredStrings = {
|
5
|
+
:Emails => ['us@gmail.com', 'us.vn@gmail.com', 'us_vn@gmail.com', 'us_vn@gmail.com.vn'],
|
6
|
+
:Urls => ['www.domain.com', 'www.domain.subdomain.com', 'http://www.domain.com', 'http://www.domain.subdomain.com',
|
7
|
+
'http://www.domain.com/path/1', 'https://www.domain.com', 'https://www.domain.subdomain.com', 'domain.subdomain.com',
|
8
|
+
'domain.com/path/1', 'subdomain.domain.com/path/1'],
|
9
|
+
:IPS => ['192.168.1.1', '192.168.1.2'],
|
10
|
+
:Sex => ['male', 'female', 'gay', 'les', 'other'],
|
11
|
+
:Zips => ['10001', '10002', '10003'],
|
12
|
+
:Phones => ['732-757-2923', '1732-757-2923', '+84 121731845', '84 121731845', '(84) 121731845'],
|
13
|
+
:Datetimes => ['1999-01-01', '99-01-01', '1999/01/01', '99/01/01', '01/01/99', '03/10/1986', '01-01-1999', '01-01-99', 'January 07, 2013',
|
14
|
+
'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday',
|
15
|
+
'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december',
|
16
|
+
'am', 'pm'],
|
17
|
+
:Countries => ['Vietnam', 'America', 'England', 'Vietnamese', 'American', 'English'],
|
18
|
+
:Cities => ['New York', 'London', 'Ho Chi Minh'],
|
19
|
+
:Statuses => ['married', 'single', 'available', 'complicated'],
|
20
|
+
:Files => ['filename.txt', 'filename.jpg', 'filename.png', 'filename.jpeg'],
|
21
|
+
:Extensions => ['txt', 'jpg', 'png', 'jpeg', 'mp4', 'mp3', 'wmv'],
|
22
|
+
:Videos => ['filename.wmv', 'filename.mp4', 'filename.flv'],
|
23
|
+
:CCNumbers => ['4111 1111 1111 1111', '5500 0000 0000 0004', '3400 0000 0000 009', '3000 0000 0000 04'],
|
24
|
+
:CCodes => ['84', '1', '39'],
|
25
|
+
:ISOCCodes => ['US', 'USA', 'VN', 'VNM'],
|
26
|
+
:Services => ['yahoo', 'google', 'facebook', 'amazone', 'youtube', 'paypal', 'alchemy'],
|
27
|
+
:Marks => ['excellent', 'good', 'bad']
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
|
+
require 'quick_shoulda/random_string/data'
|
2
|
+
|
1
3
|
module QuickShoulda
|
2
|
-
|
4
|
+
module RandomString
|
3
5
|
class << self
|
4
6
|
Size = 3
|
5
7
|
LowerCaseChars = ('a'..'z').to_a
|
@@ -10,8 +12,8 @@ module QuickShoulda
|
|
10
12
|
stored_strings + random_digits_strings + random_chars_strings
|
11
13
|
end
|
12
14
|
|
13
|
-
def stored_strings
|
14
|
-
@stored_strings ||=
|
15
|
+
def stored_strings
|
16
|
+
@stored_strings ||= Data::StoredStrings.values.flatten
|
15
17
|
end
|
16
18
|
|
17
19
|
def random_digits_strings
|
data/spec/file_writer_spec.rb
CHANGED
@@ -65,13 +65,14 @@ describe 'QuickShoulda::FileWriter' do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
let(:file_path) { 'spec/fixtures/user_spec.rb' }
|
68
|
-
|
69
68
|
[:association, :validation].each do |block_name|
|
69
|
+
|
70
70
|
it "should clear the whole #{block_name} block" do
|
71
71
|
block = block_describe_header(block_name)
|
72
|
-
|
72
|
+
block_regex = /#{block}\n.+\n\tend/
|
73
|
+
( IO.read(file_path) =~ block_regex ).should_not be_nil
|
73
74
|
clear_block(block)
|
74
|
-
( IO.read(file_path) =~
|
75
|
+
( IO.read(file_path) =~ block_regex ).should be_nil
|
75
76
|
end
|
76
77
|
end
|
77
78
|
end
|
data/spec/fixtures/user_spec.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
describe 'User', :test => true do
|
2
2
|
describe '#Associations' do
|
3
|
-
|
4
|
-
it { should have_many(:attr2) }
|
3
|
+
#There's nothing here
|
5
4
|
end
|
6
5
|
|
7
6
|
describe '#Validations' do
|
8
|
-
|
9
|
-
it { should validate_presence_of(:password) }
|
7
|
+
#There's nothing here also
|
10
8
|
end
|
11
9
|
end
|
data/spec/random_string_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quick_shoulda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -56,11 +56,11 @@ files:
|
|
56
56
|
- .rdebugrc
|
57
57
|
- .rspec
|
58
58
|
- .rvmrc
|
59
|
+
- .travis.yml
|
59
60
|
- Gemfile
|
60
61
|
- LICENSE.txt
|
61
62
|
- README.rdoc
|
62
63
|
- Rakefile
|
63
|
-
- data/stored_strings.yml
|
64
64
|
- lib/generators/quick_shoulda/g_generator.rb
|
65
65
|
- lib/quick_shoulda.rb
|
66
66
|
- lib/quick_shoulda/config.rb
|
@@ -74,6 +74,7 @@ files:
|
|
74
74
|
- lib/quick_shoulda/main.rb
|
75
75
|
- lib/quick_shoulda/path_resolver.rb
|
76
76
|
- lib/quick_shoulda/random_string.rb
|
77
|
+
- lib/quick_shoulda/random_string/data.rb
|
77
78
|
- lib/quick_shoulda/version.rb
|
78
79
|
- quick_shoulda.gemspec
|
79
80
|
- spec/file_writer_spec.rb
|
data/data/stored_strings.yml
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
[
|
2
|
-
#URLs
|
3
|
-
'www.domain.com', 'www.domain.subdomain.com', 'http://www.domain.com', 'http://www.domain.subdomain.com',
|
4
|
-
'http://www.domain.com/path/1', 'https://www.domain.com', 'https://www.domain.subdomain.com', 'domain.subdomain.com',
|
5
|
-
'domain.com/path/1', 'subdomain.domain.com/path/1',
|
6
|
-
#Emails
|
7
|
-
'us@gmail.com', 'us.vn@gmail.com', 'us_vn@gmail.com', 'us_vn@gmail.com.vn',
|
8
|
-
#IPS
|
9
|
-
'192.168.1.1', '192.168.1.2',
|
10
|
-
#Sex
|
11
|
-
'male', 'female', 'gay', 'les', 'other',
|
12
|
-
#Zip postal code
|
13
|
-
'10001', '10002', '10003',
|
14
|
-
#Phone numbers
|
15
|
-
'732-757-2923', '1732-757-2923',
|
16
|
-
#datestimes
|
17
|
-
'1999-01-01', '99-01-01', '1999/01/01', '99/01/01', '01/01/99', '03/10/1986', '01-01-1999', '01-01-99', 'January 07, 2013',
|
18
|
-
'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday',
|
19
|
-
'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december',
|
20
|
-
'am', 'pm',
|
21
|
-
#countries
|
22
|
-
'Vietnam', 'America', 'England',
|
23
|
-
'Vietnamese', 'American', 'English',
|
24
|
-
#cities
|
25
|
-
'New York', 'London', 'Ho Chi Minh',
|
26
|
-
#Status
|
27
|
-
'married', 'single', 'available', 'complicated',
|
28
|
-
#Files
|
29
|
-
'filename.txt', 'filename.jpg', 'filename.png', 'filename.jpeg',
|
30
|
-
#Extensions
|
31
|
-
'txt', 'jpg', 'png', 'jpeg', 'mp4', 'mp3', 'wmv',
|
32
|
-
#Videos
|
33
|
-
'filename.wmv', 'filename.mp4', 'filename.flv',
|
34
|
-
#credit cards number
|
35
|
-
'4111 1111 1111 1111', '5500 0000 0000 0004', '3400 0000 0000 009', '3000 0000 0000 04', '+84 121731845', '84 121731845', '(84) 121731845',
|
36
|
-
#some countries code
|
37
|
-
'84', '1', '39',
|
38
|
-
#ISO countries code
|
39
|
-
'US', 'USA', 'VN', 'VNM',
|
40
|
-
#services'
|
41
|
-
'yahoo', 'google', 'facebook', 'amazone', 'youtube', 'paypal', 'alchemy',
|
42
|
-
#marks
|
43
|
-
'excellent', 'good', 'bad'
|
44
|
-
]
|