@@ -29,29 +29,29 @@ def run_cli_without_token(*args)
29
29
describe 'help and error handling' do
30
30
it 'shows help when --help is passed' do
31
31
stdout , stderr , status = run_cli ( '--help' )
32
-
32
+
33
33
expect ( status . success? ) . to be true
34
34
expect ( stdout ) . to include ( 'Usage: readwise' )
35
35
expect ( stdout ) . to include ( 'Available commands:' )
36
36
end
37
37
38
38
it 'shows help when no arguments are provided' do
39
39
stdout , stderr , status = run_cli ( )
40
-
40
+
41
41
expect ( status . success? ) . to be false
42
42
expect ( stdout ) . to include ( 'Usage: readwise <resource> <action>' )
43
43
end
44
44
45
45
it 'shows error for unknown command' do
46
46
stdout , stderr , status = run_cli ( 'unknown' , 'command' )
47
-
47
+
48
48
expect ( status . success? ) . to be false
49
49
expect ( stdout ) . to include ( "Error: Unknown command 'unknown command'" )
50
50
end
51
51
52
52
it 'shows error when resource or action is missing' do
53
53
stdout , stderr , status = run_cli ( 'document' )
54
-
54
+
55
55
expect ( status . success? ) . to be false
56
56
expect ( stdout ) . to include ( 'Error: Resource and action are required' )
57
57
end
@@ -60,43 +60,43 @@ def run_cli_without_token(*args)
60
60
describe 'document create command' do
61
61
it 'shows help for document create command' do
62
62
stdout , stderr , status = run_cli ( 'document' , 'create' , '--help' )
63
-
63
+
64
64
expect ( status . success? ) . to be true
65
65
expect ( stdout ) . to include ( 'Usage: readwise document create' )
66
66
expect ( stdout ) . to include ( 'Sends HTML content to Readwise Reader API' )
67
67
end
68
68
69
69
it 'shows error when no HTML file is provided' do
70
70
stdout , stderr , status = run_cli ( 'document' , 'create' )
71
-
71
+
72
72
expect ( status . success? ) . to be false
73
73
expect ( stdout ) . to include ( 'Error: HTML file path is required (use --file or -f)' )
74
74
end
75
75
76
76
it 'shows error when file does not exist' do
77
77
stdout , stderr , status = run_cli ( 'document' , 'create' , '--file' , 'nonexistent.html' )
78
-
78
+
79
79
expect ( status . success? ) . to be false
80
80
expect ( stdout ) . to include ( "Error: File 'nonexistent.html' not found" )
81
81
end
82
82
83
83
it 'shows error when READWISE_API_KEY is not set' do
84
84
stdout , stderr , status = run_cli_without_token ( 'document' , 'create' , '--file' , temp_file . path )
85
-
85
+
86
86
expect ( status . success? ) . to be false
87
87
expect ( stdout ) . to include ( 'Error: READWISE_API_KEY environment variable is not set' )
88
88
end
89
89
90
90
it 'shows error for invalid location' do
91
91
stdout , stderr , status = run_cli ( 'document' , 'create' , '--location=invalid' , '--file' , temp_file . path )
92
-
92
+
93
93
expect ( status . success? ) . to be false
94
94
expect ( stdout ) . to include ( 'Error: Invalid location. Must be one of: new, later, archive, feed' )
95
95
end
96
96
97
97
it 'shows error for invalid category' do
98
98
stdout , stderr , status = run_cli ( 'document' , 'create' , '--category=invalid' , '--file' , temp_file . path )
99
-
99
+
100
100
expect ( status . success? ) . to be false
101
101
expect ( stdout ) . to include ( 'Error: Invalid category. Must be one of: article, email, rss, highlight, note, pdf, epub, tweet, video' )
102
102
end
@@ -117,4 +117,4 @@ def run_cli_without_token(*args)
117
117
unreadable_file . unlink
118
118
end
119
119
end
120
- end
120
+ end
0 commit comments